documentation.d.ts 3.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834598355983659837598385983959840598415984259843598445984559846598475984859849598505985159852598535985459855598565985759858598595986059861598625986359864598655986659867598685986959870598715987259873598745987559876598775987859879598805988159882598835988459885598865988759888598895989059891598925989359894598955989659897598985989959900599015990259903599045990559906599075990859909599105991159912599135991459915599165991759918599195992059921599225992359924599255992659927599285992959930599315993259933599345993559936599375993859939599405994159942599435994459945599465994759948599495995059951599525995359954599555995659957599585995959960599615996259963599645996559966599675996859969599705997159972599735997459975599765997759978599795998059981599825998359984599855998659987599885998959990599915999259993599945999559996599975999859999600006000160002600036000460005600066000760008600096001060011600126001360014600156001660017600186001960020600216002260023600246002560026600276002860029600306003160032600336003460035600366003760038600396004060041600426004360044600456004660047600486004960050600516005260053600546005560056600576005860059600606006160062600636006460065600666006760068600696007060071600726007360074600756007660077600786007960080600816008260083600846008560086600876008860089600906009160092600936009460095600966009760098600996010060101601026010360104601056010660107601086010960110601116011260113601146011560116601176011860119601206012160122601236012460125601266012760128601296013060131601326013360134601356013660137601386013960140601416014260143601446014560146601476014860149601506015160152601536015460155601566015760158601596016060161601626016360164601656016660167601686016960170601716017260173601746017560176601776017860179601806018160182601836018460185601866018760188601896019060191601926019360194601956019660197601986019960200602016020260203602046020560206602076020860209602106021160212602136021460215602166021760218602196022060221602226022360224602256022660227602286022960230602316023260233602346023560236602376023860239602406024160242602436024460245602466024760248602496025060251602526025360254602556025660257602586025960260602616026260263602646026560266602676026860269602706027160272602736027460275602766027760278602796028060281602826028360284602856028660287602886028960290602916029260293602946029560296602976029860299603006030160302603036030460305603066030760308603096031060311603126031360314603156031660317603186031960320603216032260323603246032560326603276032860329603306033160332603336033460335603366033760338603396034060341603426034360344603456034660347603486034960350603516035260353603546035560356603576035860359603606036160362603636036460365603666036760368603696037060371603726037360374603756037660377603786037960380603816038260383603846038560386603876038860389603906039160392603936039460395603966039760398603996040060401604026040360404604056040660407604086040960410604116041260413604146041560416604176041860419604206042160422604236042460425604266042760428604296043060431604326043360434604356043660437604386043960440604416044260443604446044560446604476044860449604506045160452604536045460455604566045760458604596046060461604626046360464604656046660467604686046960470604716047260473604746047560476604776047860479604806048160482604836048460485604866048760488604896049060491604926049360494604956049660497604986049960500605016050260503605046050560506605076050860509605106051160512605136051460515605166051760518605196052060521605226052360524605256052660527605286052960530605316053260533605346053560536605376053860539605406054160542605436054460545605466054760548605496055060551605526055360554605556055660557605586055960560605616056260563605646056560566605676056860569605706057160572605736057460575605766057760578605796058060581605826058360584605856058660587605886058960590605916059260593605946059560596605976059860599606006060160602606036060460605606066060760608606096061060611606126061360614606156061660617606186061960620606216062260623606246062560626606276062860629606306063160632606336063460635606366063760638606396064060641606426064360644606456064660647606486064960650606516065260653606546065560656606576065860659606606066160662606636066460665606666066760668606696067060671606726067360674606756067660677606786067960680606816068260683606846068560686606876068860689606906069160692606936069460695606966069760698606996070060701607026070360704607056070660707607086070960710607116071260713607146071560716607176071860719607206072160722607236072460725607266072760728607296073060731607326073360734607356073660737607386073960740607416074260743607446074560746607476074860749607506075160752607536075460755607566075760758607596076060761607626076360764607656076660767607686076960770607716077260773607746077560776607776077860779607806078160782607836078460785607866078760788607896079060791607926079360794607956079660797607986079960800608016080260803608046080560806608076080860809608106081160812608136081460815608166081760818608196082060821608226082360824608256082660827608286082960830608316083260833608346083560836608376083860839608406084160842608436084460845608466084760848608496085060851608526085360854608556085660857608586085960860608616086260863608646086560866608676086860869608706087160872608736087460875608766087760878608796088060881608826088360884608856088660887608886088960890608916089260893608946089560896608976089860899609006090160902609036090460905609066090760908609096091060911609126091360914609156091660917609186091960920609216092260923609246092560926609276092860929609306093160932609336093460935609366093760938609396094060941609426094360944609456094660947609486094960950609516095260953609546095560956609576095860959609606096160962609636096460965609666096760968609696097060971609726097360974609756097660977609786097960980609816098260983609846098560986609876098860989609906099160992609936099460995609966099760998609996100061001610026100361004610056100661007610086100961010610116101261013610146101561016610176101861019610206102161022610236102461025610266102761028610296103061031610326103361034610356103661037610386103961040610416104261043610446104561046610476104861049610506105161052610536105461055610566105761058610596106061061610626106361064610656106661067610686106961070610716107261073610746107561076610776107861079610806108161082610836108461085610866108761088610896109061091610926109361094610956109661097610986109961100611016110261103611046110561106611076110861109611106111161112611136111461115611166111761118611196112061121611226112361124611256112661127611286112961130611316113261133611346113561136611376113861139611406114161142611436114461145611466114761148611496115061151611526115361154611556115661157611586115961160611616116261163611646116561166611676116861169611706117161172611736117461175611766117761178611796118061181611826118361184611856118661187611886118961190611916119261193611946119561196611976119861199612006120161202612036120461205612066120761208612096121061211612126121361214612156121661217612186121961220612216122261223612246122561226612276122861229612306123161232612336123461235612366123761238612396124061241612426124361244612456124661247612486124961250612516125261253612546125561256612576125861259612606126161262612636126461265612666126761268612696127061271612726127361274612756127661277612786127961280612816128261283612846128561286612876128861289612906129161292612936129461295612966129761298612996130061301613026130361304613056130661307613086130961310613116131261313613146131561316613176131861319613206132161322613236132461325613266132761328613296133061331613326133361334613356133661337613386133961340613416134261343613446134561346613476134861349613506135161352613536135461355613566135761358613596136061361613626136361364613656136661367613686136961370613716137261373613746137561376613776137861379613806138161382613836138461385613866138761388613896139061391613926139361394613956139661397613986139961400614016140261403614046140561406614076140861409614106141161412614136141461415614166141761418614196142061421614226142361424614256142661427614286142961430614316143261433614346143561436614376143861439614406144161442614436144461445614466144761448614496145061451614526145361454614556145661457614586145961460614616146261463614646146561466614676146861469614706147161472614736147461475614766147761478614796148061481614826148361484614856148661487614886148961490614916149261493614946149561496614976149861499615006150161502615036150461505615066150761508615096151061511615126151361514615156151661517615186151961520615216152261523615246152561526615276152861529615306153161532615336153461535615366153761538615396154061541615426154361544615456154661547615486154961550615516155261553615546155561556615576155861559615606156161562615636156461565615666156761568615696157061571615726157361574615756157661577615786157961580615816158261583615846158561586615876158861589615906159161592615936159461595615966159761598615996160061601616026160361604616056160661607616086160961610616116161261613616146161561616616176161861619616206162161622616236162461625616266162761628616296163061631616326163361634616356163661637616386163961640616416164261643616446164561646616476164861649616506165161652616536165461655616566165761658616596166061661616626166361664616656166661667616686166961670616716167261673616746167561676616776167861679616806168161682616836168461685616866168761688616896169061691616926169361694616956169661697616986169961700617016170261703617046170561706617076170861709617106171161712617136171461715617166171761718617196172061721617226172361724617256172661727617286172961730617316173261733617346173561736617376173861739617406174161742617436174461745617466174761748617496175061751617526175361754617556175661757617586175961760617616176261763617646176561766617676176861769617706177161772617736177461775617766177761778617796178061781617826178361784617856178661787617886178961790617916179261793617946179561796617976179861799618006180161802618036180461805618066180761808618096181061811618126181361814618156181661817618186181961820618216182261823618246182561826618276182861829618306183161832618336183461835618366183761838618396184061841618426184361844618456184661847618486184961850618516185261853618546185561856618576185861859618606186161862618636186461865618666186761868618696187061871618726187361874618756187661877618786187961880618816188261883618846188561886618876188861889618906189161892618936189461895618966189761898618996190061901619026190361904619056190661907619086190961910619116191261913619146191561916619176191861919619206192161922619236192461925619266192761928619296193061931619326193361934619356193661937619386193961940619416194261943619446194561946619476194861949619506195161952619536195461955619566195761958619596196061961619626196361964619656196661967619686196961970619716197261973619746197561976619776197861979619806198161982619836198461985619866198761988619896199061991619926199361994619956199661997619986199962000620016200262003620046200562006620076200862009620106201162012620136201462015620166201762018620196202062021620226202362024620256202662027620286202962030620316203262033620346203562036620376203862039620406204162042620436204462045620466204762048620496205062051620526205362054620556205662057620586205962060620616206262063620646206562066620676206862069620706207162072620736207462075620766207762078620796208062081620826208362084620856208662087620886208962090620916209262093620946209562096620976209862099621006210162102621036210462105621066210762108621096211062111621126211362114621156211662117621186211962120621216212262123621246212562126621276212862129621306213162132621336213462135621366213762138621396214062141621426214362144621456214662147621486214962150621516215262153621546215562156621576215862159621606216162162621636216462165621666216762168621696217062171621726217362174621756217662177621786217962180621816218262183621846218562186621876218862189621906219162192621936219462195621966219762198621996220062201622026220362204622056220662207622086220962210622116221262213622146221562216622176221862219622206222162222622236222462225622266222762228622296223062231622326223362234622356223662237622386223962240622416224262243622446224562246622476224862249622506225162252622536225462255622566225762258622596226062261622626226362264622656226662267622686226962270622716227262273622746227562276622776227862279622806228162282622836228462285622866228762288622896229062291622926229362294622956229662297622986229962300623016230262303623046230562306623076230862309623106231162312623136231462315623166231762318623196232062321623226232362324623256232662327623286232962330623316233262333623346233562336623376233862339623406234162342623436234462345623466234762348623496235062351623526235362354623556235662357623586235962360623616236262363623646236562366623676236862369623706237162372623736237462375623766237762378623796238062381623826238362384623856238662387623886238962390623916239262393623946239562396623976239862399624006240162402624036240462405624066240762408624096241062411624126241362414624156241662417624186241962420624216242262423624246242562426624276242862429624306243162432624336243462435624366243762438624396244062441624426244362444624456244662447624486244962450624516245262453624546245562456624576245862459624606246162462624636246462465624666246762468624696247062471624726247362474624756247662477624786247962480624816248262483624846248562486624876248862489624906249162492624936249462495624966249762498624996250062501625026250362504625056250662507625086250962510625116251262513625146251562516625176251862519625206252162522625236252462525625266252762528625296253062531625326253362534625356253662537625386253962540625416254262543625446254562546625476254862549625506255162552625536255462555625566255762558625596256062561625626256362564625656256662567625686256962570625716257262573625746257562576625776257862579625806258162582625836258462585625866258762588625896259062591625926259362594625956259662597625986259962600626016260262603626046260562606626076260862609626106261162612626136261462615626166261762618626196262062621626226262362624626256262662627626286262962630626316263262633626346263562636626376263862639626406264162642626436264462645626466264762648626496265062651626526265362654626556265662657626586265962660626616266262663626646266562666626676266862669626706267162672626736267462675626766267762678626796268062681626826268362684626856268662687626886268962690626916269262693626946269562696626976269862699627006270162702627036270462705627066270762708627096271062711627126271362714627156271662717627186271962720627216272262723627246272562726627276272862729627306273162732627336273462735627366273762738627396274062741627426274362744627456274662747627486274962750627516275262753627546275562756627576275862759627606276162762627636276462765627666276762768627696277062771627726277362774627756277662777627786277962780627816278262783627846278562786627876278862789627906279162792627936279462795627966279762798627996280062801628026280362804628056280662807628086280962810628116281262813628146281562816628176281862819628206282162822628236282462825628266282762828628296283062831628326283362834628356283662837628386283962840628416284262843628446284562846628476284862849628506285162852628536285462855628566285762858628596286062861628626286362864628656286662867628686286962870628716287262873628746287562876628776287862879628806288162882628836288462885628866288762888628896289062891628926289362894628956289662897628986289962900629016290262903629046290562906629076290862909629106291162912629136291462915629166291762918629196292062921629226292362924629256292662927629286292962930629316293262933629346293562936629376293862939629406294162942629436294462945629466294762948629496295062951629526295362954629556295662957629586295962960629616296262963629646296562966629676296862969629706297162972629736297462975629766297762978629796298062981629826298362984629856298662987629886298962990629916299262993629946299562996629976299862999630006300163002630036300463005630066300763008630096301063011630126301363014630156301663017630186301963020630216302263023630246302563026630276302863029630306303163032630336303463035630366303763038630396304063041630426304363044630456304663047630486304963050630516305263053630546305563056630576305863059630606306163062630636306463065630666306763068630696307063071630726307363074630756307663077630786307963080630816308263083630846308563086630876308863089630906309163092630936309463095630966309763098630996310063101631026310363104631056310663107631086310963110631116311263113631146311563116631176311863119631206312163122631236312463125631266312763128631296313063131631326313363134631356313663137631386313963140631416314263143631446314563146631476314863149631506315163152631536315463155631566315763158631596316063161631626316363164631656316663167631686316963170631716317263173631746317563176631776317863179631806318163182631836318463185631866318763188631896319063191631926319363194631956319663197631986319963200632016320263203632046320563206632076320863209632106321163212632136321463215632166321763218632196322063221632226322363224632256322663227632286322963230632316323263233632346323563236632376323863239632406324163242632436324463245632466324763248632496325063251632526325363254632556325663257632586325963260632616326263263632646326563266632676326863269632706327163272632736327463275632766327763278632796328063281632826328363284632856328663287632886328963290632916329263293632946329563296632976329863299633006330163302633036330463305633066330763308633096331063311633126331363314633156331663317633186331963320633216332263323633246332563326633276332863329633306333163332633336333463335633366333763338633396334063341633426334363344633456334663347633486334963350633516335263353633546335563356633576335863359633606336163362633636336463365633666336763368633696337063371633726337363374633756337663377633786337963380633816338263383633846338563386633876338863389633906339163392633936339463395633966339763398633996340063401634026340363404634056340663407634086340963410634116341263413634146341563416634176341863419634206342163422634236342463425634266342763428634296343063431634326343363434634356343663437634386343963440634416344263443634446344563446634476344863449634506345163452634536345463455634566345763458634596346063461634626346363464634656346663467634686346963470634716347263473634746347563476634776347863479634806348163482634836348463485634866348763488634896349063491634926349363494634956349663497634986349963500635016350263503635046350563506635076350863509635106351163512635136351463515635166351763518635196352063521635226352363524635256352663527635286352963530635316353263533635346353563536635376353863539635406354163542635436354463545635466354763548635496355063551635526355363554635556355663557635586355963560635616356263563635646356563566635676356863569635706357163572635736357463575635766357763578635796358063581635826358363584635856358663587635886358963590635916359263593635946359563596635976359863599636006360163602636036360463605636066360763608636096361063611636126361363614636156361663617636186361963620636216362263623636246362563626636276362863629636306363163632636336363463635636366363763638636396364063641636426364363644636456364663647636486364963650636516365263653636546365563656636576365863659636606366163662636636366463665636666366763668636696367063671636726367363674636756367663677636786367963680636816368263683636846368563686636876368863689636906369163692636936369463695636966369763698636996370063701637026370363704637056370663707637086370963710637116371263713637146371563716637176371863719637206372163722637236372463725637266372763728637296373063731637326373363734637356373663737637386373963740637416374263743637446374563746637476374863749637506375163752637536375463755637566375763758637596376063761637626376363764637656376663767637686376963770637716377263773637746377563776637776377863779637806378163782637836378463785637866378763788637896379063791637926379363794637956379663797637986379963800638016380263803638046380563806638076380863809638106381163812638136381463815638166381763818638196382063821638226382363824638256382663827638286382963830638316383263833638346383563836638376383863839638406384163842638436384463845638466384763848638496385063851638526385363854638556385663857638586385963860638616386263863638646386563866638676386863869638706387163872638736387463875638766387763878638796388063881638826388363884638856388663887638886388963890638916389263893638946389563896638976389863899639006390163902639036390463905639066390763908639096391063911639126391363914639156391663917639186391963920639216392263923639246392563926639276392863929639306393163932639336393463935639366393763938639396394063941639426394363944639456394663947639486394963950639516395263953639546395563956639576395863959639606396163962639636396463965639666396763968639696397063971639726397363974639756397663977639786397963980639816398263983639846398563986639876398863989639906399163992639936399463995639966399763998639996400064001640026400364004640056400664007640086400964010640116401264013640146401564016640176401864019640206402164022640236402464025640266402764028640296403064031640326403364034640356403664037640386403964040640416404264043640446404564046640476404864049640506405164052640536405464055640566405764058640596406064061640626406364064640656406664067640686406964070640716407264073640746407564076640776407864079640806408164082640836408464085640866408764088640896409064091640926409364094640956409664097640986409964100641016410264103641046410564106641076410864109641106411164112641136411464115641166411764118641196412064121641226412364124641256412664127641286412964130641316413264133641346413564136641376413864139641406414164142641436414464145641466414764148641496415064151641526415364154641556415664157641586415964160641616416264163641646416564166641676416864169641706417164172641736417464175641766417764178641796418064181641826418364184641856418664187641886418964190641916419264193641946419564196641976419864199642006420164202642036420464205642066420764208642096421064211642126421364214642156421664217642186421964220642216422264223642246422564226642276422864229642306423164232642336423464235642366423764238642396424064241642426424364244642456424664247642486424964250642516425264253642546425564256642576425864259642606426164262642636426464265642666426764268642696427064271642726427364274642756427664277642786427964280642816428264283642846428564286642876428864289642906429164292642936429464295642966429764298642996430064301643026430364304643056430664307643086430964310643116431264313643146431564316643176431864319643206432164322643236432464325643266432764328643296433064331643326433364334643356433664337643386433964340643416434264343643446434564346643476434864349643506435164352643536435464355643566435764358643596436064361643626436364364643656436664367643686436964370643716437264373643746437564376643776437864379643806438164382643836438464385643866438764388643896439064391643926439364394643956439664397643986439964400644016440264403644046440564406644076440864409644106441164412644136441464415644166441764418644196442064421644226442364424644256442664427644286442964430644316443264433644346443564436644376443864439644406444164442644436444464445644466444764448644496445064451644526445364454644556445664457644586445964460644616446264463644646446564466644676446864469644706447164472644736447464475644766447764478644796448064481644826448364484644856448664487644886448964490644916449264493644946449564496644976449864499645006450164502645036450464505645066450764508645096451064511645126451364514645156451664517645186451964520645216452264523645246452564526645276452864529645306453164532645336453464535645366453764538645396454064541645426454364544645456454664547645486454964550645516455264553645546455564556645576455864559645606456164562645636456464565645666456764568645696457064571645726457364574645756457664577645786457964580645816458264583645846458564586645876458864589645906459164592645936459464595645966459764598645996460064601646026460364604646056460664607646086460964610646116461264613646146461564616646176461864619646206462164622646236462464625646266462764628646296463064631646326463364634646356463664637646386463964640646416464264643646446464564646646476464864649646506465164652646536465464655646566465764658646596466064661646626466364664646656466664667646686466964670646716467264673646746467564676646776467864679646806468164682646836468464685646866468764688646896469064691646926469364694646956469664697646986469964700647016470264703647046470564706647076470864709647106471164712647136471464715647166471764718647196472064721647226472364724647256472664727647286472964730647316473264733647346473564736647376473864739647406474164742647436474464745647466474764748647496475064751647526475364754647556475664757647586475964760647616476264763647646476564766647676476864769647706477164772647736477464775647766477764778647796478064781647826478364784647856478664787647886478964790647916479264793647946479564796647976479864799648006480164802648036480464805648066480764808648096481064811648126481364814648156481664817648186481964820648216482264823648246482564826648276482864829648306483164832648336483464835648366483764838648396484064841648426484364844648456484664847648486484964850648516485264853648546485564856648576485864859648606486164862648636486464865648666486764868648696487064871648726487364874648756487664877648786487964880648816488264883648846488564886648876488864889648906489164892648936489464895648966489764898648996490064901649026490364904649056490664907649086490964910649116491264913649146491564916649176491864919649206492164922649236492464925649266492764928649296493064931649326493364934649356493664937649386493964940649416494264943649446494564946649476494864949649506495164952649536495464955649566495764958649596496064961649626496364964649656496664967649686496964970649716497264973649746497564976649776497864979649806498164982649836498464985649866498764988649896499064991649926499364994649956499664997649986499965000650016500265003650046500565006650076500865009650106501165012650136501465015650166501765018650196502065021650226502365024650256502665027650286502965030650316503265033650346503565036650376503865039650406504165042650436504465045650466504765048650496505065051650526505365054650556505665057650586505965060650616506265063650646506565066650676506865069650706507165072650736507465075650766507765078650796508065081650826508365084650856508665087650886508965090650916509265093650946509565096650976509865099651006510165102651036510465105651066510765108651096511065111651126511365114651156511665117651186511965120651216512265123651246512565126651276512865129651306513165132651336513465135651366513765138651396514065141651426514365144651456514665147651486514965150651516515265153651546515565156651576515865159651606516165162651636516465165651666516765168651696517065171651726517365174651756517665177651786517965180651816518265183651846518565186651876518865189651906519165192651936519465195651966519765198651996520065201652026520365204652056520665207652086520965210652116521265213652146521565216652176521865219652206522165222652236522465225652266522765228652296523065231652326523365234652356523665237652386523965240652416524265243652446524565246652476524865249652506525165252652536525465255652566525765258652596526065261652626526365264652656526665267652686526965270652716527265273652746527565276652776527865279652806528165282652836528465285652866528765288652896529065291652926529365294652956529665297652986529965300653016530265303653046530565306653076530865309653106531165312653136531465315653166531765318653196532065321653226532365324653256532665327653286532965330653316533265333653346533565336653376533865339653406534165342653436534465345653466534765348653496535065351653526535365354653556535665357653586535965360653616536265363653646536565366653676536865369653706537165372653736537465375653766537765378653796538065381653826538365384653856538665387653886538965390653916539265393653946539565396653976539865399654006540165402654036540465405654066540765408654096541065411654126541365414654156541665417654186541965420654216542265423654246542565426654276542865429654306543165432654336543465435654366543765438654396544065441654426544365444654456544665447654486544965450654516545265453654546545565456654576545865459654606546165462654636546465465654666546765468654696547065471654726547365474654756547665477654786547965480654816548265483654846548565486654876548865489654906549165492654936549465495654966549765498654996550065501655026550365504655056550665507655086550965510655116551265513655146551565516655176551865519655206552165522655236552465525655266552765528655296553065531655326553365534655356553665537655386553965540655416554265543655446554565546655476554865549655506555165552655536555465555655566555765558655596556065561655626556365564655656556665567655686556965570655716557265573655746557565576655776557865579655806558165582655836558465585655866558765588655896559065591655926559365594655956559665597655986559965600656016560265603656046560565606656076560865609656106561165612656136561465615656166561765618656196562065621656226562365624656256562665627656286562965630656316563265633656346563565636656376563865639656406564165642656436564465645656466564765648656496565065651656526565365654656556565665657656586565965660656616566265663656646566565666656676566865669656706567165672656736567465675656766567765678656796568065681656826568365684656856568665687656886568965690656916569265693656946569565696656976569865699657006570165702657036570465705657066570765708657096571065711657126571365714657156571665717657186571965720657216572265723657246572565726657276572865729657306573165732657336573465735657366573765738657396574065741657426574365744657456574665747657486574965750657516575265753657546575565756657576575865759657606576165762657636576465765657666576765768657696577065771657726577365774657756577665777657786577965780657816578265783657846578565786657876578865789657906579165792657936579465795657966579765798657996580065801658026580365804658056580665807658086580965810658116581265813658146581565816658176581865819658206582165822658236582465825658266582765828658296583065831658326583365834658356583665837658386583965840658416584265843658446584565846658476584865849658506585165852658536585465855658566585765858658596586065861658626586365864658656586665867658686586965870658716587265873658746587565876658776587865879658806588165882658836588465885658866588765888658896589065891658926589365894658956589665897658986589965900659016590265903659046590565906659076590865909659106591165912659136591465915659166591765918659196592065921659226592365924659256592665927659286592965930659316593265933659346593565936659376593865939659406594165942659436594465945659466594765948659496595065951659526595365954659556595665957659586595965960659616596265963659646596565966659676596865969659706597165972659736597465975659766597765978659796598065981659826598365984659856598665987659886598965990659916599265993659946599565996659976599865999660006600166002660036600466005660066600766008660096601066011660126601366014660156601666017660186601966020660216602266023660246602566026660276602866029660306603166032660336603466035660366603766038660396604066041660426604366044660456604666047660486604966050660516605266053660546605566056660576605866059660606606166062660636606466065660666606766068660696607066071660726607366074660756607666077660786607966080660816608266083660846608566086660876608866089660906609166092660936609466095660966609766098660996610066101661026610366104661056610666107661086610966110661116611266113661146611566116661176611866119661206612166122661236612466125661266612766128661296613066131661326613366134661356613666137661386613966140661416614266143661446614566146661476614866149661506615166152661536615466155661566615766158661596616066161661626616366164661656616666167661686616966170661716617266173661746617566176661776617866179661806618166182661836618466185661866618766188661896619066191661926619366194661956619666197661986619966200662016620266203662046620566206662076620866209662106621166212662136621466215662166621766218662196622066221662226622366224662256622666227662286622966230662316623266233662346623566236662376623866239662406624166242662436624466245662466624766248662496625066251662526625366254662556625666257662586625966260662616626266263662646626566266662676626866269662706627166272662736627466275662766627766278662796628066281662826628366284662856628666287662886628966290662916629266293662946629566296662976629866299663006630166302663036630466305663066630766308663096631066311663126631366314663156631666317663186631966320663216632266323663246632566326663276632866329663306633166332663336633466335663366633766338663396634066341663426634366344663456634666347663486634966350663516635266353663546635566356663576635866359663606636166362663636636466365663666636766368663696637066371663726637366374663756637666377663786637966380663816638266383663846638566386663876638866389663906639166392663936639466395663966639766398663996640066401664026640366404664056640666407664086640966410664116641266413664146641566416664176641866419664206642166422664236642466425664266642766428664296643066431664326643366434664356643666437664386643966440664416644266443664446644566446664476644866449664506645166452664536645466455664566645766458664596646066461664626646366464664656646666467664686646966470664716647266473664746647566476664776647866479664806648166482664836648466485664866648766488664896649066491664926649366494664956649666497664986649966500665016650266503665046650566506665076650866509665106651166512665136651466515665166651766518665196652066521665226652366524665256652666527665286652966530665316653266533665346653566536665376653866539665406654166542665436654466545665466654766548665496655066551665526655366554665556655666557665586655966560665616656266563665646656566566665676656866569665706657166572665736657466575665766657766578665796658066581665826658366584665856658666587665886658966590665916659266593665946659566596665976659866599666006660166602666036660466605666066660766608666096661066611666126661366614666156661666617666186661966620666216662266623666246662566626666276662866629666306663166632666336663466635666366663766638666396664066641666426664366644666456664666647666486664966650666516665266653666546665566656666576665866659666606666166662666636666466665666666666766668666696667066671666726667366674666756667666677666786667966680666816668266683666846668566686666876668866689666906669166692666936669466695666966669766698666996670066701667026670366704667056670666707667086670966710667116671266713667146671566716667176671866719667206672166722667236672466725667266672766728667296673066731667326673366734667356673666737667386673966740667416674266743667446674566746667476674866749667506675166752667536675466755667566675766758667596676066761667626676366764667656676666767667686676966770667716677266773667746677566776667776677866779667806678166782667836678466785667866678766788667896679066791667926679366794667956679666797667986679966800668016680266803668046680566806668076680866809668106681166812668136681466815668166681766818668196682066821668226682366824668256682666827668286682966830668316683266833668346683566836668376683866839668406684166842668436684466845668466684766848668496685066851668526685366854668556685666857668586685966860668616686266863668646686566866668676686866869668706687166872668736687466875668766687766878668796688066881668826688366884668856688666887668886688966890668916689266893668946689566896668976689866899669006690166902669036690466905669066690766908669096691066911669126691366914669156691666917669186691966920669216692266923669246692566926669276692866929669306693166932669336693466935669366693766938669396694066941669426694366944669456694666947669486694966950669516695266953669546695566956669576695866959669606696166962669636696466965669666696766968669696697066971669726697366974669756697666977669786697966980669816698266983669846698566986669876698866989669906699166992669936699466995669966699766998669996700067001670026700367004670056700667007670086700967010670116701267013670146701567016670176701867019670206702167022670236702467025670266702767028670296703067031670326703367034670356703667037670386703967040670416704267043670446704567046670476704867049670506705167052670536705467055670566705767058670596706067061670626706367064670656706667067670686706967070670716707267073670746707567076670776707867079670806708167082670836708467085670866708767088670896709067091670926709367094670956709667097670986709967100671016710267103671046710567106671076710867109671106711167112671136711467115671166711767118671196712067121671226712367124671256712667127671286712967130671316713267133671346713567136671376713867139671406714167142671436714467145671466714767148671496715067151671526715367154671556715667157671586715967160671616716267163671646716567166671676716867169671706717167172671736717467175671766717767178671796718067181671826718367184671856718667187671886718967190671916719267193671946719567196671976719867199672006720167202672036720467205672066720767208672096721067211672126721367214672156721667217672186721967220672216722267223672246722567226672276722867229672306723167232672336723467235672366723767238672396724067241672426724367244672456724667247672486724967250672516725267253672546725567256672576725867259672606726167262672636726467265672666726767268672696727067271672726727367274672756727667277672786727967280672816728267283672846728567286672876728867289672906729167292672936729467295672966729767298672996730067301673026730367304673056730667307673086730967310673116731267313673146731567316673176731867319673206732167322673236732467325673266732767328673296733067331673326733367334673356733667337673386733967340673416734267343673446734567346673476734867349673506735167352673536735467355673566735767358673596736067361673626736367364673656736667367673686736967370673716737267373673746737567376673776737867379673806738167382673836738467385673866738767388673896739067391673926739367394673956739667397673986739967400674016740267403674046740567406674076740867409674106741167412674136741467415674166741767418674196742067421674226742367424674256742667427674286742967430674316743267433674346743567436674376743867439674406744167442674436744467445674466744767448674496745067451674526745367454674556745667457674586745967460674616746267463674646746567466674676746867469674706747167472674736747467475674766747767478674796748067481674826748367484674856748667487674886748967490674916749267493674946749567496674976749867499675006750167502675036750467505675066750767508675096751067511675126751367514675156751667517675186751967520675216752267523675246752567526675276752867529675306753167532675336753467535675366753767538675396754067541675426754367544675456754667547675486754967550675516755267553675546755567556675576755867559675606756167562675636756467565675666756767568675696757067571675726757367574675756757667577675786757967580675816758267583675846758567586675876758867589675906759167592675936759467595675966759767598675996760067601676026760367604676056760667607676086760967610676116761267613676146761567616676176761867619676206762167622676236762467625676266762767628676296763067631676326763367634676356763667637676386763967640676416764267643676446764567646676476764867649676506765167652676536765467655676566765767658676596766067661676626766367664676656766667667676686766967670676716767267673676746767567676676776767867679676806768167682676836768467685676866768767688676896769067691676926769367694676956769667697676986769967700677016770267703677046770567706677076770867709677106771167712677136771467715677166771767718677196772067721677226772367724677256772667727677286772967730677316773267733677346773567736677376773867739677406774167742677436774467745677466774767748677496775067751677526775367754677556775667757677586775967760677616776267763677646776567766677676776867769677706777167772677736777467775677766777767778677796778067781677826778367784677856778667787677886778967790677916779267793677946779567796677976779867799678006780167802678036780467805678066780767808678096781067811678126781367814678156781667817678186781967820678216782267823678246782567826678276782867829678306783167832678336783467835678366783767838678396784067841678426784367844678456784667847678486784967850678516785267853678546785567856678576785867859678606786167862678636786467865678666786767868678696787067871678726787367874678756787667877678786787967880678816788267883678846788567886678876788867889678906789167892678936789467895678966789767898678996790067901679026790367904679056790667907679086790967910679116791267913679146791567916679176791867919679206792167922679236792467925679266792767928679296793067931679326793367934679356793667937679386793967940679416794267943679446794567946679476794867949679506795167952679536795467955679566795767958679596796067961679626796367964679656796667967679686796967970679716797267973679746797567976679776797867979679806798167982679836798467985679866798767988679896799067991679926799367994679956799667997679986799968000680016800268003680046800568006680076800868009680106801168012680136801468015680166801768018680196802068021680226802368024680256802668027680286802968030680316803268033680346803568036680376803868039680406804168042680436804468045680466804768048680496805068051680526805368054680556805668057680586805968060680616806268063680646806568066680676806868069680706807168072680736807468075680766807768078680796808068081680826808368084680856808668087680886808968090680916809268093680946809568096680976809868099681006810168102681036810468105681066810768108681096811068111681126811368114681156811668117681186811968120681216812268123681246812568126681276812868129681306813168132681336813468135681366813768138681396814068141681426814368144681456814668147681486814968150681516815268153681546815568156681576815868159681606816168162681636816468165681666816768168681696817068171681726817368174681756817668177681786817968180681816818268183681846818568186681876818868189681906819168192681936819468195681966819768198681996820068201682026820368204682056820668207682086820968210682116821268213682146821568216682176821868219682206822168222682236822468225682266822768228682296823068231682326823368234682356823668237682386823968240682416824268243682446824568246682476824868249682506825168252682536825468255682566825768258682596826068261682626826368264682656826668267682686826968270682716827268273682746827568276682776827868279682806828168282682836828468285682866828768288682896829068291682926829368294682956829668297682986829968300683016830268303683046830568306683076830868309683106831168312683136831468315683166831768318683196832068321683226832368324683256832668327683286832968330683316833268333683346833568336683376833868339683406834168342683436834468345683466834768348683496835068351683526835368354683556835668357683586835968360683616836268363683646836568366683676836868369683706837168372683736837468375683766837768378683796838068381683826838368384683856838668387683886838968390683916839268393683946839568396683976839868399684006840168402684036840468405684066840768408684096841068411684126841368414684156841668417684186841968420684216842268423684246842568426684276842868429684306843168432684336843468435684366843768438684396844068441684426844368444684456844668447684486844968450684516845268453684546845568456684576845868459684606846168462684636846468465684666846768468684696847068471684726847368474684756847668477684786847968480684816848268483684846848568486684876848868489684906849168492684936849468495684966849768498684996850068501685026850368504685056850668507685086850968510685116851268513685146851568516685176851868519685206852168522685236852468525685266852768528685296853068531685326853368534685356853668537685386853968540685416854268543685446854568546685476854868549685506855168552685536855468555685566855768558685596856068561685626856368564685656856668567685686856968570685716857268573685746857568576685776857868579685806858168582685836858468585685866858768588685896859068591685926859368594685956859668597685986859968600686016860268603686046860568606686076860868609686106861168612686136861468615686166861768618686196862068621686226862368624686256862668627686286862968630686316863268633686346863568636686376863868639686406864168642686436864468645686466864768648686496865068651686526865368654686556865668657686586865968660686616866268663686646866568666686676866868669686706867168672686736867468675686766867768678686796868068681686826868368684686856868668687686886868968690686916869268693686946869568696686976869868699687006870168702687036870468705687066870768708687096871068711687126871368714687156871668717687186871968720687216872268723687246872568726687276872868729687306873168732687336873468735687366873768738687396874068741687426874368744687456874668747687486874968750687516875268753687546875568756687576875868759687606876168762687636876468765687666876768768687696877068771687726877368774687756877668777687786877968780687816878268783687846878568786687876878868789687906879168792687936879468795687966879768798687996880068801688026880368804688056880668807688086880968810688116881268813688146881568816688176881868819688206882168822688236882468825688266882768828688296883068831688326883368834688356883668837688386883968840688416884268843688446884568846688476884868849688506885168852688536885468855688566885768858688596886068861688626886368864688656886668867688686886968870688716887268873688746887568876688776887868879688806888168882688836888468885688866888768888688896889068891688926889368894688956889668897688986889968900689016890268903689046890568906689076890868909689106891168912689136891468915689166891768918689196892068921689226892368924689256892668927689286892968930689316893268933689346893568936689376893868939689406894168942689436894468945689466894768948689496895068951689526895368954689556895668957689586895968960689616896268963689646896568966689676896868969689706897168972689736897468975689766897768978689796898068981689826898368984689856898668987689886898968990689916899268993689946899568996689976899868999690006900169002690036900469005690066900769008690096901069011690126901369014690156901669017690186901969020690216902269023690246902569026690276902869029690306903169032690336903469035690366903769038690396904069041690426904369044690456904669047690486904969050690516905269053690546905569056690576905869059690606906169062690636906469065690666906769068690696907069071690726907369074690756907669077690786907969080690816908269083690846908569086690876908869089690906909169092690936909469095690966909769098690996910069101691026910369104691056910669107691086910969110691116911269113691146911569116691176911869119691206912169122691236912469125691266912769128691296913069131691326913369134691356913669137691386913969140691416914269143691446914569146691476914869149691506915169152691536915469155691566915769158691596916069161691626916369164691656916669167691686916969170691716917269173691746917569176691776917869179691806918169182691836918469185691866918769188691896919069191691926919369194691956919669197691986919969200692016920269203692046920569206692076920869209692106921169212692136921469215692166921769218692196922069221692226922369224692256922669227692286922969230692316923269233692346923569236692376923869239692406924169242692436924469245692466924769248692496925069251692526925369254692556925669257692586925969260692616926269263692646926569266692676926869269692706927169272692736927469275692766927769278692796928069281692826928369284692856928669287692886928969290692916929269293692946929569296692976929869299693006930169302693036930469305693066930769308693096931069311693126931369314693156931669317693186931969320693216932269323693246932569326693276932869329693306933169332693336933469335693366933769338693396934069341693426934369344693456934669347693486934969350693516935269353693546935569356693576935869359693606936169362693636936469365693666936769368693696937069371693726937369374693756937669377693786937969380693816938269383693846938569386693876938869389693906939169392693936939469395693966939769398693996940069401694026940369404694056940669407694086940969410694116941269413694146941569416694176941869419694206942169422694236942469425694266942769428694296943069431694326943369434694356943669437694386943969440694416944269443694446944569446694476944869449694506945169452694536945469455694566945769458694596946069461694626946369464694656946669467694686946969470694716947269473694746947569476694776947869479694806948169482694836948469485694866948769488694896949069491694926949369494694956949669497694986949969500695016950269503695046950569506695076950869509695106951169512695136951469515695166951769518695196952069521695226952369524695256952669527695286952969530695316953269533695346953569536695376953869539695406954169542695436954469545695466954769548695496955069551695526955369554695556955669557695586955969560695616956269563695646956569566695676956869569695706957169572695736957469575695766957769578695796958069581695826958369584695856958669587695886958969590695916959269593695946959569596695976959869599696006960169602696036960469605696066960769608696096961069611696126961369614696156961669617696186961969620696216962269623696246962569626696276962869629696306963169632696336963469635696366963769638696396964069641696426964369644696456964669647696486964969650696516965269653696546965569656696576965869659696606966169662696636966469665696666966769668696696967069671696726967369674696756967669677696786967969680696816968269683696846968569686696876968869689696906969169692696936969469695696966969769698696996970069701697026970369704697056970669707697086970969710697116971269713697146971569716697176971869719697206972169722697236972469725697266972769728697296973069731697326973369734697356973669737697386973969740697416974269743697446974569746697476974869749697506975169752697536975469755697566975769758697596976069761697626976369764697656976669767697686976969770697716977269773697746977569776697776977869779697806978169782697836978469785697866978769788697896979069791697926979369794697956979669797697986979969800698016980269803698046980569806698076980869809698106981169812698136981469815698166981769818698196982069821698226982369824698256982669827698286982969830698316983269833698346983569836698376983869839698406984169842698436984469845698466984769848698496985069851698526985369854698556985669857698586985969860698616986269863698646986569866698676986869869698706987169872698736987469875698766987769878698796988069881698826988369884698856988669887698886988969890698916989269893698946989569896698976989869899699006990169902699036990469905699066990769908699096991069911699126991369914699156991669917699186991969920699216992269923699246992569926699276992869929699306993169932699336993469935699366993769938699396994069941699426994369944699456994669947699486994969950699516995269953699546995569956699576995869959699606996169962699636996469965699666996769968699696997069971699726997369974699756997669977699786997969980699816998269983699846998569986699876998869989699906999169992699936999469995699966999769998699997000070001700027000370004700057000670007700087000970010700117001270013700147001570016700177001870019700207002170022700237002470025700267002770028700297003070031700327003370034700357003670037700387003970040700417004270043700447004570046700477004870049700507005170052700537005470055700567005770058700597006070061700627006370064700657006670067700687006970070700717007270073700747007570076700777007870079700807008170082700837008470085700867008770088700897009070091700927009370094700957009670097700987009970100701017010270103701047010570106701077010870109701107011170112701137011470115701167011770118701197012070121701227012370124701257012670127701287012970130701317013270133701347013570136701377013870139701407014170142701437014470145701467014770148701497015070151701527015370154701557015670157701587015970160701617016270163701647016570166701677016870169701707017170172701737017470175701767017770178701797018070181701827018370184701857018670187701887018970190701917019270193701947019570196701977019870199702007020170202702037020470205702067020770208702097021070211702127021370214702157021670217702187021970220702217022270223702247022570226702277022870229702307023170232702337023470235702367023770238702397024070241702427024370244702457024670247702487024970250702517025270253702547025570256702577025870259702607026170262702637026470265702667026770268702697027070271702727027370274702757027670277702787027970280702817028270283702847028570286702877028870289702907029170292702937029470295702967029770298702997030070301703027030370304703057030670307703087030970310703117031270313703147031570316703177031870319703207032170322703237032470325703267032770328703297033070331703327033370334703357033670337703387033970340703417034270343703447034570346703477034870349703507035170352703537035470355703567035770358703597036070361703627036370364703657036670367703687036970370703717037270373703747037570376703777037870379703807038170382703837038470385703867038770388703897039070391703927039370394703957039670397703987039970400704017040270403704047040570406704077040870409704107041170412704137041470415704167041770418704197042070421704227042370424704257042670427704287042970430704317043270433704347043570436704377043870439704407044170442704437044470445704467044770448704497045070451704527045370454704557045670457704587045970460704617046270463704647046570466704677046870469704707047170472704737047470475704767047770478704797048070481704827048370484704857048670487704887048970490704917049270493704947049570496704977049870499705007050170502705037050470505705067050770508705097051070511705127051370514705157051670517705187051970520705217052270523705247052570526705277052870529705307053170532705337053470535705367053770538705397054070541705427054370544705457054670547705487054970550705517055270553705547055570556705577055870559705607056170562705637056470565705667056770568705697057070571705727057370574705757057670577705787057970580705817058270583705847058570586705877058870589705907059170592705937059470595705967059770598705997060070601706027060370604706057060670607706087060970610706117061270613706147061570616706177061870619706207062170622706237062470625706267062770628706297063070631706327063370634706357063670637706387063970640706417064270643706447064570646706477064870649706507065170652706537065470655706567065770658706597066070661706627066370664706657066670667706687066970670706717067270673706747067570676706777067870679706807068170682706837068470685706867068770688706897069070691706927069370694706957069670697706987069970700707017070270703707047070570706707077070870709707107071170712707137071470715707167071770718707197072070721707227072370724707257072670727707287072970730707317073270733707347073570736707377073870739707407074170742707437074470745707467074770748707497075070751707527075370754707557075670757707587075970760707617076270763707647076570766707677076870769707707077170772707737077470775707767077770778707797078070781707827078370784707857078670787707887078970790707917079270793707947079570796707977079870799708007080170802708037080470805708067080770808708097081070811708127081370814708157081670817708187081970820708217082270823708247082570826708277082870829708307083170832708337083470835708367083770838708397084070841708427084370844708457084670847708487084970850708517085270853708547085570856708577085870859708607086170862708637086470865708667086770868708697087070871708727087370874708757087670877708787087970880708817088270883708847088570886708877088870889708907089170892708937089470895708967089770898708997090070901709027090370904709057090670907709087090970910709117091270913709147091570916709177091870919709207092170922709237092470925709267092770928709297093070931709327093370934709357093670937709387093970940709417094270943709447094570946709477094870949709507095170952709537095470955709567095770958709597096070961709627096370964709657096670967709687096970970709717097270973709747097570976709777097870979709807098170982709837098470985709867098770988709897099070991709927099370994709957099670997709987099971000710017100271003710047100571006710077100871009710107101171012710137101471015710167101771018710197102071021710227102371024710257102671027710287102971030710317103271033710347103571036710377103871039710407104171042710437104471045710467104771048710497105071051710527105371054710557105671057710587105971060710617106271063710647106571066710677106871069710707107171072710737107471075710767107771078710797108071081710827108371084710857108671087710887108971090710917109271093710947109571096710977109871099711007110171102711037110471105711067110771108711097111071111711127111371114711157111671117711187111971120711217112271123711247112571126711277112871129711307113171132711337113471135711367113771138711397114071141711427114371144711457114671147711487114971150711517115271153711547115571156711577115871159711607116171162711637116471165711667116771168711697117071171711727117371174711757117671177711787117971180711817118271183711847118571186711877118871189711907119171192711937119471195711967119771198711997120071201712027120371204712057120671207712087120971210712117121271213712147121571216712177121871219712207122171222712237122471225712267122771228712297123071231712327123371234712357123671237712387123971240712417124271243712447124571246712477124871249712507125171252712537125471255712567125771258712597126071261712627126371264712657126671267712687126971270712717127271273712747127571276712777127871279712807128171282712837128471285712867128771288712897129071291712927129371294712957129671297712987129971300713017130271303713047130571306713077130871309713107131171312713137131471315713167131771318713197132071321713227132371324713257132671327713287132971330713317133271333713347133571336713377133871339713407134171342713437134471345713467134771348713497135071351713527135371354713557135671357713587135971360713617136271363713647136571366713677136871369713707137171372713737137471375713767137771378713797138071381713827138371384713857138671387713887138971390713917139271393713947139571396713977139871399714007140171402714037140471405714067140771408714097141071411714127141371414714157141671417714187141971420714217142271423714247142571426714277142871429714307143171432714337143471435714367143771438714397144071441714427144371444714457144671447714487144971450714517145271453714547145571456714577145871459714607146171462714637146471465714667146771468714697147071471714727147371474714757147671477714787147971480714817148271483714847148571486714877148871489714907149171492714937149471495714967149771498714997150071501715027150371504715057150671507715087150971510715117151271513715147151571516715177151871519715207152171522715237152471525715267152771528715297153071531715327153371534715357153671537715387153971540715417154271543715447154571546715477154871549715507155171552715537155471555715567155771558715597156071561715627156371564715657156671567715687156971570715717157271573715747157571576715777157871579715807158171582715837158471585715867158771588715897159071591715927159371594715957159671597715987159971600716017160271603716047160571606716077160871609716107161171612716137161471615716167161771618716197162071621716227162371624716257162671627716287162971630716317163271633716347163571636716377163871639716407164171642716437164471645716467164771648716497165071651716527165371654716557165671657716587165971660716617166271663716647166571666716677166871669716707167171672716737167471675716767167771678716797168071681716827168371684716857168671687716887168971690716917169271693716947169571696716977169871699717007170171702717037170471705717067170771708717097171071711717127171371714717157171671717717187171971720717217172271723717247172571726717277172871729717307173171732717337173471735717367173771738717397174071741717427174371744717457174671747717487174971750717517175271753717547175571756717577175871759717607176171762717637176471765717667176771768717697177071771717727177371774717757177671777717787177971780717817178271783717847178571786717877178871789717907179171792717937179471795717967179771798717997180071801718027180371804718057180671807718087180971810718117181271813718147181571816718177181871819718207182171822718237182471825718267182771828718297183071831718327183371834718357183671837718387183971840718417184271843718447184571846718477184871849718507185171852718537185471855718567185771858718597186071861718627186371864718657186671867718687186971870718717187271873718747187571876718777187871879718807188171882718837188471885718867188771888718897189071891718927189371894718957189671897718987189971900719017190271903719047190571906719077190871909719107191171912719137191471915719167191771918719197192071921719227192371924719257192671927719287192971930719317193271933719347193571936719377193871939719407194171942719437194471945719467194771948719497195071951719527195371954719557195671957719587195971960719617196271963719647196571966719677196871969719707197171972719737197471975719767197771978719797198071981719827198371984719857198671987719887198971990719917199271993719947199571996719977199871999720007200172002720037200472005720067200772008720097201072011720127201372014720157201672017720187201972020720217202272023720247202572026720277202872029720307203172032720337203472035720367203772038720397204072041720427204372044720457204672047720487204972050720517205272053720547205572056720577205872059720607206172062720637206472065720667206772068720697207072071720727207372074720757207672077720787207972080720817208272083720847208572086720877208872089720907209172092720937209472095720967209772098720997210072101721027210372104721057210672107721087210972110721117211272113721147211572116721177211872119721207212172122721237212472125721267212772128721297213072131721327213372134721357213672137721387213972140721417214272143721447214572146721477214872149721507215172152721537215472155721567215772158721597216072161721627216372164721657216672167721687216972170721717217272173721747217572176721777217872179721807218172182721837218472185721867218772188721897219072191721927219372194721957219672197721987219972200722017220272203722047220572206722077220872209722107221172212722137221472215722167221772218722197222072221722227222372224722257222672227722287222972230722317223272233722347223572236722377223872239722407224172242722437224472245722467224772248722497225072251722527225372254722557225672257722587225972260722617226272263722647226572266722677226872269722707227172272722737227472275722767227772278722797228072281722827228372284722857228672287722887228972290722917229272293722947229572296722977229872299723007230172302723037230472305723067230772308723097231072311723127231372314723157231672317723187231972320723217232272323723247232572326723277232872329723307233172332723337233472335723367233772338723397234072341723427234372344723457234672347723487234972350723517235272353723547235572356723577235872359723607236172362723637236472365723667236772368723697237072371723727237372374723757237672377723787237972380723817238272383723847238572386723877238872389723907239172392723937239472395723967239772398723997240072401724027240372404724057240672407724087240972410724117241272413724147241572416724177241872419724207242172422724237242472425724267242772428724297243072431724327243372434724357243672437724387243972440724417244272443724447244572446724477244872449724507245172452724537245472455724567245772458724597246072461724627246372464724657246672467724687246972470724717247272473724747247572476724777247872479724807248172482724837248472485724867248772488724897249072491724927249372494724957249672497724987249972500725017250272503725047250572506725077250872509725107251172512725137251472515725167251772518725197252072521725227252372524725257252672527725287252972530725317253272533725347253572536725377253872539725407254172542725437254472545725467254772548725497255072551725527255372554725557255672557725587255972560725617256272563725647256572566725677256872569725707257172572725737257472575725767257772578725797258072581725827258372584725857258672587725887258972590725917259272593725947259572596725977259872599726007260172602726037260472605726067260772608726097261072611726127261372614726157261672617726187261972620726217262272623726247262572626726277262872629726307263172632726337263472635726367263772638726397264072641726427264372644726457264672647726487264972650726517265272653726547265572656726577265872659726607266172662726637266472665726667266772668726697267072671726727267372674726757267672677726787267972680726817268272683726847268572686726877268872689726907269172692726937269472695726967269772698726997270072701727027270372704727057270672707727087270972710727117271272713727147271572716727177271872719727207272172722727237272472725727267272772728727297273072731727327273372734727357273672737727387273972740727417274272743727447274572746727477274872749727507275172752727537275472755727567275772758727597276072761727627276372764727657276672767727687276972770727717277272773727747277572776727777277872779727807278172782727837278472785727867278772788727897279072791727927279372794727957279672797727987279972800728017280272803728047280572806728077280872809728107281172812728137281472815728167281772818728197282072821728227282372824728257282672827728287282972830728317283272833728347283572836728377283872839728407284172842728437284472845728467284772848728497285072851728527285372854728557285672857728587285972860728617286272863728647286572866728677286872869728707287172872728737287472875728767287772878728797288072881728827288372884728857288672887728887288972890728917289272893728947289572896728977289872899729007290172902729037290472905729067290772908729097291072911729127291372914729157291672917729187291972920729217292272923729247292572926729277292872929729307293172932729337293472935729367293772938729397294072941729427294372944729457294672947729487294972950729517295272953729547295572956729577295872959729607296172962729637296472965729667296772968729697297072971729727297372974729757297672977729787297972980729817298272983729847298572986729877298872989729907299172992729937299472995729967299772998729997300073001730027300373004730057300673007730087300973010730117301273013730147301573016730177301873019730207302173022730237302473025730267302773028730297303073031730327303373034730357303673037730387303973040730417304273043730447304573046730477304873049730507305173052730537305473055730567305773058730597306073061730627306373064730657306673067730687306973070730717307273073730747307573076730777307873079730807308173082730837308473085730867308773088730897309073091730927309373094730957309673097730987309973100731017310273103731047310573106731077310873109731107311173112731137311473115731167311773118731197312073121731227312373124731257312673127731287312973130731317313273133731347313573136731377313873139731407314173142731437314473145731467314773148731497315073151731527315373154731557315673157731587315973160731617316273163731647316573166731677316873169731707317173172731737317473175731767317773178731797318073181731827318373184731857318673187731887318973190731917319273193731947319573196731977319873199732007320173202732037320473205732067320773208732097321073211732127321373214732157321673217732187321973220732217322273223732247322573226732277322873229732307323173232732337323473235732367323773238732397324073241732427324373244732457324673247732487324973250732517325273253732547325573256732577325873259732607326173262732637326473265732667326773268732697327073271732727327373274732757327673277732787327973280732817328273283732847328573286732877328873289732907329173292732937329473295732967329773298732997330073301733027330373304733057330673307733087330973310733117331273313733147331573316733177331873319733207332173322733237332473325733267332773328733297333073331733327333373334733357333673337733387333973340733417334273343733447334573346733477334873349733507335173352733537335473355733567335773358733597336073361733627336373364733657336673367733687336973370733717337273373733747337573376733777337873379733807338173382733837338473385733867338773388733897339073391733927339373394733957339673397733987339973400734017340273403734047340573406734077340873409734107341173412734137341473415734167341773418734197342073421734227342373424734257342673427734287342973430734317343273433734347343573436734377343873439734407344173442734437344473445734467344773448734497345073451734527345373454734557345673457734587345973460734617346273463734647346573466734677346873469734707347173472734737347473475734767347773478734797348073481734827348373484734857348673487734887348973490734917349273493734947349573496734977349873499735007350173502735037350473505735067350773508735097351073511735127351373514735157351673517735187351973520735217352273523735247352573526735277352873529735307353173532735337353473535735367353773538735397354073541735427354373544735457354673547735487354973550735517355273553735547355573556735577355873559735607356173562735637356473565735667356773568735697357073571735727357373574735757357673577735787357973580735817358273583735847358573586735877358873589735907359173592735937359473595735967359773598735997360073601736027360373604736057360673607736087360973610736117361273613736147361573616736177361873619736207362173622736237362473625736267362773628736297363073631736327363373634736357363673637736387363973640736417364273643736447364573646736477364873649736507365173652736537365473655736567365773658736597366073661736627366373664736657366673667736687366973670736717367273673736747367573676736777367873679736807368173682736837368473685736867368773688736897369073691736927369373694736957369673697736987369973700737017370273703737047370573706737077370873709737107371173712737137371473715737167371773718737197372073721737227372373724737257372673727737287372973730737317373273733737347373573736737377373873739737407374173742737437374473745737467374773748737497375073751737527375373754737557375673757737587375973760737617376273763737647376573766737677376873769737707377173772737737377473775737767377773778737797378073781737827378373784737857378673787737887378973790737917379273793737947379573796737977379873799738007380173802738037380473805738067380773808738097381073811738127381373814738157381673817738187381973820738217382273823738247382573826738277382873829738307383173832738337383473835738367383773838738397384073841738427384373844738457384673847738487384973850738517385273853738547385573856738577385873859738607386173862738637386473865738667386773868738697387073871738727387373874738757387673877738787387973880738817388273883738847388573886738877388873889738907389173892738937389473895738967389773898738997390073901739027390373904739057390673907739087390973910739117391273913739147391573916739177391873919739207392173922739237392473925739267392773928739297393073931739327393373934739357393673937739387393973940739417394273943739447394573946739477394873949739507395173952739537395473955739567395773958739597396073961739627396373964739657396673967739687396973970739717397273973739747397573976739777397873979739807398173982739837398473985739867398773988739897399073991739927399373994739957399673997739987399974000740017400274003740047400574006740077400874009740107401174012740137401474015740167401774018740197402074021740227402374024740257402674027740287402974030740317403274033740347403574036740377403874039740407404174042740437404474045740467404774048740497405074051740527405374054740557405674057740587405974060740617406274063740647406574066740677406874069740707407174072740737407474075740767407774078740797408074081740827408374084740857408674087740887408974090740917409274093740947409574096740977409874099741007410174102741037410474105741067410774108741097411074111741127411374114741157411674117741187411974120741217412274123741247412574126741277412874129741307413174132741337413474135741367413774138741397414074141741427414374144741457414674147741487414974150741517415274153741547415574156741577415874159741607416174162741637416474165741667416774168741697417074171741727417374174741757417674177741787417974180741817418274183741847418574186741877418874189741907419174192741937419474195741967419774198741997420074201742027420374204742057420674207742087420974210742117421274213742147421574216742177421874219742207422174222742237422474225742267422774228742297423074231742327423374234742357423674237742387423974240742417424274243742447424574246742477424874249742507425174252742537425474255742567425774258742597426074261742627426374264742657426674267742687426974270742717427274273742747427574276742777427874279742807428174282742837428474285742867428774288742897429074291742927429374294742957429674297742987429974300743017430274303743047430574306743077430874309743107431174312743137431474315743167431774318743197432074321743227432374324743257432674327743287432974330743317433274333743347433574336743377433874339743407434174342743437434474345743467434774348743497435074351743527435374354743557435674357743587435974360743617436274363743647436574366743677436874369743707437174372743737437474375743767437774378743797438074381743827438374384743857438674387743887438974390743917439274393743947439574396743977439874399744007440174402744037440474405744067440774408744097441074411744127441374414744157441674417744187441974420744217442274423744247442574426744277442874429744307443174432744337443474435744367443774438744397444074441744427444374444744457444674447744487444974450744517445274453744547445574456744577445874459744607446174462744637446474465744667446774468744697447074471744727447374474744757447674477744787447974480744817448274483744847448574486744877448874489744907449174492744937449474495744967449774498744997450074501745027450374504745057450674507745087450974510745117451274513745147451574516745177451874519745207452174522745237452474525745267452774528745297453074531745327453374534745357453674537745387453974540745417454274543745447454574546745477454874549745507455174552745537455474555745567455774558745597456074561745627456374564745657456674567745687456974570745717457274573745747457574576745777457874579745807458174582745837458474585745867458774588745897459074591745927459374594745957459674597745987459974600746017460274603746047460574606746077460874609746107461174612746137461474615746167461774618746197462074621746227462374624746257462674627746287462974630746317463274633746347463574636746377463874639746407464174642746437464474645746467464774648746497465074651746527465374654746557465674657746587465974660746617466274663746647466574666746677466874669746707467174672746737467474675746767467774678746797468074681746827468374684746857468674687746887468974690746917469274693746947469574696746977469874699747007470174702747037470474705747067470774708747097471074711747127471374714747157471674717747187471974720747217472274723747247472574726747277472874729747307473174732747337473474735747367473774738747397474074741747427474374744747457474674747747487474974750747517475274753747547475574756747577475874759747607476174762747637476474765747667476774768747697477074771747727477374774747757477674777747787477974780747817478274783747847478574786747877478874789747907479174792747937479474795747967479774798747997480074801748027480374804748057480674807748087480974810748117481274813748147481574816748177481874819748207482174822748237482474825748267482774828748297483074831748327483374834748357483674837748387483974840748417484274843748447484574846748477484874849748507485174852748537485474855748567485774858748597486074861748627486374864748657486674867748687486974870748717487274873748747487574876748777487874879748807488174882748837488474885748867488774888748897489074891748927489374894748957489674897748987489974900749017490274903749047490574906749077490874909749107491174912749137491474915749167491774918749197492074921749227492374924749257492674927749287492974930749317493274933749347493574936749377493874939749407494174942749437494474945749467494774948749497495074951749527495374954749557495674957749587495974960749617496274963749647496574966749677496874969749707497174972749737497474975749767497774978749797498074981749827498374984749857498674987749887498974990749917499274993749947499574996749977499874999750007500175002750037500475005750067500775008750097501075011750127501375014750157501675017750187501975020750217502275023750247502575026750277502875029750307503175032750337503475035750367503775038750397504075041750427504375044750457504675047750487504975050750517505275053750547505575056750577505875059750607506175062750637506475065750667506775068750697507075071750727507375074750757507675077750787507975080750817508275083750847508575086750877508875089750907509175092750937509475095750967509775098750997510075101751027510375104751057510675107751087510975110751117511275113751147511575116751177511875119751207512175122751237512475125751267512775128751297513075131751327513375134751357513675137751387513975140751417514275143751447514575146751477514875149751507515175152751537515475155751567515775158751597516075161751627516375164751657516675167751687516975170751717517275173751747517575176751777517875179751807518175182751837518475185751867518775188751897519075191751927519375194751957519675197751987519975200752017520275203752047520575206752077520875209752107521175212752137521475215752167521775218752197522075221752227522375224752257522675227752287522975230752317523275233752347523575236752377523875239752407524175242752437524475245752467524775248752497525075251752527525375254752557525675257752587525975260752617526275263752647526575266752677526875269752707527175272752737527475275752767527775278752797528075281752827528375284752857528675287752887528975290752917529275293752947529575296752977529875299753007530175302753037530475305753067530775308753097531075311753127531375314753157531675317753187531975320753217532275323753247532575326753277532875329753307533175332753337533475335753367533775338753397534075341753427534375344753457534675347753487534975350753517535275353753547535575356753577535875359753607536175362753637536475365753667536775368753697537075371753727537375374753757537675377753787537975380753817538275383753847538575386753877538875389753907539175392753937539475395753967539775398753997540075401754027540375404754057540675407754087540975410754117541275413754147541575416754177541875419754207542175422754237542475425754267542775428754297543075431754327543375434754357543675437754387543975440754417544275443754447544575446754477544875449754507545175452754537545475455754567545775458754597546075461754627546375464754657546675467754687546975470754717547275473754747547575476754777547875479754807548175482754837548475485754867548775488754897549075491754927549375494754957549675497754987549975500755017550275503755047550575506755077550875509755107551175512755137551475515755167551775518755197552075521755227552375524755257552675527755287552975530755317553275533755347553575536755377553875539755407554175542755437554475545755467554775548755497555075551755527555375554755557555675557755587555975560755617556275563755647556575566755677556875569755707557175572755737557475575755767557775578755797558075581755827558375584755857558675587755887558975590755917559275593755947559575596755977559875599756007560175602756037560475605756067560775608756097561075611756127561375614756157561675617756187561975620756217562275623756247562575626756277562875629756307563175632756337563475635756367563775638756397564075641756427564375644756457564675647756487564975650756517565275653756547565575656756577565875659756607566175662756637566475665756667566775668756697567075671756727567375674756757567675677756787567975680756817568275683756847568575686756877568875689756907569175692756937569475695756967569775698756997570075701757027570375704757057570675707757087570975710757117571275713757147571575716757177571875719757207572175722757237572475725757267572775728757297573075731757327573375734757357573675737757387573975740757417574275743757447574575746757477574875749757507575175752757537575475755757567575775758757597576075761757627576375764757657576675767757687576975770757717577275773757747577575776757777577875779757807578175782757837578475785757867578775788757897579075791757927579375794757957579675797757987579975800758017580275803758047580575806758077580875809758107581175812758137581475815758167581775818758197582075821758227582375824758257582675827758287582975830758317583275833758347583575836758377583875839758407584175842758437584475845758467584775848758497585075851758527585375854758557585675857758587585975860758617586275863758647586575866758677586875869758707587175872758737587475875758767587775878758797588075881758827588375884758857588675887758887588975890758917589275893758947589575896758977589875899759007590175902759037590475905759067590775908759097591075911759127591375914759157591675917759187591975920759217592275923759247592575926759277592875929759307593175932759337593475935759367593775938759397594075941759427594375944759457594675947759487594975950759517595275953759547595575956759577595875959759607596175962759637596475965759667596775968759697597075971759727597375974759757597675977759787597975980759817598275983759847598575986759877598875989759907599175992759937599475995759967599775998759997600076001760027600376004760057600676007760087600976010760117601276013760147601576016760177601876019760207602176022760237602476025760267602776028760297603076031760327603376034760357603676037760387603976040760417604276043760447604576046760477604876049760507605176052760537605476055760567605776058760597606076061760627606376064760657606676067760687606976070760717607276073760747607576076760777607876079760807608176082760837608476085760867608776088760897609076091760927609376094760957609676097760987609976100761017610276103761047610576106761077610876109761107611176112761137611476115761167611776118761197612076121761227612376124761257612676127761287612976130761317613276133761347613576136761377613876139761407614176142761437614476145761467614776148761497615076151761527615376154761557615676157761587615976160761617616276163761647616576166761677616876169761707617176172761737617476175761767617776178761797618076181761827618376184761857618676187761887618976190761917619276193761947619576196761977619876199762007620176202762037620476205762067620776208762097621076211762127621376214762157621676217762187621976220762217622276223762247622576226762277622876229762307623176232762337623476235762367623776238762397624076241762427624376244762457624676247762487624976250762517625276253762547625576256762577625876259762607626176262762637626476265762667626776268762697627076271762727627376274762757627676277762787627976280762817628276283762847628576286762877628876289762907629176292762937629476295762967629776298762997630076301763027630376304763057630676307763087630976310763117631276313763147631576316763177631876319763207632176322763237632476325763267632776328763297633076331763327633376334763357633676337763387633976340763417634276343763447634576346763477634876349763507635176352763537635476355763567635776358763597636076361763627636376364763657636676367763687636976370763717637276373763747637576376763777637876379763807638176382763837638476385763867638776388763897639076391763927639376394763957639676397763987639976400764017640276403764047640576406764077640876409764107641176412764137641476415764167641776418764197642076421764227642376424764257642676427764287642976430764317643276433764347643576436764377643876439764407644176442764437644476445764467644776448764497645076451764527645376454764557645676457764587645976460764617646276463764647646576466764677646876469764707647176472764737647476475764767647776478764797648076481764827648376484764857648676487764887648976490764917649276493764947649576496764977649876499765007650176502765037650476505765067650776508765097651076511765127651376514765157651676517765187651976520765217652276523765247652576526765277652876529765307653176532765337653476535765367653776538765397654076541765427654376544765457654676547765487654976550765517655276553765547655576556765577655876559765607656176562765637656476565765667656776568765697657076571765727657376574765757657676577765787657976580765817658276583765847658576586765877658876589765907659176592765937659476595765967659776598765997660076601766027660376604766057660676607766087660976610766117661276613766147661576616766177661876619766207662176622766237662476625766267662776628766297663076631766327663376634766357663676637766387663976640766417664276643766447664576646766477664876649766507665176652766537665476655766567665776658766597666076661766627666376664766657666676667766687666976670766717667276673766747667576676766777667876679766807668176682766837668476685766867668776688766897669076691766927669376694766957669676697766987669976700767017670276703767047670576706767077670876709767107671176712767137671476715767167671776718767197672076721767227672376724767257672676727767287672976730767317673276733767347673576736767377673876739767407674176742767437674476745767467674776748767497675076751767527675376754767557675676757767587675976760767617676276763767647676576766767677676876769767707677176772767737677476775767767677776778767797678076781767827678376784767857678676787767887678976790767917679276793767947679576796767977679876799768007680176802768037680476805768067680776808768097681076811768127681376814768157681676817768187681976820768217682276823768247682576826768277682876829768307683176832768337683476835768367683776838768397684076841768427684376844768457684676847768487684976850768517685276853768547685576856768577685876859768607686176862768637686476865768667686776868768697687076871768727687376874768757687676877768787687976880768817688276883768847688576886768877688876889768907689176892768937689476895768967689776898768997690076901769027690376904769057690676907769087690976910769117691276913769147691576916769177691876919769207692176922769237692476925769267692776928769297693076931769327693376934769357693676937769387693976940769417694276943769447694576946769477694876949769507695176952769537695476955769567695776958769597696076961769627696376964769657696676967769687696976970769717697276973769747697576976769777697876979769807698176982769837698476985769867698776988769897699076991769927699376994769957699676997769987699977000770017700277003770047700577006770077700877009770107701177012770137701477015770167701777018770197702077021770227702377024770257702677027770287702977030770317703277033770347703577036770377703877039770407704177042770437704477045770467704777048770497705077051770527705377054770557705677057770587705977060770617706277063770647706577066770677706877069770707707177072770737707477075770767707777078770797708077081770827708377084770857708677087770887708977090770917709277093770947709577096770977709877099771007710177102771037710477105771067710777108771097711077111771127711377114771157711677117771187711977120771217712277123771247712577126771277712877129771307713177132771337713477135771367713777138771397714077141771427714377144771457714677147771487714977150771517715277153771547715577156771577715877159771607716177162771637716477165771667716777168771697717077171771727717377174771757717677177771787717977180771817718277183771847718577186771877718877189771907719177192771937719477195771967719777198771997720077201772027720377204772057720677207772087720977210772117721277213772147721577216772177721877219772207722177222772237722477225772267722777228772297723077231772327723377234772357723677237772387723977240772417724277243772447724577246772477724877249772507725177252772537725477255772567725777258772597726077261772627726377264772657726677267772687726977270772717727277273772747727577276772777727877279772807728177282772837728477285772867728777288772897729077291772927729377294772957729677297772987729977300773017730277303773047730577306773077730877309773107731177312773137731477315773167731777318773197732077321773227732377324773257732677327773287732977330773317733277333773347733577336773377733877339773407734177342773437734477345773467734777348773497735077351773527735377354773557735677357773587735977360773617736277363773647736577366773677736877369773707737177372773737737477375773767737777378773797738077381773827738377384773857738677387773887738977390773917739277393773947739577396773977739877399774007740177402774037740477405774067740777408774097741077411774127741377414774157741677417774187741977420774217742277423774247742577426774277742877429774307743177432774337743477435774367743777438774397744077441774427744377444774457744677447774487744977450774517745277453774547745577456774577745877459774607746177462774637746477465774667746777468774697747077471774727747377474774757747677477774787747977480774817748277483774847748577486774877748877489774907749177492774937749477495774967749777498774997750077501775027750377504775057750677507775087750977510775117751277513775147751577516775177751877519775207752177522775237752477525775267752777528775297753077531775327753377534775357753677537775387753977540775417754277543775447754577546775477754877549775507755177552775537755477555775567755777558775597756077561775627756377564775657756677567775687756977570775717757277573775747757577576775777757877579775807758177582775837758477585775867758777588775897759077591775927759377594775957759677597775987759977600776017760277603776047760577606776077760877609776107761177612776137761477615776167761777618776197762077621776227762377624776257762677627776287762977630776317763277633776347763577636776377763877639776407764177642776437764477645776467764777648776497765077651776527765377654776557765677657776587765977660776617766277663776647766577666776677766877669776707767177672776737767477675776767767777678776797768077681776827768377684776857768677687776887768977690776917769277693776947769577696776977769877699777007770177702777037770477705777067770777708777097771077711777127771377714777157771677717777187771977720777217772277723777247772577726777277772877729777307773177732777337773477735777367773777738777397774077741777427774377744777457774677747777487774977750777517775277753777547775577756777577775877759777607776177762777637776477765777667776777768777697777077771777727777377774777757777677777777787777977780777817778277783777847778577786777877778877789777907779177792777937779477795777967779777798777997780077801778027780377804778057780677807778087780977810778117781277813778147781577816778177781877819778207782177822778237782477825778267782777828778297783077831778327783377834778357783677837778387783977840778417784277843778447784577846778477784877849778507785177852778537785477855778567785777858778597786077861778627786377864778657786677867778687786977870778717787277873778747787577876778777787877879778807788177882778837788477885778867788777888778897789077891778927789377894778957789677897778987789977900779017790277903779047790577906779077790877909779107791177912779137791477915779167791777918779197792077921779227792377924779257792677927779287792977930779317793277933779347793577936779377793877939779407794177942779437794477945779467794777948779497795077951779527795377954779557795677957779587795977960779617796277963779647796577966779677796877969779707797177972779737797477975779767797777978779797798077981779827798377984779857798677987779887798977990779917799277993779947799577996779977799877999780007800178002780037800478005780067800778008780097801078011780127801378014780157801678017780187801978020780217802278023780247802578026780277802878029780307803178032780337803478035780367803778038780397804078041780427804378044780457804678047780487804978050780517805278053780547805578056780577805878059780607806178062780637806478065780667806778068780697807078071780727807378074780757807678077780787807978080780817808278083780847808578086780877808878089780907809178092780937809478095780967809778098780997810078101781027810378104781057810678107781087810978110781117811278113781147811578116781177811878119781207812178122781237812478125781267812778128781297813078131781327813378134781357813678137781387813978140781417814278143781447814578146781477814878149781507815178152781537815478155781567815778158781597816078161781627816378164781657816678167781687816978170781717817278173781747817578176781777817878179781807818178182781837818478185781867818778188781897819078191781927819378194781957819678197781987819978200782017820278203782047820578206782077820878209782107821178212782137821478215782167821778218782197822078221782227822378224782257822678227782287822978230782317823278233782347823578236782377823878239782407824178242782437824478245782467824778248782497825078251782527825378254782557825678257782587825978260782617826278263782647826578266782677826878269782707827178272782737827478275782767827778278782797828078281782827828378284782857828678287782887828978290782917829278293782947829578296782977829878299783007830178302783037830478305783067830778308783097831078311783127831378314783157831678317783187831978320783217832278323783247832578326783277832878329783307833178332783337833478335783367833778338783397834078341783427834378344783457834678347783487834978350783517835278353783547835578356783577835878359783607836178362783637836478365783667836778368783697837078371783727837378374783757837678377783787837978380783817838278383783847838578386783877838878389783907839178392783937839478395783967839778398783997840078401784027840378404784057840678407784087840978410784117841278413784147841578416784177841878419784207842178422784237842478425784267842778428784297843078431784327843378434784357843678437784387843978440784417844278443784447844578446784477844878449784507845178452784537845478455784567845778458784597846078461784627846378464784657846678467784687846978470784717847278473784747847578476784777847878479784807848178482784837848478485784867848778488784897849078491784927849378494784957849678497784987849978500785017850278503785047850578506785077850878509785107851178512785137851478515785167851778518785197852078521785227852378524785257852678527785287852978530785317853278533785347853578536785377853878539785407854178542785437854478545785467854778548785497855078551785527855378554785557855678557785587855978560785617856278563785647856578566785677856878569785707857178572785737857478575785767857778578785797858078581785827858378584785857858678587785887858978590785917859278593785947859578596785977859878599786007860178602786037860478605786067860778608786097861078611786127861378614786157861678617786187861978620786217862278623786247862578626786277862878629786307863178632786337863478635786367863778638786397864078641786427864378644786457864678647786487864978650786517865278653786547865578656786577865878659786607866178662786637866478665786667866778668786697867078671786727867378674786757867678677786787867978680786817868278683786847868578686786877868878689786907869178692786937869478695786967869778698786997870078701787027870378704787057870678707787087870978710787117871278713787147871578716787177871878719787207872178722787237872478725787267872778728787297873078731787327873378734787357873678737787387873978740787417874278743787447874578746787477874878749787507875178752787537875478755787567875778758787597876078761787627876378764787657876678767787687876978770787717877278773787747877578776787777877878779787807878178782787837878478785787867878778788787897879078791787927879378794787957879678797787987879978800788017880278803788047880578806788077880878809788107881178812788137881478815788167881778818788197882078821788227882378824788257882678827788287882978830788317883278833788347883578836788377883878839788407884178842788437884478845788467884778848788497885078851788527885378854788557885678857788587885978860788617886278863788647886578866788677886878869788707887178872788737887478875788767887778878788797888078881788827888378884788857888678887788887888978890788917889278893788947889578896788977889878899789007890178902789037890478905789067890778908789097891078911789127891378914789157891678917789187891978920789217892278923789247892578926789277892878929789307893178932789337893478935789367893778938789397894078941789427894378944789457894678947789487894978950789517895278953789547895578956789577895878959789607896178962789637896478965789667896778968789697897078971789727897378974789757897678977789787897978980789817898278983789847898578986789877898878989789907899178992789937899478995789967899778998789997900079001790027900379004790057900679007790087900979010790117901279013790147901579016790177901879019790207902179022790237902479025790267902779028790297903079031790327903379034790357903679037790387903979040790417904279043790447904579046790477904879049790507905179052790537905479055790567905779058790597906079061790627906379064790657906679067790687906979070790717907279073790747907579076790777907879079790807908179082790837908479085790867908779088790897909079091790927909379094790957909679097790987909979100791017910279103791047910579106791077910879109791107911179112791137911479115791167911779118791197912079121791227912379124791257912679127791287912979130791317913279133791347913579136791377913879139791407914179142791437914479145791467914779148791497915079151791527915379154791557915679157791587915979160791617916279163791647916579166791677916879169791707917179172791737917479175791767917779178791797918079181791827918379184791857918679187791887918979190791917919279193791947919579196791977919879199792007920179202792037920479205792067920779208792097921079211792127921379214792157921679217792187921979220792217922279223792247922579226792277922879229792307923179232792337923479235792367923779238792397924079241792427924379244792457924679247792487924979250792517925279253792547925579256792577925879259792607926179262792637926479265792667926779268792697927079271792727927379274792757927679277792787927979280792817928279283792847928579286792877928879289792907929179292792937929479295792967929779298792997930079301793027930379304793057930679307793087930979310793117931279313793147931579316793177931879319793207932179322793237932479325793267932779328793297933079331793327933379334793357933679337793387933979340793417934279343793447934579346793477934879349793507935179352793537935479355793567935779358793597936079361793627936379364793657936679367793687936979370793717937279373793747937579376793777937879379793807938179382793837938479385793867938779388793897939079391793927939379394793957939679397793987939979400794017940279403794047940579406794077940879409794107941179412794137941479415794167941779418794197942079421794227942379424794257942679427794287942979430794317943279433794347943579436794377943879439794407944179442794437944479445794467944779448794497945079451794527945379454794557945679457794587945979460794617946279463794647946579466794677946879469794707947179472794737947479475794767947779478794797948079481794827948379484794857948679487794887948979490794917949279493794947949579496794977949879499795007950179502795037950479505795067950779508795097951079511795127951379514795157951679517795187951979520795217952279523795247952579526795277952879529795307953179532795337953479535795367953779538795397954079541795427954379544795457954679547795487954979550795517955279553795547955579556795577955879559795607956179562795637956479565795667956779568795697957079571795727957379574795757957679577795787957979580795817958279583795847958579586795877958879589795907959179592795937959479595795967959779598795997960079601796027960379604796057960679607796087960979610796117961279613796147961579616796177961879619796207962179622796237962479625796267962779628796297963079631796327963379634796357963679637796387963979640796417964279643796447964579646796477964879649796507965179652796537965479655796567965779658796597966079661796627966379664796657966679667796687966979670796717967279673796747967579676796777967879679796807968179682796837968479685796867968779688796897969079691796927969379694796957969679697796987969979700797017970279703797047970579706797077970879709797107971179712797137971479715797167971779718797197972079721797227972379724797257972679727797287972979730797317973279733797347973579736797377973879739797407974179742797437974479745797467974779748797497975079751797527975379754797557975679757797587975979760797617976279763797647976579766797677976879769797707977179772797737977479775797767977779778797797978079781797827978379784797857978679787797887978979790797917979279793797947979579796797977979879799798007980179802798037980479805798067980779808798097981079811798127981379814798157981679817798187981979820798217982279823798247982579826798277982879829798307983179832798337983479835798367983779838798397984079841798427984379844798457984679847798487984979850798517985279853798547985579856798577985879859798607986179862798637986479865798667986779868798697987079871798727987379874798757987679877798787987979880798817988279883798847988579886798877988879889798907989179892798937989479895798967989779898798997990079901799027990379904799057990679907799087990979910799117991279913799147991579916799177991879919799207992179922799237992479925799267992779928799297993079931799327993379934799357993679937799387993979940799417994279943799447994579946799477994879949799507995179952799537995479955799567995779958799597996079961799627996379964799657996679967799687996979970799717997279973799747997579976799777997879979799807998179982799837998479985799867998779988799897999079991799927999379994799957999679997799987999980000800018000280003800048000580006800078000880009800108001180012800138001480015800168001780018800198002080021800228002380024800258002680027800288002980030800318003280033800348003580036800378003880039800408004180042800438004480045800468004780048800498005080051800528005380054800558005680057800588005980060800618006280063800648006580066800678006880069800708007180072800738007480075800768007780078800798008080081800828008380084800858008680087800888008980090800918009280093800948009580096800978009880099801008010180102801038010480105801068010780108801098011080111801128011380114801158011680117801188011980120801218012280123801248012580126801278012880129801308013180132801338013480135801368013780138801398014080141801428014380144801458014680147801488014980150801518015280153801548015580156801578015880159801608016180162801638016480165801668016780168801698017080171801728017380174801758017680177801788017980180801818018280183801848018580186801878018880189801908019180192801938019480195801968019780198801998020080201802028020380204802058020680207802088020980210802118021280213802148021580216802178021880219802208022180222802238022480225802268022780228802298023080231802328023380234802358023680237802388023980240802418024280243802448024580246802478024880249802508025180252802538025480255802568025780258802598026080261802628026380264802658026680267802688026980270802718027280273802748027580276802778027880279802808028180282802838028480285802868028780288802898029080291802928029380294802958029680297802988029980300803018030280303803048030580306803078030880309803108031180312803138031480315803168031780318803198032080321803228032380324803258032680327803288032980330803318033280333803348033580336803378033880339803408034180342803438034480345803468034780348803498035080351803528035380354803558035680357803588035980360803618036280363803648036580366803678036880369803708037180372803738037480375803768037780378803798038080381803828038380384803858038680387803888038980390803918039280393803948039580396803978039880399804008040180402804038040480405804068040780408804098041080411804128041380414804158041680417804188041980420804218042280423804248042580426804278042880429804308043180432804338043480435804368043780438804398044080441804428044380444804458044680447804488044980450804518045280453804548045580456804578045880459804608046180462804638046480465804668046780468804698047080471804728047380474804758047680477804788047980480804818048280483804848048580486804878048880489804908049180492804938049480495804968049780498804998050080501805028050380504805058050680507805088050980510805118051280513805148051580516805178051880519805208052180522805238052480525805268052780528805298053080531805328053380534805358053680537805388053980540805418054280543805448054580546805478054880549805508055180552805538055480555805568055780558805598056080561805628056380564805658056680567805688056980570805718057280573805748057580576805778057880579805808058180582805838058480585805868058780588805898059080591805928059380594805958059680597805988059980600806018060280603806048060580606806078060880609806108061180612806138061480615806168061780618806198062080621806228062380624806258062680627806288062980630806318063280633806348063580636806378063880639806408064180642806438064480645806468064780648806498065080651806528065380654806558065680657806588065980660806618066280663806648066580666806678066880669806708067180672806738067480675806768067780678806798068080681806828068380684806858068680687806888068980690806918069280693806948069580696806978069880699807008070180702807038070480705807068070780708807098071080711807128071380714807158071680717807188071980720807218072280723807248072580726807278072880729807308073180732807338073480735807368073780738807398074080741807428074380744807458074680747807488074980750807518075280753807548075580756807578075880759807608076180762807638076480765807668076780768807698077080771807728077380774807758077680777807788077980780807818078280783807848078580786807878078880789807908079180792807938079480795807968079780798807998080080801808028080380804808058080680807808088080980810808118081280813808148081580816808178081880819808208082180822808238082480825808268082780828808298083080831808328083380834808358083680837808388083980840808418084280843808448084580846808478084880849808508085180852808538085480855808568085780858808598086080861808628086380864808658086680867808688086980870808718087280873808748087580876808778087880879808808088180882808838088480885808868088780888808898089080891808928089380894808958089680897808988089980900809018090280903809048090580906809078090880909809108091180912809138091480915809168091780918809198092080921809228092380924809258092680927809288092980930809318093280933809348093580936809378093880939809408094180942809438094480945809468094780948809498095080951809528095380954809558095680957809588095980960809618096280963809648096580966809678096880969809708097180972809738097480975809768097780978809798098080981809828098380984809858098680987809888098980990809918099280993809948099580996809978099880999810008100181002810038100481005810068100781008810098101081011810128101381014810158101681017810188101981020810218102281023810248102581026810278102881029810308103181032810338103481035810368103781038810398104081041810428104381044810458104681047810488104981050810518105281053810548105581056810578105881059810608106181062810638106481065810668106781068810698107081071810728107381074810758107681077810788107981080810818108281083810848108581086810878108881089810908109181092810938109481095810968109781098810998110081101811028110381104811058110681107811088110981110811118111281113811148111581116811178111881119811208112181122811238112481125811268112781128811298113081131811328113381134811358113681137811388113981140811418114281143811448114581146811478114881149811508115181152811538115481155811568115781158811598116081161811628116381164811658116681167811688116981170811718117281173811748117581176811778117881179811808118181182811838118481185811868118781188811898119081191811928119381194811958119681197811988119981200812018120281203812048120581206812078120881209812108121181212812138121481215812168121781218812198122081221812228122381224812258122681227812288122981230812318123281233812348123581236812378123881239812408124181242812438124481245812468124781248812498125081251812528125381254812558125681257812588125981260812618126281263812648126581266812678126881269812708127181272812738127481275812768127781278812798128081281812828128381284812858128681287812888128981290812918129281293812948129581296812978129881299813008130181302813038130481305813068130781308813098131081311813128131381314813158131681317813188131981320813218132281323813248132581326813278132881329813308133181332813338133481335813368133781338813398134081341813428134381344813458134681347813488134981350813518135281353813548135581356813578135881359813608136181362813638136481365813668136781368813698137081371813728137381374813758137681377813788137981380813818138281383813848138581386813878138881389813908139181392813938139481395813968139781398813998140081401814028140381404814058140681407814088140981410814118141281413814148141581416814178141881419814208142181422814238142481425814268142781428814298143081431814328143381434814358143681437814388143981440814418144281443814448144581446814478144881449814508145181452814538145481455814568145781458814598146081461814628146381464814658146681467814688146981470814718147281473814748147581476814778147881479814808148181482814838148481485814868148781488814898149081491814928149381494814958149681497814988149981500815018150281503815048150581506815078150881509815108151181512815138151481515815168151781518815198152081521815228152381524815258152681527815288152981530815318153281533815348153581536815378153881539815408154181542815438154481545815468154781548815498155081551815528155381554815558155681557815588155981560815618156281563815648156581566815678156881569815708157181572815738157481575815768157781578815798158081581815828158381584815858158681587815888158981590815918159281593815948159581596815978159881599816008160181602816038160481605816068160781608816098161081611816128161381614816158161681617816188161981620816218162281623816248162581626816278162881629816308163181632816338163481635816368163781638816398164081641816428164381644816458164681647816488164981650816518165281653816548165581656816578165881659816608166181662816638166481665816668166781668816698167081671816728167381674816758167681677816788167981680816818168281683816848168581686816878168881689816908169181692816938169481695816968169781698816998170081701817028170381704817058170681707817088170981710817118171281713817148171581716817178171881719817208172181722817238172481725817268172781728817298173081731817328173381734817358173681737817388173981740817418174281743817448174581746817478174881749817508175181752817538175481755817568175781758817598176081761817628176381764817658176681767817688176981770817718177281773817748177581776817778177881779817808178181782817838178481785817868178781788817898179081791817928179381794817958179681797817988179981800818018180281803818048180581806818078180881809818108181181812818138181481815818168181781818818198182081821818228182381824818258182681827818288182981830818318183281833818348183581836818378183881839818408184181842818438184481845818468184781848818498185081851818528185381854818558185681857818588185981860818618186281863818648186581866818678186881869818708187181872818738187481875818768187781878818798188081881818828188381884818858188681887818888188981890818918189281893818948189581896818978189881899819008190181902819038190481905819068190781908819098191081911819128191381914819158191681917819188191981920819218192281923819248192581926819278192881929819308193181932819338193481935819368193781938819398194081941819428194381944819458194681947819488194981950819518195281953819548195581956819578195881959819608196181962819638196481965819668196781968819698197081971819728197381974819758197681977819788197981980819818198281983819848198581986819878198881989819908199181992819938199481995819968199781998819998200082001820028200382004820058200682007820088200982010820118201282013820148201582016820178201882019820208202182022820238202482025820268202782028820298203082031820328203382034820358203682037820388203982040820418204282043820448204582046820478204882049820508205182052820538205482055820568205782058820598206082061820628206382064820658206682067820688206982070820718207282073820748207582076820778207882079820808208182082820838208482085820868208782088820898209082091820928209382094820958209682097820988209982100821018210282103821048210582106821078210882109821108211182112821138211482115821168211782118821198212082121821228212382124821258212682127821288212982130821318213282133821348213582136821378213882139821408214182142821438214482145821468214782148821498215082151821528215382154821558215682157821588215982160821618216282163821648216582166821678216882169821708217182172821738217482175821768217782178821798218082181821828218382184821858218682187821888218982190821918219282193821948219582196821978219882199822008220182202822038220482205822068220782208822098221082211822128221382214822158221682217822188221982220822218222282223822248222582226822278222882229822308223182232822338223482235822368223782238822398224082241822428224382244822458224682247822488224982250822518225282253822548225582256822578225882259822608226182262822638226482265822668226782268822698227082271822728227382274822758227682277822788227982280822818228282283822848228582286822878228882289822908229182292822938229482295822968229782298822998230082301823028230382304823058230682307823088230982310823118231282313823148231582316823178231882319823208232182322823238232482325823268232782328823298233082331823328233382334823358233682337823388233982340823418234282343823448234582346823478234882349823508235182352823538235482355823568235782358823598236082361823628236382364823658236682367823688236982370823718237282373823748237582376823778237882379823808238182382823838238482385823868238782388823898239082391823928239382394823958239682397823988239982400824018240282403824048240582406824078240882409824108241182412824138241482415824168241782418824198242082421824228242382424824258242682427824288242982430824318243282433824348243582436824378243882439824408244182442824438244482445824468244782448824498245082451824528245382454824558245682457824588245982460824618246282463824648246582466824678246882469824708247182472824738247482475824768247782478824798248082481824828248382484824858248682487824888248982490824918249282493824948249582496824978249882499825008250182502825038250482505825068250782508825098251082511825128251382514825158251682517825188251982520825218252282523825248252582526825278252882529825308253182532825338253482535825368253782538825398254082541825428254382544825458254682547825488254982550825518255282553825548255582556825578255882559825608256182562825638256482565825668256782568825698257082571825728257382574825758257682577825788257982580825818258282583825848258582586825878258882589825908259182592825938259482595825968259782598825998260082601826028260382604826058260682607826088260982610826118261282613826148261582616826178261882619826208262182622826238262482625826268262782628826298263082631826328263382634826358263682637826388263982640826418264282643826448264582646826478264882649826508265182652826538265482655826568265782658826598266082661826628266382664826658266682667826688266982670826718267282673826748267582676826778267882679826808268182682826838268482685826868268782688826898269082691826928269382694826958269682697826988269982700827018270282703827048270582706827078270882709827108271182712827138271482715827168271782718827198272082721827228272382724827258272682727827288272982730827318273282733827348273582736827378273882739827408274182742827438274482745827468274782748827498275082751827528275382754827558275682757827588275982760827618276282763827648276582766827678276882769827708277182772827738277482775827768277782778827798278082781827828278382784827858278682787827888278982790827918279282793827948279582796827978279882799828008280182802828038280482805828068280782808828098281082811828128281382814828158281682817828188281982820828218282282823828248282582826828278282882829828308283182832828338283482835828368283782838828398284082841828428284382844828458284682847828488284982850828518285282853828548285582856828578285882859828608286182862828638286482865828668286782868828698287082871828728287382874828758287682877828788287982880828818288282883828848288582886828878288882889828908289182892828938289482895828968289782898828998290082901829028290382904829058290682907829088290982910829118291282913829148291582916829178291882919829208292182922829238292482925829268292782928829298293082931829328293382934829358293682937829388293982940829418294282943829448294582946829478294882949829508295182952829538295482955829568295782958829598296082961829628296382964829658296682967829688296982970829718297282973829748297582976829778297882979829808298182982829838298482985829868298782988829898299082991829928299382994829958299682997829988299983000830018300283003830048300583006830078300883009830108301183012830138301483015830168301783018830198302083021830228302383024830258302683027830288302983030830318303283033830348303583036830378303883039830408304183042830438304483045830468304783048830498305083051830528305383054830558305683057830588305983060830618306283063830648306583066830678306883069830708307183072830738307483075830768307783078830798308083081830828308383084830858308683087830888308983090830918309283093830948309583096830978309883099831008310183102831038310483105831068310783108831098311083111831128311383114831158311683117831188311983120831218312283123831248312583126831278312883129831308313183132831338313483135831368313783138831398314083141831428314383144831458314683147831488314983150831518315283153831548315583156831578315883159831608316183162831638316483165831668316783168831698317083171831728317383174831758317683177831788317983180831818318283183831848318583186831878318883189831908319183192831938319483195831968319783198831998320083201832028320383204832058320683207832088320983210832118321283213832148321583216832178321883219832208322183222832238322483225832268322783228832298323083231832328323383234832358323683237832388323983240832418324283243832448324583246832478324883249832508325183252832538325483255832568325783258832598326083261832628326383264832658326683267832688326983270832718327283273832748327583276832778327883279832808328183282832838328483285832868328783288832898329083291832928329383294832958329683297832988329983300833018330283303833048330583306833078330883309833108331183312833138331483315833168331783318833198332083321833228332383324833258332683327833288332983330833318333283333833348333583336833378333883339833408334183342833438334483345833468334783348833498335083351833528335383354833558335683357833588335983360833618336283363833648336583366833678336883369833708337183372833738337483375833768337783378833798338083381833828338383384833858338683387833888338983390833918339283393833948339583396833978339883399834008340183402834038340483405834068340783408834098341083411834128341383414834158341683417834188341983420834218342283423834248342583426834278342883429834308343183432834338343483435834368343783438834398344083441834428344383444834458344683447834488344983450834518345283453834548345583456834578345883459834608346183462834638346483465834668346783468834698347083471834728347383474834758347683477834788347983480834818348283483834848348583486834878348883489834908349183492834938349483495834968349783498834998350083501835028350383504835058350683507835088350983510835118351283513835148351583516835178351883519835208352183522835238352483525835268352783528835298353083531835328353383534835358353683537835388353983540835418354283543835448354583546835478354883549835508355183552835538355483555835568355783558835598356083561835628356383564835658356683567835688356983570835718357283573835748357583576835778357883579835808358183582835838358483585835868358783588835898359083591835928359383594835958359683597835988359983600836018360283603836048360583606836078360883609836108361183612836138361483615836168361783618836198362083621836228362383624836258362683627836288362983630836318363283633836348363583636836378363883639836408364183642836438364483645836468364783648836498365083651836528365383654836558365683657836588365983660836618366283663836648366583666836678366883669836708367183672836738367483675836768367783678836798368083681836828368383684836858368683687836888368983690836918369283693836948369583696836978369883699837008370183702837038370483705837068370783708837098371083711837128371383714837158371683717837188371983720837218372283723837248372583726837278372883729837308373183732837338373483735837368373783738837398374083741837428374383744837458374683747837488374983750837518375283753837548375583756837578375883759837608376183762837638376483765837668376783768837698377083771837728377383774837758377683777837788377983780837818378283783837848378583786837878378883789837908379183792837938379483795837968379783798837998380083801838028380383804838058380683807838088380983810838118381283813838148381583816838178381883819838208382183822838238382483825838268382783828838298383083831838328383383834838358383683837838388383983840838418384283843838448384583846838478384883849838508385183852838538385483855838568385783858838598386083861838628386383864838658386683867838688386983870838718387283873838748387583876838778387883879838808388183882838838388483885838868388783888838898389083891838928389383894838958389683897838988389983900839018390283903839048390583906839078390883909839108391183912839138391483915839168391783918839198392083921839228392383924839258392683927839288392983930839318393283933839348393583936839378393883939839408394183942839438394483945839468394783948839498395083951839528395383954839558395683957839588395983960839618396283963839648396583966839678396883969839708397183972839738397483975839768397783978839798398083981839828398383984839858398683987839888398983990839918399283993839948399583996839978399883999840008400184002840038400484005840068400784008840098401084011840128401384014840158401684017840188401984020840218402284023840248402584026840278402884029840308403184032840338403484035840368403784038840398404084041840428404384044840458404684047840488404984050840518405284053840548405584056840578405884059840608406184062840638406484065840668406784068840698407084071840728407384074840758407684077840788407984080840818408284083840848408584086840878408884089840908409184092840938409484095840968409784098840998410084101841028410384104841058410684107841088410984110841118411284113841148411584116841178411884119841208412184122841238412484125841268412784128841298413084131841328413384134841358413684137841388413984140841418414284143841448414584146841478414884149841508415184152841538415484155841568415784158841598416084161841628416384164841658416684167841688416984170841718417284173841748417584176841778417884179841808418184182841838418484185841868418784188841898419084191841928419384194841958419684197841988419984200842018420284203842048420584206842078420884209842108421184212842138421484215842168421784218842198422084221842228422384224842258422684227842288422984230842318423284233842348423584236842378423884239842408424184242842438424484245842468424784248842498425084251842528425384254842558425684257842588425984260842618426284263842648426584266842678426884269842708427184272842738427484275842768427784278842798428084281842828428384284842858428684287842888428984290842918429284293842948429584296842978429884299843008430184302843038430484305843068430784308843098431084311843128431384314843158431684317843188431984320843218432284323843248432584326843278432884329843308433184332843338433484335843368433784338843398434084341843428434384344843458434684347843488434984350843518435284353843548435584356843578435884359843608436184362843638436484365843668436784368843698437084371843728437384374843758437684377843788437984380843818438284383843848438584386843878438884389843908439184392843938439484395843968439784398843998440084401844028440384404844058440684407844088440984410844118441284413844148441584416844178441884419844208442184422844238442484425844268442784428844298443084431844328443384434844358443684437844388443984440844418444284443844448444584446844478444884449844508445184452844538445484455844568445784458844598446084461844628446384464844658446684467844688446984470844718447284473844748447584476844778447884479844808448184482844838448484485844868448784488844898449084491844928449384494844958449684497844988449984500845018450284503845048450584506845078450884509845108451184512845138451484515845168451784518845198452084521845228452384524845258452684527845288452984530845318453284533845348453584536845378453884539845408454184542845438454484545845468454784548845498455084551845528455384554845558455684557845588455984560845618456284563845648456584566845678456884569845708457184572845738457484575845768457784578845798458084581845828458384584845858458684587845888458984590845918459284593845948459584596845978459884599846008460184602846038460484605846068460784608846098461084611846128461384614846158461684617846188461984620846218462284623846248462584626846278462884629846308463184632846338463484635846368463784638846398464084641846428464384644846458464684647846488464984650846518465284653846548465584656846578465884659846608466184662846638466484665846668466784668846698467084671846728467384674846758467684677846788467984680846818468284683846848468584686846878468884689846908469184692846938469484695846968469784698846998470084701847028470384704847058470684707847088470984710847118471284713847148471584716847178471884719847208472184722847238472484725847268472784728847298473084731847328473384734847358473684737847388473984740847418474284743847448474584746847478474884749847508475184752847538475484755847568475784758847598476084761847628476384764847658476684767847688476984770847718477284773847748477584776847778477884779847808478184782847838478484785847868478784788847898479084791847928479384794847958479684797847988479984800848018480284803848048480584806848078480884809848108481184812848138481484815848168481784818848198482084821848228482384824848258482684827848288482984830848318483284833848348483584836848378483884839848408484184842848438484484845848468484784848848498485084851848528485384854848558485684857848588485984860848618486284863848648486584866848678486884869848708487184872848738487484875848768487784878848798488084881848828488384884848858488684887848888488984890848918489284893848948489584896848978489884899849008490184902849038490484905849068490784908849098491084911849128491384914849158491684917849188491984920849218492284923849248492584926849278492884929849308493184932849338493484935849368493784938849398494084941849428494384944849458494684947849488494984950849518495284953849548495584956849578495884959849608496184962849638496484965849668496784968849698497084971849728497384974849758497684977849788497984980849818498284983849848498584986849878498884989849908499184992849938499484995849968499784998849998500085001850028500385004850058500685007850088500985010850118501285013850148501585016850178501885019850208502185022850238502485025850268502785028850298503085031850328503385034850358503685037850388503985040850418504285043850448504585046850478504885049850508505185052850538505485055850568505785058850598506085061850628506385064850658506685067850688506985070850718507285073850748507585076850778507885079850808508185082850838508485085850868508785088850898509085091850928509385094850958509685097850988509985100851018510285103851048510585106851078510885109851108511185112851138511485115851168511785118851198512085121851228512385124851258512685127851288512985130851318513285133851348513585136851378513885139851408514185142851438514485145851468514785148851498515085151851528515385154851558515685157851588515985160851618516285163851648516585166851678516885169851708517185172851738517485175851768517785178851798518085181851828518385184851858518685187851888518985190851918519285193851948519585196851978519885199852008520185202852038520485205852068520785208852098521085211852128521385214852158521685217852188521985220852218522285223852248522585226852278522885229852308523185232852338523485235852368523785238852398524085241852428524385244852458524685247852488524985250852518525285253852548525585256852578525885259852608526185262852638526485265852668526785268852698527085271852728527385274852758527685277852788527985280852818528285283852848528585286852878528885289852908529185292852938529485295852968529785298852998530085301853028530385304853058530685307853088530985310853118531285313853148531585316853178531885319853208532185322853238532485325853268532785328853298533085331853328533385334853358533685337853388533985340853418534285343853448534585346853478534885349853508535185352853538535485355853568535785358853598536085361853628536385364853658536685367853688536985370853718537285373853748537585376853778537885379853808538185382853838538485385853868538785388853898539085391853928539385394853958539685397853988539985400854018540285403854048540585406854078540885409854108541185412854138541485415854168541785418854198542085421854228542385424854258542685427854288542985430854318543285433854348543585436854378543885439854408544185442854438544485445854468544785448854498545085451854528545385454854558545685457854588545985460854618546285463854648546585466854678546885469854708547185472854738547485475854768547785478854798548085481854828548385484854858548685487854888548985490854918549285493854948549585496854978549885499855008550185502855038550485505855068550785508855098551085511855128551385514855158551685517855188551985520855218552285523855248552585526855278552885529855308553185532855338553485535855368553785538855398554085541855428554385544855458554685547855488554985550855518555285553855548555585556855578555885559855608556185562855638556485565855668556785568855698557085571855728557385574855758557685577855788557985580855818558285583855848558585586855878558885589855908559185592855938559485595855968559785598855998560085601856028560385604856058560685607856088560985610856118561285613856148561585616856178561885619856208562185622856238562485625856268562785628856298563085631856328563385634856358563685637856388563985640856418564285643856448564585646856478564885649856508565185652856538565485655856568565785658856598566085661856628566385664856658566685667856688566985670856718567285673856748567585676856778567885679856808568185682856838568485685856868568785688856898569085691856928569385694856958569685697856988569985700857018570285703857048570585706857078570885709857108571185712857138571485715857168571785718857198572085721857228572385724857258572685727857288572985730857318573285733857348573585736857378573885739857408574185742857438574485745857468574785748857498575085751857528575385754857558575685757857588575985760857618576285763857648576585766857678576885769857708577185772857738577485775857768577785778857798578085781857828578385784857858578685787857888578985790857918579285793857948579585796857978579885799858008580185802858038580485805858068580785808858098581085811858128581385814858158581685817858188581985820858218582285823858248582585826858278582885829858308583185832858338583485835858368583785838858398584085841858428584385844858458584685847858488584985850858518585285853858548585585856858578585885859858608586185862858638586485865858668586785868858698587085871858728587385874858758587685877858788587985880858818588285883858848588585886858878588885889858908589185892858938589485895858968589785898858998590085901859028590385904859058590685907859088590985910859118591285913859148591585916859178591885919859208592185922859238592485925859268592785928859298593085931859328593385934859358593685937859388593985940859418594285943859448594585946859478594885949859508595185952859538595485955859568595785958859598596085961859628596385964859658596685967859688596985970859718597285973859748597585976859778597885979859808598185982859838598485985859868598785988859898599085991859928599385994859958599685997859988599986000860018600286003860048600586006860078600886009860108601186012860138601486015860168601786018860198602086021860228602386024860258602686027860288602986030860318603286033860348603586036860378603886039860408604186042860438604486045860468604786048860498605086051860528605386054860558605686057860588605986060860618606286063860648606586066860678606886069860708607186072860738607486075860768607786078860798608086081860828608386084860858608686087860888608986090860918609286093860948609586096860978609886099861008610186102861038610486105861068610786108861098611086111861128611386114861158611686117861188611986120861218612286123861248612586126861278612886129861308613186132861338613486135861368613786138861398614086141861428614386144861458614686147861488614986150861518615286153861548615586156861578615886159861608616186162861638616486165861668616786168861698617086171861728617386174861758617686177861788617986180861818618286183861848618586186861878618886189861908619186192861938619486195861968619786198861998620086201862028620386204862058620686207862088620986210862118621286213862148621586216862178621886219862208622186222862238622486225862268622786228862298623086231862328623386234862358623686237862388623986240862418624286243862448624586246862478624886249862508625186252862538625486255862568625786258862598626086261862628626386264862658626686267862688626986270862718627286273862748627586276862778627886279862808628186282862838628486285862868628786288862898629086291862928629386294862958629686297862988629986300863018630286303863048630586306863078630886309863108631186312863138631486315863168631786318863198632086321863228632386324863258632686327863288632986330863318633286333863348633586336863378633886339863408634186342863438634486345863468634786348863498635086351863528635386354863558635686357863588635986360863618636286363863648636586366863678636886369863708637186372863738637486375863768637786378863798638086381863828638386384863858638686387863888638986390863918639286393863948639586396863978639886399864008640186402864038640486405864068640786408864098641086411864128641386414864158641686417864188641986420864218642286423864248642586426864278642886429864308643186432864338643486435864368643786438864398644086441864428644386444864458644686447864488644986450864518645286453864548645586456864578645886459864608646186462864638646486465864668646786468864698647086471864728647386474864758647686477864788647986480864818648286483864848648586486864878648886489864908649186492864938649486495864968649786498864998650086501865028650386504865058650686507865088650986510865118651286513865148651586516865178651886519865208652186522865238652486525865268652786528865298653086531865328653386534865358653686537865388653986540865418654286543865448654586546865478654886549865508655186552865538655486555865568655786558865598656086561865628656386564865658656686567865688656986570865718657286573865748657586576865778657886579865808658186582865838658486585865868658786588865898659086591865928659386594865958659686597865988659986600866018660286603866048660586606866078660886609866108661186612866138661486615866168661786618866198662086621866228662386624866258662686627866288662986630866318663286633866348663586636866378663886639866408664186642866438664486645866468664786648866498665086651866528665386654866558665686657866588665986660866618666286663866648666586666866678666886669866708667186672866738667486675866768667786678866798668086681866828668386684866858668686687866888668986690866918669286693866948669586696866978669886699867008670186702867038670486705867068670786708867098671086711867128671386714867158671686717867188671986720867218672286723867248672586726867278672886729867308673186732867338673486735867368673786738867398674086741867428674386744867458674686747867488674986750867518675286753867548675586756867578675886759867608676186762867638676486765867668676786768867698677086771867728677386774867758677686777867788677986780867818678286783867848678586786867878678886789867908679186792867938679486795867968679786798867998680086801868028680386804868058680686807868088680986810868118681286813868148681586816868178681886819868208682186822868238682486825868268682786828868298683086831868328683386834868358683686837868388683986840868418684286843868448684586846868478684886849868508685186852868538685486855868568685786858868598686086861868628686386864868658686686867868688686986870868718687286873868748687586876868778687886879868808688186882868838688486885868868688786888868898689086891868928689386894868958689686897868988689986900869018690286903869048690586906869078690886909869108691186912869138691486915869168691786918869198692086921869228692386924869258692686927869288692986930869318693286933869348693586936869378693886939869408694186942869438694486945869468694786948869498695086951869528695386954869558695686957869588695986960869618696286963869648696586966869678696886969869708697186972869738697486975869768697786978869798698086981869828698386984869858698686987869888698986990869918699286993869948699586996869978699886999870008700187002870038700487005870068700787008870098701087011870128701387014870158701687017870188701987020870218702287023870248702587026870278702887029870308703187032870338703487035870368703787038870398704087041870428704387044870458704687047870488704987050870518705287053870548705587056870578705887059870608706187062870638706487065870668706787068870698707087071870728707387074870758707687077870788707987080870818708287083870848708587086870878708887089870908709187092870938709487095870968709787098870998710087101871028710387104871058710687107871088710987110871118711287113871148711587116871178711887119871208712187122871238712487125871268712787128871298713087131871328713387134871358713687137871388713987140871418714287143871448714587146871478714887149871508715187152871538715487155871568715787158871598716087161871628716387164871658716687167871688716987170871718717287173871748717587176871778717887179871808718187182871838718487185871868718787188871898719087191871928719387194871958719687197871988719987200872018720287203872048720587206872078720887209872108721187212872138721487215872168721787218872198722087221872228722387224872258722687227872288722987230872318723287233872348723587236872378723887239872408724187242872438724487245872468724787248872498725087251872528725387254872558725687257872588725987260872618726287263872648726587266872678726887269872708727187272872738727487275872768727787278872798728087281872828728387284872858728687287872888728987290872918729287293872948729587296872978729887299873008730187302873038730487305873068730787308873098731087311873128731387314873158731687317873188731987320873218732287323873248732587326873278732887329873308733187332873338733487335873368733787338873398734087341873428734387344873458734687347873488734987350873518735287353873548735587356873578735887359873608736187362873638736487365873668736787368873698737087371873728737387374873758737687377873788737987380873818738287383873848738587386873878738887389873908739187392873938739487395873968739787398873998740087401874028740387404874058740687407874088740987410874118741287413874148741587416874178741887419874208742187422874238742487425874268742787428874298743087431874328743387434874358743687437874388743987440874418744287443874448744587446874478744887449874508745187452874538745487455874568745787458874598746087461874628746387464874658746687467874688746987470874718747287473874748747587476874778747887479874808748187482874838748487485874868748787488874898749087491874928749387494874958749687497874988749987500875018750287503875048750587506875078750887509875108751187512875138751487515875168751787518875198752087521875228752387524875258752687527875288752987530875318753287533875348753587536875378753887539875408754187542875438754487545875468754787548875498755087551875528755387554875558755687557875588755987560875618756287563875648756587566875678756887569875708757187572875738757487575875768757787578875798758087581875828758387584875858758687587875888758987590875918759287593875948759587596875978759887599876008760187602876038760487605876068760787608876098761087611876128761387614876158761687617876188761987620876218762287623876248762587626876278762887629876308763187632876338763487635876368763787638876398764087641876428764387644876458764687647876488764987650876518765287653876548765587656876578765887659876608766187662876638766487665876668766787668876698767087671876728767387674
  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 dirty prepass flag value
  858. */
  859. static readonly MATERIAL_PrePassDirtyFlag: number;
  860. /**
  861. * The all dirty flag value
  862. */
  863. static readonly MATERIAL_AllDirtyFlag: number;
  864. /**
  865. * Returns the triangle fill mode
  866. */
  867. static readonly MATERIAL_TriangleFillMode: number;
  868. /**
  869. * Returns the wireframe mode
  870. */
  871. static readonly MATERIAL_WireFrameFillMode: number;
  872. /**
  873. * Returns the point fill mode
  874. */
  875. static readonly MATERIAL_PointFillMode: number;
  876. /**
  877. * Returns the point list draw mode
  878. */
  879. static readonly MATERIAL_PointListDrawMode: number;
  880. /**
  881. * Returns the line list draw mode
  882. */
  883. static readonly MATERIAL_LineListDrawMode: number;
  884. /**
  885. * Returns the line loop draw mode
  886. */
  887. static readonly MATERIAL_LineLoopDrawMode: number;
  888. /**
  889. * Returns the line strip draw mode
  890. */
  891. static readonly MATERIAL_LineStripDrawMode: number;
  892. /**
  893. * Returns the triangle strip draw mode
  894. */
  895. static readonly MATERIAL_TriangleStripDrawMode: number;
  896. /**
  897. * Returns the triangle fan draw mode
  898. */
  899. static readonly MATERIAL_TriangleFanDrawMode: number;
  900. /**
  901. * Stores the clock-wise side orientation
  902. */
  903. static readonly MATERIAL_ClockWiseSideOrientation: number;
  904. /**
  905. * Stores the counter clock-wise side orientation
  906. */
  907. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  908. /**
  909. * Nothing
  910. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_NothingTrigger: number;
  913. /**
  914. * On pick
  915. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickTrigger: number;
  918. /**
  919. * On left pick
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnLeftPickTrigger: number;
  923. /**
  924. * On right pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnRightPickTrigger: number;
  928. /**
  929. * On center pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnCenterPickTrigger: number;
  933. /**
  934. * On pick down
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnPickDownTrigger: number;
  938. /**
  939. * On double pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnDoublePickTrigger: number;
  943. /**
  944. * On pick up
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickUpTrigger: number;
  948. /**
  949. * On pick out.
  950. * This trigger will only be raised if you also declared a OnPickDown
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickOutTrigger: number;
  954. /**
  955. * On long press
  956. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnLongPressTrigger: number;
  959. /**
  960. * On pointer over
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPointerOverTrigger: number;
  964. /**
  965. * On pointer out
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnPointerOutTrigger: number;
  969. /**
  970. * On every frame
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnEveryFrameTrigger: number;
  974. /**
  975. * On intersection enter
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnIntersectionEnterTrigger: number;
  979. /**
  980. * On intersection exit
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnIntersectionExitTrigger: number;
  984. /**
  985. * On key down
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnKeyDownTrigger: number;
  989. /**
  990. * On key up
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnKeyUpTrigger: number;
  994. /**
  995. * Billboard mode will only apply to Y axis
  996. */
  997. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  998. /**
  999. * Billboard mode will apply to all axes
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1002. /**
  1003. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1006. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1007. * Test order :
  1008. * Is the bounding sphere outside the frustum ?
  1009. * If not, are the bounding box vertices outside the frustum ?
  1010. * It not, then the cullable object is in the frustum.
  1011. */
  1012. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1013. /** Culling strategy : Bounding Sphere Only.
  1014. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1015. * It's also less accurate than the standard because some not visible objects can still be selected.
  1016. * Test : is the bounding sphere outside the frustum ?
  1017. * If not, then the cullable object is in the frustum.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1020. /** Culling strategy : Optimistic Inclusion.
  1021. * This in an inclusion test first, then the standard exclusion test.
  1022. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1023. * 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.
  1024. * Anyway, it's as accurate as the standard strategy.
  1025. * Test :
  1026. * Is the cullable object bounding sphere center in the frustum ?
  1027. * If not, apply the default culling strategy.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1030. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1031. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1032. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1040. /**
  1041. * No logging while loading
  1042. */
  1043. static readonly SCENELOADER_NO_LOGGING: number;
  1044. /**
  1045. * Minimal logging while loading
  1046. */
  1047. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1048. /**
  1049. * Summary logging while loading
  1050. */
  1051. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1052. /**
  1053. * Detailled logging while loading
  1054. */
  1055. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1056. /**
  1057. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module BABYLON {
  1094. /**
  1095. * This represents the required contract to create a new type of texture loader.
  1096. */
  1097. export interface IInternalTextureLoader {
  1098. /**
  1099. * Defines wether the loader supports cascade loading the different faces.
  1100. */
  1101. supportCascades: boolean;
  1102. /**
  1103. * This returns if the loader support the current file information.
  1104. * @param extension defines the file extension of the file being loaded
  1105. * @param mimeType defines the optional mime type of the file being loaded
  1106. * @returns true if the loader can load the specified file
  1107. */
  1108. canLoad(extension: string, mimeType?: string): boolean;
  1109. /**
  1110. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1111. * @param data contains the texture data
  1112. * @param texture defines the BabylonJS internal texture
  1113. * @param createPolynomials will be true if polynomials have been requested
  1114. * @param onLoad defines the callback to trigger once the texture is ready
  1115. * @param onError defines the callback to trigger in case of error
  1116. */
  1117. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1118. /**
  1119. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1120. * @param data contains the texture data
  1121. * @param texture defines the BabylonJS internal texture
  1122. * @param callback defines the method to call once ready to upload
  1123. */
  1124. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1125. }
  1126. }
  1127. declare module BABYLON {
  1128. /**
  1129. * Class used to store and describe the pipeline context associated with an effect
  1130. */
  1131. export interface IPipelineContext {
  1132. /**
  1133. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1134. */
  1135. isAsync: boolean;
  1136. /**
  1137. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1138. */
  1139. isReady: boolean;
  1140. /** @hidden */
  1141. _getVertexShaderCode(): string | null;
  1142. /** @hidden */
  1143. _getFragmentShaderCode(): string | null;
  1144. /** @hidden */
  1145. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1146. }
  1147. }
  1148. declare module BABYLON {
  1149. /**
  1150. * Class used to store gfx data (like WebGLBuffer)
  1151. */
  1152. export class DataBuffer {
  1153. /**
  1154. * Gets or sets the number of objects referencing this buffer
  1155. */
  1156. references: number;
  1157. /** Gets or sets the size of the underlying buffer */
  1158. capacity: number;
  1159. /**
  1160. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1161. */
  1162. is32Bits: boolean;
  1163. /**
  1164. * Gets the underlying buffer
  1165. */
  1166. get underlyingResource(): any;
  1167. }
  1168. }
  1169. declare module BABYLON {
  1170. /** @hidden */
  1171. export interface IShaderProcessor {
  1172. attributeProcessor?: (attribute: string) => string;
  1173. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1174. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1175. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1176. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1177. lineProcessor?: (line: string, isFragment: boolean) => string;
  1178. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1179. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1180. }
  1181. }
  1182. declare module BABYLON {
  1183. /** @hidden */
  1184. export interface ProcessingOptions {
  1185. defines: string[];
  1186. indexParameters: any;
  1187. isFragment: boolean;
  1188. shouldUseHighPrecisionShader: boolean;
  1189. supportsUniformBuffers: boolean;
  1190. shadersRepository: string;
  1191. includesShadersStore: {
  1192. [key: string]: string;
  1193. };
  1194. processor?: IShaderProcessor;
  1195. version: string;
  1196. platformName: string;
  1197. lookForClosingBracketForUniformBuffer?: boolean;
  1198. }
  1199. }
  1200. declare module BABYLON {
  1201. /** @hidden */
  1202. export class ShaderCodeNode {
  1203. line: string;
  1204. children: ShaderCodeNode[];
  1205. additionalDefineKey?: string;
  1206. additionalDefineValue?: string;
  1207. isValid(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. process(preprocessors: {
  1211. [key: string]: string;
  1212. }, options: ProcessingOptions): string;
  1213. }
  1214. }
  1215. declare module BABYLON {
  1216. /** @hidden */
  1217. export class ShaderCodeCursor {
  1218. private _lines;
  1219. lineIndex: number;
  1220. get currentLine(): string;
  1221. get canRead(): boolean;
  1222. set lines(value: string[]);
  1223. }
  1224. }
  1225. declare module BABYLON {
  1226. /** @hidden */
  1227. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1228. process(preprocessors: {
  1229. [key: string]: string;
  1230. }, options: ProcessingOptions): string;
  1231. }
  1232. }
  1233. declare module BABYLON {
  1234. /** @hidden */
  1235. export class ShaderDefineExpression {
  1236. isTrue(preprocessors: {
  1237. [key: string]: string;
  1238. }): boolean;
  1239. private static _OperatorPriority;
  1240. private static _Stack;
  1241. static postfixToInfix(postfix: string[]): string;
  1242. static infixToPostfix(infix: string): string[];
  1243. }
  1244. }
  1245. declare module BABYLON {
  1246. /** @hidden */
  1247. export class ShaderCodeTestNode extends ShaderCodeNode {
  1248. testExpression: ShaderDefineExpression;
  1249. isValid(preprocessors: {
  1250. [key: string]: string;
  1251. }): boolean;
  1252. }
  1253. }
  1254. declare module BABYLON {
  1255. /** @hidden */
  1256. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1257. define: string;
  1258. not: boolean;
  1259. constructor(define: string, not?: boolean);
  1260. isTrue(preprocessors: {
  1261. [key: string]: string;
  1262. }): boolean;
  1263. }
  1264. }
  1265. declare module BABYLON {
  1266. /** @hidden */
  1267. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1268. leftOperand: ShaderDefineExpression;
  1269. rightOperand: ShaderDefineExpression;
  1270. isTrue(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module BABYLON {
  1276. /** @hidden */
  1277. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module BABYLON {
  1286. /** @hidden */
  1287. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1288. define: string;
  1289. operand: string;
  1290. testValue: string;
  1291. constructor(define: string, operand: string, testValue: string);
  1292. isTrue(preprocessors: {
  1293. [key: string]: string;
  1294. }): boolean;
  1295. }
  1296. }
  1297. declare module BABYLON {
  1298. /**
  1299. * Class used to enable access to offline support
  1300. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1301. */
  1302. export interface IOfflineProvider {
  1303. /**
  1304. * Gets a boolean indicating if scene must be saved in the database
  1305. */
  1306. enableSceneOffline: boolean;
  1307. /**
  1308. * Gets a boolean indicating if textures must be saved in the database
  1309. */
  1310. enableTexturesOffline: boolean;
  1311. /**
  1312. * Open the offline support and make it available
  1313. * @param successCallback defines the callback to call on success
  1314. * @param errorCallback defines the callback to call on error
  1315. */
  1316. open(successCallback: () => void, errorCallback: () => void): void;
  1317. /**
  1318. * Loads an image from the offline support
  1319. * @param url defines the url to load from
  1320. * @param image defines the target DOM image
  1321. */
  1322. loadImage(url: string, image: HTMLImageElement): void;
  1323. /**
  1324. * Loads a file from offline support
  1325. * @param url defines the URL to load from
  1326. * @param sceneLoaded defines a callback to call on success
  1327. * @param progressCallBack defines a callback to call when progress changed
  1328. * @param errorCallback defines a callback to call on error
  1329. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1330. */
  1331. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1332. }
  1333. }
  1334. declare module BABYLON {
  1335. /**
  1336. * Class used to help managing file picking and drag'n'drop
  1337. * File Storage
  1338. */
  1339. export class FilesInputStore {
  1340. /**
  1341. * List of files ready to be loaded
  1342. */
  1343. static FilesToLoad: {
  1344. [key: string]: File;
  1345. };
  1346. }
  1347. }
  1348. declare module BABYLON {
  1349. /**
  1350. * Class used to define a retry strategy when error happens while loading assets
  1351. */
  1352. export class RetryStrategy {
  1353. /**
  1354. * Function used to defines an exponential back off strategy
  1355. * @param maxRetries defines the maximum number of retries (3 by default)
  1356. * @param baseInterval defines the interval between retries
  1357. * @returns the strategy function to use
  1358. */
  1359. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1360. }
  1361. }
  1362. declare module BABYLON {
  1363. /**
  1364. * @ignore
  1365. * Application error to support additional information when loading a file
  1366. */
  1367. export abstract class BaseError extends Error {
  1368. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1369. }
  1370. }
  1371. declare module BABYLON {
  1372. /** @ignore */
  1373. export class LoadFileError extends BaseError {
  1374. request?: WebRequest;
  1375. file?: File;
  1376. /**
  1377. * Creates a new LoadFileError
  1378. * @param message defines the message of the error
  1379. * @param request defines the optional web request
  1380. * @param file defines the optional file
  1381. */
  1382. constructor(message: string, object?: WebRequest | File);
  1383. }
  1384. /** @ignore */
  1385. export class RequestFileError extends BaseError {
  1386. request: WebRequest;
  1387. /**
  1388. * Creates a new LoadFileError
  1389. * @param message defines the message of the error
  1390. * @param request defines the optional web request
  1391. */
  1392. constructor(message: string, request: WebRequest);
  1393. }
  1394. /** @ignore */
  1395. export class ReadFileError extends BaseError {
  1396. file: File;
  1397. /**
  1398. * Creates a new ReadFileError
  1399. * @param message defines the message of the error
  1400. * @param file defines the optional file
  1401. */
  1402. constructor(message: string, file: File);
  1403. }
  1404. /**
  1405. * @hidden
  1406. */
  1407. export class FileTools {
  1408. /**
  1409. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1410. */
  1411. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1412. /**
  1413. * Gets or sets the base URL to use to load assets
  1414. */
  1415. static BaseUrl: string;
  1416. /**
  1417. * Default behaviour for cors in the application.
  1418. * It can be a string if the expected behavior is identical in the entire app.
  1419. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1420. */
  1421. static CorsBehavior: string | ((url: string | string[]) => string);
  1422. /**
  1423. * Gets or sets a function used to pre-process url before using them to load assets
  1424. */
  1425. static PreprocessUrl: (url: string) => string;
  1426. /**
  1427. * Removes unwanted characters from an url
  1428. * @param url defines the url to clean
  1429. * @returns the cleaned url
  1430. */
  1431. private static _CleanUrl;
  1432. /**
  1433. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1434. * @param url define the url we are trying
  1435. * @param element define the dom element where to configure the cors policy
  1436. */
  1437. static SetCorsBehavior(url: string | string[], element: {
  1438. crossOrigin: string | null;
  1439. }): void;
  1440. /**
  1441. * Loads an image as an HTMLImageElement.
  1442. * @param input url string, ArrayBuffer, or Blob to load
  1443. * @param onLoad callback called when the image successfully loads
  1444. * @param onError callback called when the image fails to load
  1445. * @param offlineProvider offline provider for caching
  1446. * @param mimeType optional mime type
  1447. * @returns the HTMLImageElement of the loaded image
  1448. */
  1449. 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>;
  1450. /**
  1451. * Reads a file from a File object
  1452. * @param file defines the file to load
  1453. * @param onSuccess defines the callback to call when data is loaded
  1454. * @param onProgress defines the callback to call during loading process
  1455. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1456. * @param onError defines the callback to call when an error occurs
  1457. * @returns a file request object
  1458. */
  1459. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1460. /**
  1461. * Loads a file from a url
  1462. * @param url url to load
  1463. * @param onSuccess callback called when the file successfully loads
  1464. * @param onProgress callback called while file is loading (if the server supports this mode)
  1465. * @param offlineProvider defines the offline provider for caching
  1466. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1467. * @param onError callback called when the file fails to load
  1468. * @returns a file request object
  1469. */
  1470. 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;
  1471. /**
  1472. * Loads a file
  1473. * @param url url to load
  1474. * @param onSuccess callback called when the file successfully loads
  1475. * @param onProgress callback called while file is loading (if the server supports this mode)
  1476. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1477. * @param onError callback called when the file fails to load
  1478. * @param onOpened callback called when the web request is opened
  1479. * @returns a file request object
  1480. */
  1481. 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;
  1482. /**
  1483. * Checks if the loaded document was accessed via `file:`-Protocol.
  1484. * @returns boolean
  1485. */
  1486. static IsFileURL(): boolean;
  1487. }
  1488. }
  1489. declare module BABYLON {
  1490. /** @hidden */
  1491. export class ShaderProcessor {
  1492. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1493. private static _ProcessPrecision;
  1494. private static _ExtractOperation;
  1495. private static _BuildSubExpression;
  1496. private static _BuildExpression;
  1497. private static _MoveCursorWithinIf;
  1498. private static _MoveCursor;
  1499. private static _EvaluatePreProcessors;
  1500. private static _PreparePreProcessors;
  1501. private static _ProcessShaderConversion;
  1502. private static _ProcessIncludes;
  1503. /**
  1504. * Loads a file from a url
  1505. * @param url url to load
  1506. * @param onSuccess callback called when the file successfully loads
  1507. * @param onProgress callback called while file is loading (if the server supports this mode)
  1508. * @param offlineProvider defines the offline provider for caching
  1509. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1510. * @param onError callback called when the file fails to load
  1511. * @returns a file request object
  1512. * @hidden
  1513. */
  1514. 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;
  1515. }
  1516. }
  1517. declare module BABYLON {
  1518. /**
  1519. * @hidden
  1520. */
  1521. export interface IColor4Like {
  1522. r: float;
  1523. g: float;
  1524. b: float;
  1525. a: float;
  1526. }
  1527. /**
  1528. * @hidden
  1529. */
  1530. export interface IColor3Like {
  1531. r: float;
  1532. g: float;
  1533. b: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IVector4Like {
  1539. x: float;
  1540. y: float;
  1541. z: float;
  1542. w: float;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IVector3Like {
  1548. x: float;
  1549. y: float;
  1550. z: float;
  1551. }
  1552. /**
  1553. * @hidden
  1554. */
  1555. export interface IVector2Like {
  1556. x: float;
  1557. y: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IMatrixLike {
  1563. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1564. updateFlag: int;
  1565. }
  1566. /**
  1567. * @hidden
  1568. */
  1569. export interface IViewportLike {
  1570. x: float;
  1571. y: float;
  1572. width: float;
  1573. height: float;
  1574. }
  1575. /**
  1576. * @hidden
  1577. */
  1578. export interface IPlaneLike {
  1579. normal: IVector3Like;
  1580. d: float;
  1581. normalize(): void;
  1582. }
  1583. }
  1584. declare module BABYLON {
  1585. /**
  1586. * Interface used to define common properties for effect fallbacks
  1587. */
  1588. export interface IEffectFallbacks {
  1589. /**
  1590. * Removes the defines that should be removed when falling back.
  1591. * @param currentDefines defines the current define statements for the shader.
  1592. * @param effect defines the current effect we try to compile
  1593. * @returns The resulting defines with defines of the current rank removed.
  1594. */
  1595. reduce(currentDefines: string, effect: Effect): string;
  1596. /**
  1597. * Removes the fallback from the bound mesh.
  1598. */
  1599. unBindMesh(): void;
  1600. /**
  1601. * Checks to see if more fallbacks are still availible.
  1602. */
  1603. hasMoreFallbacks: boolean;
  1604. }
  1605. }
  1606. declare module BABYLON {
  1607. /**
  1608. * Class used to evalaute queries containing `and` and `or` operators
  1609. */
  1610. export class AndOrNotEvaluator {
  1611. /**
  1612. * Evaluate a query
  1613. * @param query defines the query to evaluate
  1614. * @param evaluateCallback defines the callback used to filter result
  1615. * @returns true if the query matches
  1616. */
  1617. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1618. private static _HandleParenthesisContent;
  1619. private static _SimplifyNegation;
  1620. }
  1621. }
  1622. declare module BABYLON {
  1623. /**
  1624. * Class used to store custom tags
  1625. */
  1626. export class Tags {
  1627. /**
  1628. * Adds support for tags on the given object
  1629. * @param obj defines the object to use
  1630. */
  1631. static EnableFor(obj: any): void;
  1632. /**
  1633. * Removes tags support
  1634. * @param obj defines the object to use
  1635. */
  1636. static DisableFor(obj: any): void;
  1637. /**
  1638. * Gets a boolean indicating if the given object has tags
  1639. * @param obj defines the object to use
  1640. * @returns a boolean
  1641. */
  1642. static HasTags(obj: any): boolean;
  1643. /**
  1644. * Gets the tags available on a given object
  1645. * @param obj defines the object to use
  1646. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1647. * @returns the tags
  1648. */
  1649. static GetTags(obj: any, asString?: boolean): any;
  1650. /**
  1651. * Adds tags to an object
  1652. * @param obj defines the object to use
  1653. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1654. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1655. */
  1656. static AddTagsTo(obj: any, tagsString: string): void;
  1657. /**
  1658. * @hidden
  1659. */
  1660. static _AddTagTo(obj: any, tag: string): void;
  1661. /**
  1662. * Removes specific tags from a specific object
  1663. * @param obj defines the object to use
  1664. * @param tagsString defines the tags to remove
  1665. */
  1666. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1667. /**
  1668. * @hidden
  1669. */
  1670. static _RemoveTagFrom(obj: any, tag: string): void;
  1671. /**
  1672. * Defines if tags hosted on an object match a given query
  1673. * @param obj defines the object to use
  1674. * @param tagsQuery defines the tag query
  1675. * @returns a boolean
  1676. */
  1677. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1678. }
  1679. }
  1680. declare module BABYLON {
  1681. /**
  1682. * Scalar computation library
  1683. */
  1684. export class Scalar {
  1685. /**
  1686. * Two pi constants convenient for computation.
  1687. */
  1688. static TwoPi: number;
  1689. /**
  1690. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1691. * @param a number
  1692. * @param b number
  1693. * @param epsilon (default = 1.401298E-45)
  1694. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1695. */
  1696. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1697. /**
  1698. * Returns a string : the upper case translation of the number i to hexadecimal.
  1699. * @param i number
  1700. * @returns the upper case translation of the number i to hexadecimal.
  1701. */
  1702. static ToHex(i: number): string;
  1703. /**
  1704. * Returns -1 if value is negative and +1 is value is positive.
  1705. * @param value the value
  1706. * @returns the value itself if it's equal to zero.
  1707. */
  1708. static Sign(value: number): number;
  1709. /**
  1710. * Returns the value itself if it's between min and max.
  1711. * Returns min if the value is lower than min.
  1712. * Returns max if the value is greater than max.
  1713. * @param value the value to clmap
  1714. * @param min the min value to clamp to (default: 0)
  1715. * @param max the max value to clamp to (default: 1)
  1716. * @returns the clamped value
  1717. */
  1718. static Clamp(value: number, min?: number, max?: number): number;
  1719. /**
  1720. * the log2 of value.
  1721. * @param value the value to compute log2 of
  1722. * @returns the log2 of value.
  1723. */
  1724. static Log2(value: number): number;
  1725. /**
  1726. * Loops the value, so that it is never larger than length and never smaller than 0.
  1727. *
  1728. * This is similar to the modulo operator but it works with floating point numbers.
  1729. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1730. * With t = 5 and length = 2.5, the result would be 0.0.
  1731. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1732. * @param value the value
  1733. * @param length the length
  1734. * @returns the looped value
  1735. */
  1736. static Repeat(value: number, length: number): number;
  1737. /**
  1738. * Normalize the value between 0.0 and 1.0 using min and max values
  1739. * @param value value to normalize
  1740. * @param min max to normalize between
  1741. * @param max min to normalize between
  1742. * @returns the normalized value
  1743. */
  1744. static Normalize(value: number, min: number, max: number): number;
  1745. /**
  1746. * Denormalize the value from 0.0 and 1.0 using min and max values
  1747. * @param normalized value to denormalize
  1748. * @param min max to denormalize between
  1749. * @param max min to denormalize between
  1750. * @returns the denormalized value
  1751. */
  1752. static Denormalize(normalized: number, min: number, max: number): number;
  1753. /**
  1754. * Calculates the shortest difference between two given angles given in degrees.
  1755. * @param current current angle in degrees
  1756. * @param target target angle in degrees
  1757. * @returns the delta
  1758. */
  1759. static DeltaAngle(current: number, target: number): number;
  1760. /**
  1761. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1762. * @param tx value
  1763. * @param length length
  1764. * @returns The returned value will move back and forth between 0 and length
  1765. */
  1766. static PingPong(tx: number, length: number): number;
  1767. /**
  1768. * Interpolates between min and max with smoothing at the limits.
  1769. *
  1770. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1771. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1772. * @param from from
  1773. * @param to to
  1774. * @param tx value
  1775. * @returns the smooth stepped value
  1776. */
  1777. static SmoothStep(from: number, to: number, tx: number): number;
  1778. /**
  1779. * Moves a value current towards target.
  1780. *
  1781. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1782. * Negative values of maxDelta pushes the value away from target.
  1783. * @param current current value
  1784. * @param target target value
  1785. * @param maxDelta max distance to move
  1786. * @returns resulting value
  1787. */
  1788. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1789. /**
  1790. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1791. *
  1792. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1793. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1794. * @param current current value
  1795. * @param target target value
  1796. * @param maxDelta max distance to move
  1797. * @returns resulting angle
  1798. */
  1799. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1800. /**
  1801. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1802. * @param start start value
  1803. * @param end target value
  1804. * @param amount amount to lerp between
  1805. * @returns the lerped value
  1806. */
  1807. static Lerp(start: number, end: number, amount: number): number;
  1808. /**
  1809. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1810. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1811. * @param start start value
  1812. * @param end target value
  1813. * @param amount amount to lerp between
  1814. * @returns the lerped value
  1815. */
  1816. static LerpAngle(start: number, end: number, amount: number): number;
  1817. /**
  1818. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1819. * @param a start value
  1820. * @param b target value
  1821. * @param value value between a and b
  1822. * @returns the inverseLerp value
  1823. */
  1824. static InverseLerp(a: number, b: number, value: number): number;
  1825. /**
  1826. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1827. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1828. * @param value1 spline value
  1829. * @param tangent1 spline value
  1830. * @param value2 spline value
  1831. * @param tangent2 spline value
  1832. * @param amount input value
  1833. * @returns hermite result
  1834. */
  1835. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1836. /**
  1837. * Returns a random float number between and min and max values
  1838. * @param min min value of random
  1839. * @param max max value of random
  1840. * @returns random value
  1841. */
  1842. static RandomRange(min: number, max: number): number;
  1843. /**
  1844. * This function returns percentage of a number in a given range.
  1845. *
  1846. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1847. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1848. * @param number to convert to percentage
  1849. * @param min min range
  1850. * @param max max range
  1851. * @returns the percentage
  1852. */
  1853. static RangeToPercent(number: number, min: number, max: number): number;
  1854. /**
  1855. * This function returns number that corresponds to the percentage in a given range.
  1856. *
  1857. * PercentToRange(0.34,0,100) will return 34.
  1858. * @param percent to convert to number
  1859. * @param min min range
  1860. * @param max max range
  1861. * @returns the number
  1862. */
  1863. static PercentToRange(percent: number, min: number, max: number): number;
  1864. /**
  1865. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1866. * @param angle The angle to normalize in radian.
  1867. * @return The converted angle.
  1868. */
  1869. static NormalizeRadians(angle: number): number;
  1870. }
  1871. }
  1872. declare module BABYLON {
  1873. /**
  1874. * Constant used to convert a value to gamma space
  1875. * @ignorenaming
  1876. */
  1877. export const ToGammaSpace: number;
  1878. /**
  1879. * Constant used to convert a value to linear space
  1880. * @ignorenaming
  1881. */
  1882. export const ToLinearSpace = 2.2;
  1883. /**
  1884. * Constant used to define the minimal number value in Babylon.js
  1885. * @ignorenaming
  1886. */
  1887. let Epsilon: number;
  1888. }
  1889. declare module BABYLON {
  1890. /**
  1891. * Class used to represent a viewport on screen
  1892. */
  1893. export class Viewport {
  1894. /** viewport left coordinate */
  1895. x: number;
  1896. /** viewport top coordinate */
  1897. y: number;
  1898. /**viewport width */
  1899. width: number;
  1900. /** viewport height */
  1901. height: number;
  1902. /**
  1903. * Creates a Viewport object located at (x, y) and sized (width, height)
  1904. * @param x defines viewport left coordinate
  1905. * @param y defines viewport top coordinate
  1906. * @param width defines the viewport width
  1907. * @param height defines the viewport height
  1908. */
  1909. constructor(
  1910. /** viewport left coordinate */
  1911. x: number,
  1912. /** viewport top coordinate */
  1913. y: number,
  1914. /**viewport width */
  1915. width: number,
  1916. /** viewport height */
  1917. height: number);
  1918. /**
  1919. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1920. * @param renderWidth defines the rendering width
  1921. * @param renderHeight defines the rendering height
  1922. * @returns a new Viewport
  1923. */
  1924. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1925. /**
  1926. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1927. * @param renderWidth defines the rendering width
  1928. * @param renderHeight defines the rendering height
  1929. * @param ref defines the target viewport
  1930. * @returns the current viewport
  1931. */
  1932. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1933. /**
  1934. * Returns a new Viewport copied from the current one
  1935. * @returns a new Viewport
  1936. */
  1937. clone(): Viewport;
  1938. }
  1939. }
  1940. declare module BABYLON {
  1941. /**
  1942. * Class containing a set of static utilities functions for arrays.
  1943. */
  1944. export class ArrayTools {
  1945. /**
  1946. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1947. * @param size the number of element to construct and put in the array
  1948. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1949. * @returns a new array filled with new objects
  1950. */
  1951. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1952. }
  1953. }
  1954. declare module BABYLON {
  1955. /**
  1956. * Represents a plane by the equation ax + by + cz + d = 0
  1957. */
  1958. export class Plane {
  1959. private static _TmpMatrix;
  1960. /**
  1961. * Normal of the plane (a,b,c)
  1962. */
  1963. normal: Vector3;
  1964. /**
  1965. * d component of the plane
  1966. */
  1967. d: number;
  1968. /**
  1969. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1970. * @param a a component of the plane
  1971. * @param b b component of the plane
  1972. * @param c c component of the plane
  1973. * @param d d component of the plane
  1974. */
  1975. constructor(a: number, b: number, c: number, d: number);
  1976. /**
  1977. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1978. */
  1979. asArray(): number[];
  1980. /**
  1981. * @returns a new plane copied from the current Plane.
  1982. */
  1983. clone(): Plane;
  1984. /**
  1985. * @returns the string "Plane".
  1986. */
  1987. getClassName(): string;
  1988. /**
  1989. * @returns the Plane hash code.
  1990. */
  1991. getHashCode(): number;
  1992. /**
  1993. * Normalize the current Plane in place.
  1994. * @returns the updated Plane.
  1995. */
  1996. normalize(): Plane;
  1997. /**
  1998. * Applies a transformation the plane and returns the result
  1999. * @param transformation the transformation matrix to be applied to the plane
  2000. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2001. */
  2002. transform(transformation: DeepImmutable<Matrix>): Plane;
  2003. /**
  2004. * Compute the dot product between the point and the plane normal
  2005. * @param point point to calculate the dot product with
  2006. * @returns the dot product (float) of the point coordinates and the plane normal.
  2007. */
  2008. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2009. /**
  2010. * Updates the current Plane from the plane defined by the three given points.
  2011. * @param point1 one of the points used to contruct the plane
  2012. * @param point2 one of the points used to contruct the plane
  2013. * @param point3 one of the points used to contruct the plane
  2014. * @returns the updated Plane.
  2015. */
  2016. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2017. /**
  2018. * Checks if the plane is facing a given direction
  2019. * @param direction the direction to check if the plane is facing
  2020. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2021. * @returns True is the vector "direction" is the same side than the plane normal.
  2022. */
  2023. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2024. /**
  2025. * Calculates the distance to a point
  2026. * @param point point to calculate distance to
  2027. * @returns the signed distance (float) from the given point to the Plane.
  2028. */
  2029. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2030. /**
  2031. * Creates a plane from an array
  2032. * @param array the array to create a plane from
  2033. * @returns a new Plane from the given array.
  2034. */
  2035. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2036. /**
  2037. * Creates a plane from three points
  2038. * @param point1 point used to create the plane
  2039. * @param point2 point used to create the plane
  2040. * @param point3 point used to create the plane
  2041. * @returns a new Plane defined by the three given points.
  2042. */
  2043. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2044. /**
  2045. * Creates a plane from an origin point and a normal
  2046. * @param origin origin of the plane to be constructed
  2047. * @param normal normal of the plane to be constructed
  2048. * @returns a new Plane the normal vector to this plane at the given origin point.
  2049. * Note : the vector "normal" is updated because normalized.
  2050. */
  2051. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2052. /**
  2053. * Calculates the distance from a plane and a point
  2054. * @param origin origin of the plane to be constructed
  2055. * @param normal normal of the plane to be constructed
  2056. * @param point point to calculate distance to
  2057. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2058. */
  2059. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2060. }
  2061. }
  2062. declare module BABYLON {
  2063. /** @hidden */
  2064. export class PerformanceConfigurator {
  2065. /** @hidden */
  2066. static MatrixUse64Bits: boolean;
  2067. /** @hidden */
  2068. static MatrixTrackPrecisionChange: boolean;
  2069. /** @hidden */
  2070. static MatrixCurrentType: any;
  2071. /** @hidden */
  2072. static MatrixTrackedMatrices: Array<any> | null;
  2073. /** @hidden */
  2074. static SetMatrixPrecision(use64bits: boolean): void;
  2075. }
  2076. }
  2077. declare module BABYLON {
  2078. /**
  2079. * Class representing a vector containing 2 coordinates
  2080. */
  2081. export class Vector2 {
  2082. /** defines the first coordinate */
  2083. x: number;
  2084. /** defines the second coordinate */
  2085. y: number;
  2086. /**
  2087. * Creates a new Vector2 from the given x and y coordinates
  2088. * @param x defines the first coordinate
  2089. * @param y defines the second coordinate
  2090. */
  2091. constructor(
  2092. /** defines the first coordinate */
  2093. x?: number,
  2094. /** defines the second coordinate */
  2095. y?: number);
  2096. /**
  2097. * Gets a string with the Vector2 coordinates
  2098. * @returns a string with the Vector2 coordinates
  2099. */
  2100. toString(): string;
  2101. /**
  2102. * Gets class name
  2103. * @returns the string "Vector2"
  2104. */
  2105. getClassName(): string;
  2106. /**
  2107. * Gets current vector hash code
  2108. * @returns the Vector2 hash code as a number
  2109. */
  2110. getHashCode(): number;
  2111. /**
  2112. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2113. * @param array defines the source array
  2114. * @param index defines the offset in source array
  2115. * @returns the current Vector2
  2116. */
  2117. toArray(array: FloatArray, index?: number): Vector2;
  2118. /**
  2119. * Update the current vector from an array
  2120. * @param array defines the destination array
  2121. * @param index defines the offset in the destination array
  2122. * @returns the current Vector3
  2123. */
  2124. fromArray(array: FloatArray, index?: number): Vector2;
  2125. /**
  2126. * Copy the current vector to an array
  2127. * @returns a new array with 2 elements: the Vector2 coordinates.
  2128. */
  2129. asArray(): number[];
  2130. /**
  2131. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2132. * @param source defines the source Vector2
  2133. * @returns the current updated Vector2
  2134. */
  2135. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2136. /**
  2137. * Sets the Vector2 coordinates with the given floats
  2138. * @param x defines the first coordinate
  2139. * @param y defines the second coordinate
  2140. * @returns the current updated Vector2
  2141. */
  2142. copyFromFloats(x: number, y: number): Vector2;
  2143. /**
  2144. * Sets the Vector2 coordinates with the given floats
  2145. * @param x defines the first coordinate
  2146. * @param y defines the second coordinate
  2147. * @returns the current updated Vector2
  2148. */
  2149. set(x: number, y: number): Vector2;
  2150. /**
  2151. * Add another vector with the current one
  2152. * @param otherVector defines the other vector
  2153. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2154. */
  2155. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2156. /**
  2157. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2158. * @param otherVector defines the other vector
  2159. * @param result defines the target vector
  2160. * @returns the unmodified current Vector2
  2161. */
  2162. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2163. /**
  2164. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2165. * @param otherVector defines the other vector
  2166. * @returns the current updated Vector2
  2167. */
  2168. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2169. /**
  2170. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns a new Vector2
  2173. */
  2174. addVector3(otherVector: Vector3): Vector2;
  2175. /**
  2176. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. subtract(otherVector: Vector2): Vector2;
  2181. /**
  2182. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2183. * @param otherVector defines the other vector
  2184. * @param result defines the target vector
  2185. * @returns the unmodified current Vector2
  2186. */
  2187. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2188. /**
  2189. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @returns the current updated Vector2
  2192. */
  2193. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2194. /**
  2195. * Multiplies in place the current Vector2 coordinates by the given ones
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2202. * @param otherVector defines the other vector
  2203. * @returns a new Vector2
  2204. */
  2205. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @param result defines the target vector
  2210. * @returns the unmodified current Vector2
  2211. */
  2212. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2213. /**
  2214. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2215. * @param x defines the first coordinate
  2216. * @param y defines the second coordinate
  2217. * @returns a new Vector2
  2218. */
  2219. multiplyByFloats(x: number, y: number): Vector2;
  2220. /**
  2221. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns a new Vector2
  2224. */
  2225. divide(otherVector: Vector2): Vector2;
  2226. /**
  2227. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @param result defines the target vector
  2230. * @returns the unmodified current Vector2
  2231. */
  2232. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2233. /**
  2234. * Divides the current Vector2 coordinates by the given ones
  2235. * @param otherVector defines the other vector
  2236. * @returns the current updated Vector2
  2237. */
  2238. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2239. /**
  2240. * Gets a new Vector2 with current Vector2 negated coordinates
  2241. * @returns a new Vector2
  2242. */
  2243. negate(): Vector2;
  2244. /**
  2245. * Negate this vector in place
  2246. * @returns this
  2247. */
  2248. negateInPlace(): Vector2;
  2249. /**
  2250. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2251. * @param result defines the Vector3 object where to store the result
  2252. * @returns the current Vector2
  2253. */
  2254. negateToRef(result: Vector2): Vector2;
  2255. /**
  2256. * Multiply the Vector2 coordinates by scale
  2257. * @param scale defines the scaling factor
  2258. * @returns the current updated Vector2
  2259. */
  2260. scaleInPlace(scale: number): Vector2;
  2261. /**
  2262. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2263. * @param scale defines the scaling factor
  2264. * @returns a new Vector2
  2265. */
  2266. scale(scale: number): Vector2;
  2267. /**
  2268. * Scale the current Vector2 values by a factor to a given Vector2
  2269. * @param scale defines the scale factor
  2270. * @param result defines the Vector2 object where to store the result
  2271. * @returns the unmodified current Vector2
  2272. */
  2273. scaleToRef(scale: number, result: Vector2): Vector2;
  2274. /**
  2275. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2276. * @param scale defines the scale factor
  2277. * @param result defines the Vector2 object where to store the result
  2278. * @returns the unmodified current Vector2
  2279. */
  2280. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2281. /**
  2282. * Gets a boolean if two vectors are equals
  2283. * @param otherVector defines the other vector
  2284. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2285. */
  2286. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2287. /**
  2288. * Gets a boolean if two vectors are equals (using an epsilon value)
  2289. * @param otherVector defines the other vector
  2290. * @param epsilon defines the minimal distance to consider equality
  2291. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2292. */
  2293. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2294. /**
  2295. * Gets a new Vector2 from current Vector2 floored values
  2296. * @returns a new Vector2
  2297. */
  2298. floor(): Vector2;
  2299. /**
  2300. * Gets a new Vector2 from current Vector2 floored values
  2301. * @returns a new Vector2
  2302. */
  2303. fract(): Vector2;
  2304. /**
  2305. * Gets the length of the vector
  2306. * @returns the vector length (float)
  2307. */
  2308. length(): number;
  2309. /**
  2310. * Gets the vector squared length
  2311. * @returns the vector squared length (float)
  2312. */
  2313. lengthSquared(): number;
  2314. /**
  2315. * Normalize the vector
  2316. * @returns the current updated Vector2
  2317. */
  2318. normalize(): Vector2;
  2319. /**
  2320. * Gets a new Vector2 copied from the Vector2
  2321. * @returns a new Vector2
  2322. */
  2323. clone(): Vector2;
  2324. /**
  2325. * Gets a new Vector2(0, 0)
  2326. * @returns a new Vector2
  2327. */
  2328. static Zero(): Vector2;
  2329. /**
  2330. * Gets a new Vector2(1, 1)
  2331. * @returns a new Vector2
  2332. */
  2333. static One(): Vector2;
  2334. /**
  2335. * Gets a new Vector2 set from the given index element of the given array
  2336. * @param array defines the data source
  2337. * @param offset defines the offset in the data source
  2338. * @returns a new Vector2
  2339. */
  2340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2341. /**
  2342. * Sets "result" from the given index element of the given array
  2343. * @param array defines the data source
  2344. * @param offset defines the offset in the data source
  2345. * @param result defines the target vector
  2346. */
  2347. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2348. /**
  2349. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2350. * @param value1 defines 1st point of control
  2351. * @param value2 defines 2nd point of control
  2352. * @param value3 defines 3rd point of control
  2353. * @param value4 defines 4th point of control
  2354. * @param amount defines the interpolation factor
  2355. * @returns a new Vector2
  2356. */
  2357. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2358. /**
  2359. * 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".
  2360. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2361. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2362. * @param value defines the value to clamp
  2363. * @param min defines the lower limit
  2364. * @param max defines the upper limit
  2365. * @returns a new Vector2
  2366. */
  2367. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2368. /**
  2369. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2370. * @param value1 defines the 1st control point
  2371. * @param tangent1 defines the outgoing tangent
  2372. * @param value2 defines the 2nd control point
  2373. * @param tangent2 defines the incoming tangent
  2374. * @param amount defines the interpolation factor
  2375. * @returns a new Vector2
  2376. */
  2377. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2378. /**
  2379. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2380. * @param start defines the start vector
  2381. * @param end defines the end vector
  2382. * @param amount defines the interpolation factor
  2383. * @returns a new Vector2
  2384. */
  2385. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2386. /**
  2387. * Gets the dot product of the vector "left" and the vector "right"
  2388. * @param left defines first vector
  2389. * @param right defines second vector
  2390. * @returns the dot product (float)
  2391. */
  2392. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2393. /**
  2394. * Returns a new Vector2 equal to the normalized given vector
  2395. * @param vector defines the vector to normalize
  2396. * @returns a new Vector2
  2397. */
  2398. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2399. /**
  2400. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2401. * @param left defines 1st vector
  2402. * @param right defines 2nd vector
  2403. * @returns a new Vector2
  2404. */
  2405. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2406. /**
  2407. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2408. * @param left defines 1st vector
  2409. * @param right defines 2nd vector
  2410. * @returns a new Vector2
  2411. */
  2412. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2413. /**
  2414. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2415. * @param vector defines the vector to transform
  2416. * @param transformation defines the matrix to apply
  2417. * @returns a new Vector2
  2418. */
  2419. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2420. /**
  2421. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2422. * @param vector defines the vector to transform
  2423. * @param transformation defines the matrix to apply
  2424. * @param result defines the target vector
  2425. */
  2426. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2427. /**
  2428. * Determines if a given vector is included in a triangle
  2429. * @param p defines the vector to test
  2430. * @param p0 defines 1st triangle point
  2431. * @param p1 defines 2nd triangle point
  2432. * @param p2 defines 3rd triangle point
  2433. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2434. */
  2435. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2436. /**
  2437. * Gets the distance between the vectors "value1" and "value2"
  2438. * @param value1 defines first vector
  2439. * @param value2 defines second vector
  2440. * @returns the distance between vectors
  2441. */
  2442. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2443. /**
  2444. * Returns the squared distance between the vectors "value1" and "value2"
  2445. * @param value1 defines first vector
  2446. * @param value2 defines second vector
  2447. * @returns the squared distance between vectors
  2448. */
  2449. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2450. /**
  2451. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2452. * @param value1 defines first vector
  2453. * @param value2 defines second vector
  2454. * @returns a new Vector2
  2455. */
  2456. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2457. /**
  2458. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2459. * @param p defines the middle point
  2460. * @param segA defines one point of the segment
  2461. * @param segB defines the other point of the segment
  2462. * @returns the shortest distance
  2463. */
  2464. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2465. }
  2466. /**
  2467. * Class used to store (x,y,z) vector representation
  2468. * A Vector3 is the main object used in 3D geometry
  2469. * It can represent etiher the coordinates of a point the space, either a direction
  2470. * Reminder: js uses a left handed forward facing system
  2471. */
  2472. export class Vector3 {
  2473. private static _UpReadOnly;
  2474. private static _ZeroReadOnly;
  2475. /** @hidden */
  2476. _x: number;
  2477. /** @hidden */
  2478. _y: number;
  2479. /** @hidden */
  2480. _z: number;
  2481. /** @hidden */
  2482. _isDirty: boolean;
  2483. /** Gets or sets the x coordinate */
  2484. get x(): number;
  2485. set x(value: number);
  2486. /** Gets or sets the y coordinate */
  2487. get y(): number;
  2488. set y(value: number);
  2489. /** Gets or sets the z coordinate */
  2490. get z(): number;
  2491. set z(value: number);
  2492. /**
  2493. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2494. * @param x defines the first coordinates (on X axis)
  2495. * @param y defines the second coordinates (on Y axis)
  2496. * @param z defines the third coordinates (on Z axis)
  2497. */
  2498. constructor(x?: number, y?: number, z?: number);
  2499. /**
  2500. * Creates a string representation of the Vector3
  2501. * @returns a string with the Vector3 coordinates.
  2502. */
  2503. toString(): string;
  2504. /**
  2505. * Gets the class name
  2506. * @returns the string "Vector3"
  2507. */
  2508. getClassName(): string;
  2509. /**
  2510. * Creates the Vector3 hash code
  2511. * @returns a number which tends to be unique between Vector3 instances
  2512. */
  2513. getHashCode(): number;
  2514. /**
  2515. * Creates an array containing three elements : the coordinates of the Vector3
  2516. * @returns a new array of numbers
  2517. */
  2518. asArray(): number[];
  2519. /**
  2520. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2521. * @param array defines the destination array
  2522. * @param index defines the offset in the destination array
  2523. * @returns the current Vector3
  2524. */
  2525. toArray(array: FloatArray, index?: number): Vector3;
  2526. /**
  2527. * Update the current vector from an array
  2528. * @param array defines the destination array
  2529. * @param index defines the offset in the destination array
  2530. * @returns the current Vector3
  2531. */
  2532. fromArray(array: FloatArray, index?: number): Vector3;
  2533. /**
  2534. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2535. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2536. */
  2537. toQuaternion(): Quaternion;
  2538. /**
  2539. * Adds the given vector to the current Vector3
  2540. * @param otherVector defines the second operand
  2541. * @returns the current updated Vector3
  2542. */
  2543. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2544. /**
  2545. * Adds the given coordinates to the current Vector3
  2546. * @param x defines the x coordinate of the operand
  2547. * @param y defines the y coordinate of the operand
  2548. * @param z defines the z coordinate of the operand
  2549. * @returns the current updated Vector3
  2550. */
  2551. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2552. /**
  2553. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2554. * @param otherVector defines the second operand
  2555. * @returns the resulting Vector3
  2556. */
  2557. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2558. /**
  2559. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2560. * @param otherVector defines the second operand
  2561. * @param result defines the Vector3 object where to store the result
  2562. * @returns the current Vector3
  2563. */
  2564. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2565. /**
  2566. * Subtract the given vector from the current Vector3
  2567. * @param otherVector defines the second operand
  2568. * @returns the current updated Vector3
  2569. */
  2570. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2571. /**
  2572. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the resulting Vector3
  2575. */
  2576. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2579. * @param otherVector defines the second operand
  2580. * @param result defines the Vector3 object where to store the result
  2581. * @returns the current Vector3
  2582. */
  2583. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2584. /**
  2585. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2586. * @param x defines the x coordinate of the operand
  2587. * @param y defines the y coordinate of the operand
  2588. * @param z defines the z coordinate of the operand
  2589. * @returns the resulting Vector3
  2590. */
  2591. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2592. /**
  2593. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2594. * @param x defines the x coordinate of the operand
  2595. * @param y defines the y coordinate of the operand
  2596. * @param z defines the z coordinate of the operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2601. /**
  2602. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2603. * @returns a new Vector3
  2604. */
  2605. negate(): Vector3;
  2606. /**
  2607. * Negate this vector in place
  2608. * @returns this
  2609. */
  2610. negateInPlace(): Vector3;
  2611. /**
  2612. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2613. * @param result defines the Vector3 object where to store the result
  2614. * @returns the current Vector3
  2615. */
  2616. negateToRef(result: Vector3): Vector3;
  2617. /**
  2618. * Multiplies the Vector3 coordinates by the float "scale"
  2619. * @param scale defines the multiplier factor
  2620. * @returns the current updated Vector3
  2621. */
  2622. scaleInPlace(scale: number): Vector3;
  2623. /**
  2624. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns a new Vector3
  2627. */
  2628. scale(scale: number): Vector3;
  2629. /**
  2630. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2631. * @param scale defines the multiplier factor
  2632. * @param result defines the Vector3 object where to store the result
  2633. * @returns the current Vector3
  2634. */
  2635. scaleToRef(scale: number, result: Vector3): Vector3;
  2636. /**
  2637. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2638. * @param scale defines the scale factor
  2639. * @param result defines the Vector3 object where to store the result
  2640. * @returns the unmodified current Vector3
  2641. */
  2642. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2643. /**
  2644. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2645. * @param origin defines the origin of the projection ray
  2646. * @param plane defines the plane to project to
  2647. * @returns the projected vector3
  2648. */
  2649. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2650. /**
  2651. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2652. * @param origin defines the origin of the projection ray
  2653. * @param plane defines the plane to project to
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2657. /**
  2658. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2659. * @param otherVector defines the second operand
  2660. * @returns true if both vectors are equals
  2661. */
  2662. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2665. * @param otherVector defines the second operand
  2666. * @param epsilon defines the minimal distance to define values as equals
  2667. * @returns true if both vectors are distant less than epsilon
  2668. */
  2669. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2670. /**
  2671. * Returns true if the current Vector3 coordinates equals the given floats
  2672. * @param x defines the x coordinate of the operand
  2673. * @param y defines the y coordinate of the operand
  2674. * @param z defines the z coordinate of the operand
  2675. * @returns true if both vectors are equals
  2676. */
  2677. equalsToFloats(x: number, y: number, z: number): boolean;
  2678. /**
  2679. * Multiplies the current Vector3 coordinates by the given ones
  2680. * @param otherVector defines the second operand
  2681. * @returns the current updated Vector3
  2682. */
  2683. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2684. /**
  2685. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2686. * @param otherVector defines the second operand
  2687. * @returns the new Vector3
  2688. */
  2689. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2692. * @param otherVector defines the second operand
  2693. * @param result defines the Vector3 object where to store the result
  2694. * @returns the current Vector3
  2695. */
  2696. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2697. /**
  2698. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2699. * @param x defines the x coordinate of the operand
  2700. * @param y defines the y coordinate of the operand
  2701. * @param z defines the z coordinate of the operand
  2702. * @returns the new Vector3
  2703. */
  2704. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2705. /**
  2706. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2707. * @param otherVector defines the second operand
  2708. * @returns the new Vector3
  2709. */
  2710. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2711. /**
  2712. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2713. * @param otherVector defines the second operand
  2714. * @param result defines the Vector3 object where to store the result
  2715. * @returns the current Vector3
  2716. */
  2717. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2718. /**
  2719. * Divides the current Vector3 coordinates by the given ones.
  2720. * @param otherVector defines the second operand
  2721. * @returns the current updated Vector3
  2722. */
  2723. divideInPlace(otherVector: Vector3): Vector3;
  2724. /**
  2725. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2726. * @param other defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2738. * @param x defines the x coordinate of the operand
  2739. * @param y defines the y coordinate of the operand
  2740. * @param z defines the z coordinate of the operand
  2741. * @returns the current updated Vector3
  2742. */
  2743. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2744. /**
  2745. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2746. * @param x defines the x coordinate of the operand
  2747. * @param y defines the y coordinate of the operand
  2748. * @param z defines the z coordinate of the operand
  2749. * @returns the current updated Vector3
  2750. */
  2751. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2752. /**
  2753. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2754. * Check if is non uniform within a certain amount of decimal places to account for this
  2755. * @param epsilon the amount the values can differ
  2756. * @returns if the the vector is non uniform to a certain number of decimal places
  2757. */
  2758. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2759. /**
  2760. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2761. */
  2762. get isNonUniform(): boolean;
  2763. /**
  2764. * Gets a new Vector3 from current Vector3 floored values
  2765. * @returns a new Vector3
  2766. */
  2767. floor(): Vector3;
  2768. /**
  2769. * Gets a new Vector3 from current Vector3 floored values
  2770. * @returns a new Vector3
  2771. */
  2772. fract(): Vector3;
  2773. /**
  2774. * Gets the length of the Vector3
  2775. * @returns the length of the Vector3
  2776. */
  2777. length(): number;
  2778. /**
  2779. * Gets the squared length of the Vector3
  2780. * @returns squared length of the Vector3
  2781. */
  2782. lengthSquared(): number;
  2783. /**
  2784. * Normalize the current Vector3.
  2785. * Please note that this is an in place operation.
  2786. * @returns the current updated Vector3
  2787. */
  2788. normalize(): Vector3;
  2789. /**
  2790. * Reorders the x y z properties of the vector in place
  2791. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2792. * @returns the current updated vector
  2793. */
  2794. reorderInPlace(order: string): this;
  2795. /**
  2796. * Rotates the vector around 0,0,0 by a quaternion
  2797. * @param quaternion the rotation quaternion
  2798. * @param result vector to store the result
  2799. * @returns the resulting vector
  2800. */
  2801. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2802. /**
  2803. * Rotates a vector around a given point
  2804. * @param quaternion the rotation quaternion
  2805. * @param point the point to rotate around
  2806. * @param result vector to store the result
  2807. * @returns the resulting vector
  2808. */
  2809. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2810. /**
  2811. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2812. * The cross product is then orthogonal to both current and "other"
  2813. * @param other defines the right operand
  2814. * @returns the cross product
  2815. */
  2816. cross(other: Vector3): Vector3;
  2817. /**
  2818. * Normalize the current Vector3 with the given input length.
  2819. * Please note that this is an in place operation.
  2820. * @param len the length of the vector
  2821. * @returns the current updated Vector3
  2822. */
  2823. normalizeFromLength(len: number): Vector3;
  2824. /**
  2825. * Normalize the current Vector3 to a new vector
  2826. * @returns the new Vector3
  2827. */
  2828. normalizeToNew(): Vector3;
  2829. /**
  2830. * Normalize the current Vector3 to the reference
  2831. * @param reference define the Vector3 to update
  2832. * @returns the updated Vector3
  2833. */
  2834. normalizeToRef(reference: Vector3): Vector3;
  2835. /**
  2836. * Creates a new Vector3 copied from the current Vector3
  2837. * @returns the new Vector3
  2838. */
  2839. clone(): Vector3;
  2840. /**
  2841. * Copies the given vector coordinates to the current Vector3 ones
  2842. * @param source defines the source Vector3
  2843. * @returns the current updated Vector3
  2844. */
  2845. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2846. /**
  2847. * Copies the given floats to the current Vector3 coordinates
  2848. * @param x defines the x coordinate of the operand
  2849. * @param y defines the y coordinate of the operand
  2850. * @param z defines the z coordinate of the operand
  2851. * @returns the current updated Vector3
  2852. */
  2853. copyFromFloats(x: number, y: number, z: number): Vector3;
  2854. /**
  2855. * Copies the given floats to the current Vector3 coordinates
  2856. * @param x defines the x coordinate of the operand
  2857. * @param y defines the y coordinate of the operand
  2858. * @param z defines the z coordinate of the operand
  2859. * @returns the current updated Vector3
  2860. */
  2861. set(x: number, y: number, z: number): Vector3;
  2862. /**
  2863. * Copies the given float to the current Vector3 coordinates
  2864. * @param v defines the x, y and z coordinates of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. setAll(v: number): Vector3;
  2868. /**
  2869. * Get the clip factor between two vectors
  2870. * @param vector0 defines the first operand
  2871. * @param vector1 defines the second operand
  2872. * @param axis defines the axis to use
  2873. * @param size defines the size along the axis
  2874. * @returns the clip factor
  2875. */
  2876. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2877. /**
  2878. * Get angle between two vectors
  2879. * @param vector0 angle between vector0 and vector1
  2880. * @param vector1 angle between vector0 and vector1
  2881. * @param normal direction of the normal
  2882. * @return the angle between vector0 and vector1
  2883. */
  2884. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2885. /**
  2886. * Returns a new Vector3 set from the index "offset" of the given array
  2887. * @param array defines the source array
  2888. * @param offset defines the offset in the source array
  2889. * @returns the new Vector3
  2890. */
  2891. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2892. /**
  2893. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2894. * @param array defines the source array
  2895. * @param offset defines the offset in the source array
  2896. * @returns the new Vector3
  2897. * @deprecated Please use FromArray instead.
  2898. */
  2899. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2900. /**
  2901. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2902. * @param array defines the source array
  2903. * @param offset defines the offset in the source array
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2907. /**
  2908. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2909. * @param array defines the source array
  2910. * @param offset defines the offset in the source array
  2911. * @param result defines the Vector3 where to store the result
  2912. * @deprecated Please use FromArrayToRef instead.
  2913. */
  2914. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2915. /**
  2916. * Sets the given vector "result" with the given floats.
  2917. * @param x defines the x coordinate of the source
  2918. * @param y defines the y coordinate of the source
  2919. * @param z defines the z coordinate of the source
  2920. * @param result defines the Vector3 where to store the result
  2921. */
  2922. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2923. /**
  2924. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2925. * @returns a new empty Vector3
  2926. */
  2927. static Zero(): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2930. * @returns a new unit Vector3
  2931. */
  2932. static One(): Vector3;
  2933. /**
  2934. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2935. * @returns a new up Vector3
  2936. */
  2937. static Up(): Vector3;
  2938. /**
  2939. * Gets a up Vector3 that must not be updated
  2940. */
  2941. static get UpReadOnly(): DeepImmutable<Vector3>;
  2942. /**
  2943. * Gets a zero Vector3 that must not be updated
  2944. */
  2945. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2946. /**
  2947. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2948. * @returns a new down Vector3
  2949. */
  2950. static Down(): Vector3;
  2951. /**
  2952. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2953. * @param rightHandedSystem is the scene right-handed (negative z)
  2954. * @returns a new forward Vector3
  2955. */
  2956. static Forward(rightHandedSystem?: boolean): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative-z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Backward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2965. * @returns a new right Vector3
  2966. */
  2967. static Right(): Vector3;
  2968. /**
  2969. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2970. * @returns a new left Vector3
  2971. */
  2972. static Left(): Vector3;
  2973. /**
  2974. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2975. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2976. * @param vector defines the Vector3 to transform
  2977. * @param transformation defines the transformation matrix
  2978. * @returns the transformed Vector3
  2979. */
  2980. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2983. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2984. * @param vector defines the Vector3 to transform
  2985. * @param transformation defines the transformation matrix
  2986. * @param result defines the Vector3 where to store the result
  2987. */
  2988. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2989. /**
  2990. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2991. * This method computes tranformed coordinates only, not transformed direction vectors
  2992. * @param x define the x coordinate of the source vector
  2993. * @param y define the y coordinate of the source vector
  2994. * @param z define the z coordinate of the source vector
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3001. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3002. * @param vector defines the Vector3 to transform
  3003. * @param transformation defines the transformation matrix
  3004. * @returns the new Vector3
  3005. */
  3006. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3007. /**
  3008. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3009. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3010. * @param vector defines the Vector3 to transform
  3011. * @param transformation defines the transformation matrix
  3012. * @param result defines the Vector3 where to store the result
  3013. */
  3014. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3015. /**
  3016. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3017. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3018. * @param x define the x coordinate of the source vector
  3019. * @param y define the y coordinate of the source vector
  3020. * @param z define the z coordinate of the source vector
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3027. * @param value1 defines the first control point
  3028. * @param value2 defines the second control point
  3029. * @param value3 defines the third control point
  3030. * @param value4 defines the fourth control point
  3031. * @param amount defines the amount on the spline to use
  3032. * @returns the new Vector3
  3033. */
  3034. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3035. /**
  3036. * 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"
  3037. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3038. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3039. * @param value defines the current value
  3040. * @param min defines the lower range value
  3041. * @param max defines the upper range value
  3042. * @returns the new Vector3
  3043. */
  3044. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3045. /**
  3046. * 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"
  3047. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3048. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3049. * @param value defines the current value
  3050. * @param min defines the lower range value
  3051. * @param max defines the upper range value
  3052. * @param result defines the Vector3 where to store the result
  3053. */
  3054. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3055. /**
  3056. * Checks if a given vector is inside a specific range
  3057. * @param v defines the vector to test
  3058. * @param min defines the minimum range
  3059. * @param max defines the maximum range
  3060. */
  3061. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3062. /**
  3063. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3064. * @param value1 defines the first control point
  3065. * @param tangent1 defines the first tangent vector
  3066. * @param value2 defines the second control point
  3067. * @param tangent2 defines the second tangent vector
  3068. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3069. * @returns the new Vector3
  3070. */
  3071. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3072. /**
  3073. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3074. * @param start defines the start value
  3075. * @param end defines the end value
  3076. * @param amount max defines amount between both (between 0 and 1)
  3077. * @returns the new Vector3
  3078. */
  3079. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3080. /**
  3081. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3082. * @param start defines the start value
  3083. * @param end defines the end value
  3084. * @param amount max defines amount between both (between 0 and 1)
  3085. * @param result defines the Vector3 where to store the result
  3086. */
  3087. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3088. /**
  3089. * Returns the dot product (float) between the vectors "left" and "right"
  3090. * @param left defines the left operand
  3091. * @param right defines the right operand
  3092. * @returns the dot product
  3093. */
  3094. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3095. /**
  3096. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3097. * The cross product is then orthogonal to both "left" and "right"
  3098. * @param left defines the left operand
  3099. * @param right defines the right operand
  3100. * @returns the cross product
  3101. */
  3102. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3103. /**
  3104. * Sets the given vector "result" with the cross product of "left" and "right"
  3105. * The cross product is then orthogonal to both "left" and "right"
  3106. * @param left defines the left operand
  3107. * @param right defines the right operand
  3108. * @param result defines the Vector3 where to store the result
  3109. */
  3110. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3111. /**
  3112. * Returns a new Vector3 as the normalization of the given vector
  3113. * @param vector defines the Vector3 to normalize
  3114. * @returns the new Vector3
  3115. */
  3116. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3117. /**
  3118. * Sets the given vector "result" with the normalization of the given first vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @param result defines the Vector3 where to store the result
  3121. */
  3122. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3123. /**
  3124. * Project a Vector3 onto screen space
  3125. * @param vector defines the Vector3 to project
  3126. * @param world defines the world matrix to use
  3127. * @param transform defines the transform (view x projection) matrix to use
  3128. * @param viewport defines the screen viewport to use
  3129. * @returns the new Vector3
  3130. */
  3131. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3132. /** @hidden */
  3133. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3134. /**
  3135. * Unproject from screen space to object space
  3136. * @param source defines the screen space Vector3 to use
  3137. * @param viewportWidth defines the current width of the viewport
  3138. * @param viewportHeight defines the current height of the viewport
  3139. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3140. * @param transform defines the transform (view x projection) matrix to use
  3141. * @returns the new Vector3
  3142. */
  3143. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3144. /**
  3145. * Unproject from screen space to object space
  3146. * @param source defines the screen space Vector3 to use
  3147. * @param viewportWidth defines the current width of the viewport
  3148. * @param viewportHeight defines the current height of the viewport
  3149. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3150. * @param view defines the view matrix to use
  3151. * @param projection defines the projection matrix to use
  3152. * @returns the new Vector3
  3153. */
  3154. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3155. /**
  3156. * Unproject from screen space to object space
  3157. * @param source defines the screen space Vector3 to use
  3158. * @param viewportWidth defines the current width of the viewport
  3159. * @param viewportHeight defines the current height of the viewport
  3160. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3161. * @param view defines the view matrix to use
  3162. * @param projection defines the projection matrix to use
  3163. * @param result defines the Vector3 where to store the result
  3164. */
  3165. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param sourceX defines the screen space x coordinate to use
  3169. * @param sourceY defines the screen space y coordinate to use
  3170. * @param sourceZ defines the screen space z coordinate to use
  3171. * @param viewportWidth defines the current width of the viewport
  3172. * @param viewportHeight defines the current height of the viewport
  3173. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3174. * @param view defines the view matrix to use
  3175. * @param projection defines the projection matrix to use
  3176. * @param result defines the Vector3 where to store the result
  3177. */
  3178. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3179. /**
  3180. * Gets the minimal coordinate values between two Vector3
  3181. * @param left defines the first operand
  3182. * @param right defines the second operand
  3183. * @returns the new Vector3
  3184. */
  3185. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3186. /**
  3187. * Gets the maximal coordinate values between two Vector3
  3188. * @param left defines the first operand
  3189. * @param right defines the second operand
  3190. * @returns the new Vector3
  3191. */
  3192. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3193. /**
  3194. * Returns the distance between the vectors "value1" and "value2"
  3195. * @param value1 defines the first operand
  3196. * @param value2 defines the second operand
  3197. * @returns the distance
  3198. */
  3199. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3200. /**
  3201. * Returns the squared distance between the vectors "value1" and "value2"
  3202. * @param value1 defines the first operand
  3203. * @param value2 defines the second operand
  3204. * @returns the squared distance
  3205. */
  3206. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3207. /**
  3208. * Returns a new Vector3 located at the center between "value1" and "value2"
  3209. * @param value1 defines the first operand
  3210. * @param value2 defines the second operand
  3211. * @returns the new Vector3
  3212. */
  3213. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3214. /**
  3215. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3216. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3217. * to something in order to rotate it from its local system to the given target system
  3218. * Note: axis1, axis2 and axis3 are normalized during this operation
  3219. * @param axis1 defines the first axis
  3220. * @param axis2 defines the second axis
  3221. * @param axis3 defines the third axis
  3222. * @returns a new Vector3
  3223. */
  3224. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3227. * @param axis1 defines the first axis
  3228. * @param axis2 defines the second axis
  3229. * @param axis3 defines the third axis
  3230. * @param ref defines the Vector3 where to store the result
  3231. */
  3232. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3233. }
  3234. /**
  3235. * Vector4 class created for EulerAngle class conversion to Quaternion
  3236. */
  3237. export class Vector4 {
  3238. /** x value of the vector */
  3239. x: number;
  3240. /** y value of the vector */
  3241. y: number;
  3242. /** z value of the vector */
  3243. z: number;
  3244. /** w value of the vector */
  3245. w: number;
  3246. /**
  3247. * Creates a Vector4 object from the given floats.
  3248. * @param x x value of the vector
  3249. * @param y y value of the vector
  3250. * @param z z value of the vector
  3251. * @param w w value of the vector
  3252. */
  3253. constructor(
  3254. /** x value of the vector */
  3255. x: number,
  3256. /** y value of the vector */
  3257. y: number,
  3258. /** z value of the vector */
  3259. z: number,
  3260. /** w value of the vector */
  3261. w: number);
  3262. /**
  3263. * Returns the string with the Vector4 coordinates.
  3264. * @returns a string containing all the vector values
  3265. */
  3266. toString(): string;
  3267. /**
  3268. * Returns the string "Vector4".
  3269. * @returns "Vector4"
  3270. */
  3271. getClassName(): string;
  3272. /**
  3273. * Returns the Vector4 hash code.
  3274. * @returns a unique hash code
  3275. */
  3276. getHashCode(): number;
  3277. /**
  3278. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3279. * @returns the resulting array
  3280. */
  3281. asArray(): number[];
  3282. /**
  3283. * Populates the given array from the given index with the Vector4 coordinates.
  3284. * @param array array to populate
  3285. * @param index index of the array to start at (default: 0)
  3286. * @returns the Vector4.
  3287. */
  3288. toArray(array: FloatArray, index?: number): Vector4;
  3289. /**
  3290. * Update the current vector from an array
  3291. * @param array defines the destination array
  3292. * @param index defines the offset in the destination array
  3293. * @returns the current Vector3
  3294. */
  3295. fromArray(array: FloatArray, index?: number): Vector4;
  3296. /**
  3297. * Adds the given vector to the current Vector4.
  3298. * @param otherVector the vector to add
  3299. * @returns the updated Vector4.
  3300. */
  3301. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3302. /**
  3303. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3304. * @param otherVector the vector to add
  3305. * @returns the resulting vector
  3306. */
  3307. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3308. /**
  3309. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3310. * @param otherVector the vector to add
  3311. * @param result the vector to store the result
  3312. * @returns the current Vector4.
  3313. */
  3314. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3315. /**
  3316. * Subtract in place the given vector from the current Vector4.
  3317. * @param otherVector the vector to subtract
  3318. * @returns the updated Vector4.
  3319. */
  3320. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3321. /**
  3322. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3323. * @param otherVector the vector to add
  3324. * @returns the new vector with the result
  3325. */
  3326. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3327. /**
  3328. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3329. * @param otherVector the vector to subtract
  3330. * @param result the vector to store the result
  3331. * @returns the current Vector4.
  3332. */
  3333. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3334. /**
  3335. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3336. */
  3337. /**
  3338. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3339. * @param x value to subtract
  3340. * @param y value to subtract
  3341. * @param z value to subtract
  3342. * @param w value to subtract
  3343. * @returns new vector containing the result
  3344. */
  3345. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3346. /**
  3347. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3348. * @param x value to subtract
  3349. * @param y value to subtract
  3350. * @param z value to subtract
  3351. * @param w value to subtract
  3352. * @param result the vector to store the result in
  3353. * @returns the current Vector4.
  3354. */
  3355. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3358. * @returns a new vector with the negated values
  3359. */
  3360. negate(): Vector4;
  3361. /**
  3362. * Negate this vector in place
  3363. * @returns this
  3364. */
  3365. negateInPlace(): Vector4;
  3366. /**
  3367. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3368. * @param result defines the Vector3 object where to store the result
  3369. * @returns the current Vector4
  3370. */
  3371. negateToRef(result: Vector4): Vector4;
  3372. /**
  3373. * Multiplies the current Vector4 coordinates by scale (float).
  3374. * @param scale the number to scale with
  3375. * @returns the updated Vector4.
  3376. */
  3377. scaleInPlace(scale: number): Vector4;
  3378. /**
  3379. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3380. * @param scale the number to scale with
  3381. * @returns a new vector with the result
  3382. */
  3383. scale(scale: number): Vector4;
  3384. /**
  3385. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3386. * @param scale the number to scale with
  3387. * @param result a vector to store the result in
  3388. * @returns the current Vector4.
  3389. */
  3390. scaleToRef(scale: number, result: Vector4): Vector4;
  3391. /**
  3392. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3393. * @param scale defines the scale factor
  3394. * @param result defines the Vector4 object where to store the result
  3395. * @returns the unmodified current Vector4
  3396. */
  3397. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3398. /**
  3399. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3400. * @param otherVector the vector to compare against
  3401. * @returns true if they are equal
  3402. */
  3403. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3404. /**
  3405. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3406. * @param otherVector vector to compare against
  3407. * @param epsilon (Default: very small number)
  3408. * @returns true if they are equal
  3409. */
  3410. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3411. /**
  3412. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3413. * @param x x value to compare against
  3414. * @param y y value to compare against
  3415. * @param z z value to compare against
  3416. * @param w w value to compare against
  3417. * @returns true if equal
  3418. */
  3419. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3420. /**
  3421. * Multiplies in place the current Vector4 by the given one.
  3422. * @param otherVector vector to multiple with
  3423. * @returns the updated Vector4.
  3424. */
  3425. multiplyInPlace(otherVector: Vector4): Vector4;
  3426. /**
  3427. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3428. * @param otherVector vector to multiple with
  3429. * @returns resulting new vector
  3430. */
  3431. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3432. /**
  3433. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3434. * @param otherVector vector to multiple with
  3435. * @param result vector to store the result
  3436. * @returns the current Vector4.
  3437. */
  3438. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3439. /**
  3440. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3441. * @param x x value multiply with
  3442. * @param y y value multiply with
  3443. * @param z z value multiply with
  3444. * @param w w value multiply with
  3445. * @returns resulting new vector
  3446. */
  3447. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3448. /**
  3449. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3450. * @param otherVector vector to devide with
  3451. * @returns resulting new vector
  3452. */
  3453. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3454. /**
  3455. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3456. * @param otherVector vector to devide with
  3457. * @param result vector to store the result
  3458. * @returns the current Vector4.
  3459. */
  3460. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3461. /**
  3462. * Divides the current Vector3 coordinates by the given ones.
  3463. * @param otherVector vector to devide with
  3464. * @returns the updated Vector3.
  3465. */
  3466. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3467. /**
  3468. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3469. * @param other defines the second operand
  3470. * @returns the current updated Vector4
  3471. */
  3472. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3475. * @param other defines the second operand
  3476. * @returns the current updated Vector4
  3477. */
  3478. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Gets a new Vector4 from current Vector4 floored values
  3481. * @returns a new Vector4
  3482. */
  3483. floor(): Vector4;
  3484. /**
  3485. * Gets a new Vector4 from current Vector3 floored values
  3486. * @returns a new Vector4
  3487. */
  3488. fract(): Vector4;
  3489. /**
  3490. * Returns the Vector4 length (float).
  3491. * @returns the length
  3492. */
  3493. length(): number;
  3494. /**
  3495. * Returns the Vector4 squared length (float).
  3496. * @returns the length squared
  3497. */
  3498. lengthSquared(): number;
  3499. /**
  3500. * Normalizes in place the Vector4.
  3501. * @returns the updated Vector4.
  3502. */
  3503. normalize(): Vector4;
  3504. /**
  3505. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3506. * @returns this converted to a new vector3
  3507. */
  3508. toVector3(): Vector3;
  3509. /**
  3510. * Returns a new Vector4 copied from the current one.
  3511. * @returns the new cloned vector
  3512. */
  3513. clone(): Vector4;
  3514. /**
  3515. * Updates the current Vector4 with the given one coordinates.
  3516. * @param source the source vector to copy from
  3517. * @returns the updated Vector4.
  3518. */
  3519. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3520. /**
  3521. * Updates the current Vector4 coordinates with the given floats.
  3522. * @param x float to copy from
  3523. * @param y float to copy from
  3524. * @param z float to copy from
  3525. * @param w float to copy from
  3526. * @returns the updated Vector4.
  3527. */
  3528. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3529. /**
  3530. * Updates the current Vector4 coordinates with the given floats.
  3531. * @param x float to set from
  3532. * @param y float to set from
  3533. * @param z float to set from
  3534. * @param w float to set from
  3535. * @returns the updated Vector4.
  3536. */
  3537. set(x: number, y: number, z: number, w: number): Vector4;
  3538. /**
  3539. * Copies the given float to the current Vector3 coordinates
  3540. * @param v defines the x, y, z and w coordinates of the operand
  3541. * @returns the current updated Vector3
  3542. */
  3543. setAll(v: number): Vector4;
  3544. /**
  3545. * Returns a new Vector4 set from the starting index of the given array.
  3546. * @param array the array to pull values from
  3547. * @param offset the offset into the array to start at
  3548. * @returns the new vector
  3549. */
  3550. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3551. /**
  3552. * Updates the given vector "result" from the starting index of the given array.
  3553. * @param array the array to pull values from
  3554. * @param offset the offset into the array to start at
  3555. * @param result the vector to store the result in
  3556. */
  3557. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3558. /**
  3559. * Updates the given vector "result" from the starting index of the given Float32Array.
  3560. * @param array the array to pull values from
  3561. * @param offset the offset into the array to start at
  3562. * @param result the vector to store the result in
  3563. */
  3564. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3565. /**
  3566. * Updates the given vector "result" coordinates from the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @param result the vector to the floats in
  3572. */
  3573. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3574. /**
  3575. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3576. * @returns the new vector
  3577. */
  3578. static Zero(): Vector4;
  3579. /**
  3580. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3581. * @returns the new vector
  3582. */
  3583. static One(): Vector4;
  3584. /**
  3585. * Returns a new normalized Vector4 from the given one.
  3586. * @param vector the vector to normalize
  3587. * @returns the vector
  3588. */
  3589. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3590. /**
  3591. * Updates the given vector "result" from the normalization of the given one.
  3592. * @param vector the vector to normalize
  3593. * @param result the vector to store the result in
  3594. */
  3595. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3596. /**
  3597. * Returns a vector with the minimum values from the left and right vectors
  3598. * @param left left vector to minimize
  3599. * @param right right vector to minimize
  3600. * @returns a new vector with the minimum of the left and right vector values
  3601. */
  3602. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3603. /**
  3604. * Returns a vector with the maximum values from the left and right vectors
  3605. * @param left left vector to maximize
  3606. * @param right right vector to maximize
  3607. * @returns a new vector with the maximum of the left and right vector values
  3608. */
  3609. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3610. /**
  3611. * Returns the distance (float) between the vectors "value1" and "value2".
  3612. * @param value1 value to calulate the distance between
  3613. * @param value2 value to calulate the distance between
  3614. * @return the distance between the two vectors
  3615. */
  3616. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3617. /**
  3618. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3619. * @param value1 value to calulate the distance between
  3620. * @param value2 value to calulate the distance between
  3621. * @return the distance between the two vectors squared
  3622. */
  3623. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3624. /**
  3625. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3626. * @param value1 value to calulate the center between
  3627. * @param value2 value to calulate the center between
  3628. * @return the center between the two vectors
  3629. */
  3630. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3631. /**
  3632. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3633. * This methods computes transformed normalized direction vectors only.
  3634. * @param vector the vector to transform
  3635. * @param transformation the transformation matrix to apply
  3636. * @returns the new vector
  3637. */
  3638. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3639. /**
  3640. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3641. * This methods computes transformed normalized direction vectors only.
  3642. * @param vector the vector to transform
  3643. * @param transformation the transformation matrix to apply
  3644. * @param result the vector to store the result in
  3645. */
  3646. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3647. /**
  3648. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3649. * This methods computes transformed normalized direction vectors only.
  3650. * @param x value to transform
  3651. * @param y value to transform
  3652. * @param z value to transform
  3653. * @param w value to transform
  3654. * @param transformation the transformation matrix to apply
  3655. * @param result the vector to store the results in
  3656. */
  3657. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3658. /**
  3659. * Creates a new Vector4 from a Vector3
  3660. * @param source defines the source data
  3661. * @param w defines the 4th component (default is 0)
  3662. * @returns a new Vector4
  3663. */
  3664. static FromVector3(source: Vector3, w?: number): Vector4;
  3665. }
  3666. /**
  3667. * Class used to store quaternion data
  3668. * @see https://en.wikipedia.org/wiki/Quaternion
  3669. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3670. */
  3671. export class Quaternion {
  3672. /** @hidden */
  3673. _x: number;
  3674. /** @hidden */
  3675. _y: number;
  3676. /** @hidden */
  3677. _z: number;
  3678. /** @hidden */
  3679. _w: number;
  3680. /** @hidden */
  3681. _isDirty: boolean;
  3682. /** Gets or sets the x coordinate */
  3683. get x(): number;
  3684. set x(value: number);
  3685. /** Gets or sets the y coordinate */
  3686. get y(): number;
  3687. set y(value: number);
  3688. /** Gets or sets the z coordinate */
  3689. get z(): number;
  3690. set z(value: number);
  3691. /** Gets or sets the w coordinate */
  3692. get w(): number;
  3693. set w(value: number);
  3694. /**
  3695. * Creates a new Quaternion from the given floats
  3696. * @param x defines the first component (0 by default)
  3697. * @param y defines the second component (0 by default)
  3698. * @param z defines the third component (0 by default)
  3699. * @param w defines the fourth component (1.0 by default)
  3700. */
  3701. constructor(x?: number, y?: number, z?: number, w?: number);
  3702. /**
  3703. * Gets a string representation for the current quaternion
  3704. * @returns a string with the Quaternion coordinates
  3705. */
  3706. toString(): string;
  3707. /**
  3708. * Gets the class name of the quaternion
  3709. * @returns the string "Quaternion"
  3710. */
  3711. getClassName(): string;
  3712. /**
  3713. * Gets a hash code for this quaternion
  3714. * @returns the quaternion hash code
  3715. */
  3716. getHashCode(): number;
  3717. /**
  3718. * Copy the quaternion to an array
  3719. * @returns a new array populated with 4 elements from the quaternion coordinates
  3720. */
  3721. asArray(): number[];
  3722. /**
  3723. * Check if two quaternions are equals
  3724. * @param otherQuaternion defines the second operand
  3725. * @return true if the current quaternion and the given one coordinates are strictly equals
  3726. */
  3727. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3730. * @param otherQuaternion defines the other quaternion
  3731. * @param epsilon defines the minimal distance to consider equality
  3732. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3733. */
  3734. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3735. /**
  3736. * Clone the current quaternion
  3737. * @returns a new quaternion copied from the current one
  3738. */
  3739. clone(): Quaternion;
  3740. /**
  3741. * Copy a quaternion to the current one
  3742. * @param other defines the other quaternion
  3743. * @returns the updated current quaternion
  3744. */
  3745. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3746. /**
  3747. * Updates the current quaternion with the given float coordinates
  3748. * @param x defines the x coordinate
  3749. * @param y defines the y coordinate
  3750. * @param z defines the z coordinate
  3751. * @param w defines the w coordinate
  3752. * @returns the updated current quaternion
  3753. */
  3754. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3755. /**
  3756. * Updates the current quaternion from the given float coordinates
  3757. * @param x defines the x coordinate
  3758. * @param y defines the y coordinate
  3759. * @param z defines the z coordinate
  3760. * @param w defines the w coordinate
  3761. * @returns the updated current quaternion
  3762. */
  3763. set(x: number, y: number, z: number, w: number): Quaternion;
  3764. /**
  3765. * Adds two quaternions
  3766. * @param other defines the second operand
  3767. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3768. */
  3769. add(other: DeepImmutable<Quaternion>): Quaternion;
  3770. /**
  3771. * Add a quaternion to the current one
  3772. * @param other defines the quaternion to add
  3773. * @returns the current quaternion
  3774. */
  3775. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3776. /**
  3777. * Subtract two quaternions
  3778. * @param other defines the second operand
  3779. * @returns a new quaternion as the subtraction result of the given one from the current one
  3780. */
  3781. subtract(other: Quaternion): Quaternion;
  3782. /**
  3783. * Multiplies the current quaternion by a scale factor
  3784. * @param value defines the scale factor
  3785. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3786. */
  3787. scale(value: number): Quaternion;
  3788. /**
  3789. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3790. * @param scale defines the scale factor
  3791. * @param result defines the Quaternion object where to store the result
  3792. * @returns the unmodified current quaternion
  3793. */
  3794. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3795. /**
  3796. * Multiplies in place the current quaternion by a scale factor
  3797. * @param value defines the scale factor
  3798. * @returns the current modified quaternion
  3799. */
  3800. scaleInPlace(value: number): Quaternion;
  3801. /**
  3802. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3803. * @param scale defines the scale factor
  3804. * @param result defines the Quaternion object where to store the result
  3805. * @returns the unmodified current quaternion
  3806. */
  3807. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3808. /**
  3809. * Multiplies two quaternions
  3810. * @param q1 defines the second operand
  3811. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3812. */
  3813. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3814. /**
  3815. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3816. * @param q1 defines the second operand
  3817. * @param result defines the target quaternion
  3818. * @returns the current quaternion
  3819. */
  3820. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3821. /**
  3822. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3823. * @param q1 defines the second operand
  3824. * @returns the currentupdated quaternion
  3825. */
  3826. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3827. /**
  3828. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3829. * @param ref defines the target quaternion
  3830. * @returns the current quaternion
  3831. */
  3832. conjugateToRef(ref: Quaternion): Quaternion;
  3833. /**
  3834. * Conjugates in place (1-q) the current quaternion
  3835. * @returns the current updated quaternion
  3836. */
  3837. conjugateInPlace(): Quaternion;
  3838. /**
  3839. * Conjugates in place (1-q) the current quaternion
  3840. * @returns a new quaternion
  3841. */
  3842. conjugate(): Quaternion;
  3843. /**
  3844. * Gets length of current quaternion
  3845. * @returns the quaternion length (float)
  3846. */
  3847. length(): number;
  3848. /**
  3849. * Normalize in place the current quaternion
  3850. * @returns the current updated quaternion
  3851. */
  3852. normalize(): Quaternion;
  3853. /**
  3854. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3855. * @param order is a reserved parameter and is ignored for now
  3856. * @returns a new Vector3 containing the Euler angles
  3857. */
  3858. toEulerAngles(order?: string): Vector3;
  3859. /**
  3860. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3861. * @param result defines the vector which will be filled with the Euler angles
  3862. * @returns the current unchanged quaternion
  3863. */
  3864. toEulerAnglesToRef(result: Vector3): Quaternion;
  3865. /**
  3866. * Updates the given rotation matrix with the current quaternion values
  3867. * @param result defines the target matrix
  3868. * @returns the current unchanged quaternion
  3869. */
  3870. toRotationMatrix(result: Matrix): Quaternion;
  3871. /**
  3872. * Updates the current quaternion from the given rotation matrix values
  3873. * @param matrix defines the source matrix
  3874. * @returns the current updated quaternion
  3875. */
  3876. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3877. /**
  3878. * Creates a new quaternion from a rotation matrix
  3879. * @param matrix defines the source matrix
  3880. * @returns a new quaternion created from the given rotation matrix values
  3881. */
  3882. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3883. /**
  3884. * Updates the given quaternion with the given rotation matrix values
  3885. * @param matrix defines the source matrix
  3886. * @param result defines the target quaternion
  3887. */
  3888. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3889. /**
  3890. * Returns the dot product (float) between the quaternions "left" and "right"
  3891. * @param left defines the left operand
  3892. * @param right defines the right operand
  3893. * @returns the dot product
  3894. */
  3895. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3896. /**
  3897. * Checks if the two quaternions are close to each other
  3898. * @param quat0 defines the first quaternion to check
  3899. * @param quat1 defines the second quaternion to check
  3900. * @returns true if the two quaternions are close to each other
  3901. */
  3902. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3903. /**
  3904. * Creates an empty quaternion
  3905. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3906. */
  3907. static Zero(): Quaternion;
  3908. /**
  3909. * Inverse a given quaternion
  3910. * @param q defines the source quaternion
  3911. * @returns a new quaternion as the inverted current quaternion
  3912. */
  3913. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3914. /**
  3915. * Inverse a given quaternion
  3916. * @param q defines the source quaternion
  3917. * @param result the quaternion the result will be stored in
  3918. * @returns the result quaternion
  3919. */
  3920. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3921. /**
  3922. * Creates an identity quaternion
  3923. * @returns the identity quaternion
  3924. */
  3925. static Identity(): Quaternion;
  3926. /**
  3927. * Gets a boolean indicating if the given quaternion is identity
  3928. * @param quaternion defines the quaternion to check
  3929. * @returns true if the quaternion is identity
  3930. */
  3931. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3932. /**
  3933. * Creates a quaternion from a rotation around an axis
  3934. * @param axis defines the axis to use
  3935. * @param angle defines the angle to use
  3936. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3937. */
  3938. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3939. /**
  3940. * Creates a rotation around an axis and stores it into the given quaternion
  3941. * @param axis defines the axis to use
  3942. * @param angle defines the angle to use
  3943. * @param result defines the target quaternion
  3944. * @returns the target quaternion
  3945. */
  3946. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3947. /**
  3948. * Creates a new quaternion from data stored into an array
  3949. * @param array defines the data source
  3950. * @param offset defines the offset in the source array where the data starts
  3951. * @returns a new quaternion
  3952. */
  3953. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3954. /**
  3955. * Updates the given quaternion "result" from the starting index of the given array.
  3956. * @param array the array to pull values from
  3957. * @param offset the offset into the array to start at
  3958. * @param result the quaternion to store the result in
  3959. */
  3960. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3961. /**
  3962. * Create a quaternion from Euler rotation angles
  3963. * @param x Pitch
  3964. * @param y Yaw
  3965. * @param z Roll
  3966. * @returns the new Quaternion
  3967. */
  3968. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3969. /**
  3970. * Updates a quaternion from Euler rotation angles
  3971. * @param x Pitch
  3972. * @param y Yaw
  3973. * @param z Roll
  3974. * @param result the quaternion to store the result
  3975. * @returns the updated quaternion
  3976. */
  3977. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3978. /**
  3979. * Create a quaternion from Euler rotation vector
  3980. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3981. * @returns the new Quaternion
  3982. */
  3983. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3984. /**
  3985. * Updates a quaternion from Euler rotation vector
  3986. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3987. * @param result the quaternion to store the result
  3988. * @returns the updated quaternion
  3989. */
  3990. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3991. /**
  3992. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3993. * @param yaw defines the rotation around Y axis
  3994. * @param pitch defines the rotation around X axis
  3995. * @param roll defines the rotation around Z axis
  3996. * @returns the new quaternion
  3997. */
  3998. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3999. /**
  4000. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4001. * @param yaw defines the rotation around Y axis
  4002. * @param pitch defines the rotation around X axis
  4003. * @param roll defines the rotation around Z axis
  4004. * @param result defines the target quaternion
  4005. */
  4006. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4007. /**
  4008. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4009. * @param alpha defines the rotation around first axis
  4010. * @param beta defines the rotation around second axis
  4011. * @param gamma defines the rotation around third axis
  4012. * @returns the new quaternion
  4013. */
  4014. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4015. /**
  4016. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4017. * @param alpha defines the rotation around first axis
  4018. * @param beta defines the rotation around second axis
  4019. * @param gamma defines the rotation around third axis
  4020. * @param result defines the target quaternion
  4021. */
  4022. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4023. /**
  4024. * 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)
  4025. * @param axis1 defines the first axis
  4026. * @param axis2 defines the second axis
  4027. * @param axis3 defines the third axis
  4028. * @returns the new quaternion
  4029. */
  4030. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4031. /**
  4032. * 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
  4033. * @param axis1 defines the first axis
  4034. * @param axis2 defines the second axis
  4035. * @param axis3 defines the third axis
  4036. * @param ref defines the target quaternion
  4037. */
  4038. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4039. /**
  4040. * Interpolates between two quaternions
  4041. * @param left defines first quaternion
  4042. * @param right defines second quaternion
  4043. * @param amount defines the gradient to use
  4044. * @returns the new interpolated quaternion
  4045. */
  4046. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4047. /**
  4048. * Interpolates between two quaternions and stores it into a target quaternion
  4049. * @param left defines first quaternion
  4050. * @param right defines second quaternion
  4051. * @param amount defines the gradient to use
  4052. * @param result defines the target quaternion
  4053. */
  4054. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4055. /**
  4056. * Interpolate between two quaternions using Hermite interpolation
  4057. * @param value1 defines first quaternion
  4058. * @param tangent1 defines the incoming tangent
  4059. * @param value2 defines second quaternion
  4060. * @param tangent2 defines the outgoing tangent
  4061. * @param amount defines the target quaternion
  4062. * @returns the new interpolated quaternion
  4063. */
  4064. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4065. }
  4066. /**
  4067. * Class used to store matrix data (4x4)
  4068. */
  4069. export class Matrix {
  4070. /**
  4071. * Gets the precision of matrix computations
  4072. */
  4073. static get Use64Bits(): boolean;
  4074. private static _updateFlagSeed;
  4075. private static _identityReadOnly;
  4076. private _isIdentity;
  4077. private _isIdentityDirty;
  4078. private _isIdentity3x2;
  4079. private _isIdentity3x2Dirty;
  4080. /**
  4081. * Gets the update flag of the matrix which is an unique number for the matrix.
  4082. * It will be incremented every time the matrix data change.
  4083. * You can use it to speed the comparison between two versions of the same matrix.
  4084. */
  4085. updateFlag: number;
  4086. private readonly _m;
  4087. /**
  4088. * Gets the internal data of the matrix
  4089. */
  4090. get m(): DeepImmutable<Float32Array | Array<number>>;
  4091. /** @hidden */
  4092. _markAsUpdated(): void;
  4093. /** @hidden */
  4094. private _updateIdentityStatus;
  4095. /**
  4096. * Creates an empty matrix (filled with zeros)
  4097. */
  4098. constructor();
  4099. /**
  4100. * Check if the current matrix is identity
  4101. * @returns true is the matrix is the identity matrix
  4102. */
  4103. isIdentity(): boolean;
  4104. /**
  4105. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4106. * @returns true is the matrix is the identity matrix
  4107. */
  4108. isIdentityAs3x2(): boolean;
  4109. /**
  4110. * Gets the determinant of the matrix
  4111. * @returns the matrix determinant
  4112. */
  4113. determinant(): number;
  4114. /**
  4115. * Returns the matrix as a Float32Array or Array<number>
  4116. * @returns the matrix underlying array
  4117. */
  4118. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4119. /**
  4120. * Returns the matrix as a Float32Array or Array<number>
  4121. * @returns the matrix underlying array.
  4122. */
  4123. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4124. /**
  4125. * Inverts the current matrix in place
  4126. * @returns the current inverted matrix
  4127. */
  4128. invert(): Matrix;
  4129. /**
  4130. * Sets all the matrix elements to zero
  4131. * @returns the current matrix
  4132. */
  4133. reset(): Matrix;
  4134. /**
  4135. * Adds the current matrix with a second one
  4136. * @param other defines the matrix to add
  4137. * @returns a new matrix as the addition of the current matrix and the given one
  4138. */
  4139. add(other: DeepImmutable<Matrix>): Matrix;
  4140. /**
  4141. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4142. * @param other defines the matrix to add
  4143. * @param result defines the target matrix
  4144. * @returns the current matrix
  4145. */
  4146. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4147. /**
  4148. * Adds in place the given matrix to the current matrix
  4149. * @param other defines the second operand
  4150. * @returns the current updated matrix
  4151. */
  4152. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4153. /**
  4154. * Sets the given matrix to the current inverted Matrix
  4155. * @param other defines the target matrix
  4156. * @returns the unmodified current matrix
  4157. */
  4158. invertToRef(other: Matrix): Matrix;
  4159. /**
  4160. * add a value at the specified position in the current Matrix
  4161. * @param index the index of the value within the matrix. between 0 and 15.
  4162. * @param value the value to be added
  4163. * @returns the current updated matrix
  4164. */
  4165. addAtIndex(index: number, value: number): Matrix;
  4166. /**
  4167. * mutiply the specified position in the current Matrix by a value
  4168. * @param index the index of the value within the matrix. between 0 and 15.
  4169. * @param value the value to be added
  4170. * @returns the current updated matrix
  4171. */
  4172. multiplyAtIndex(index: number, value: number): Matrix;
  4173. /**
  4174. * Inserts the translation vector (using 3 floats) in the current matrix
  4175. * @param x defines the 1st component of the translation
  4176. * @param y defines the 2nd component of the translation
  4177. * @param z defines the 3rd component of the translation
  4178. * @returns the current updated matrix
  4179. */
  4180. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4181. /**
  4182. * Adds the translation vector (using 3 floats) in the current matrix
  4183. * @param x defines the 1st component of the translation
  4184. * @param y defines the 2nd component of the translation
  4185. * @param z defines the 3rd component of the translation
  4186. * @returns the current updated matrix
  4187. */
  4188. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4189. /**
  4190. * Inserts the translation vector in the current matrix
  4191. * @param vector3 defines the translation to insert
  4192. * @returns the current updated matrix
  4193. */
  4194. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4195. /**
  4196. * Gets the translation value of the current matrix
  4197. * @returns a new Vector3 as the extracted translation from the matrix
  4198. */
  4199. getTranslation(): Vector3;
  4200. /**
  4201. * Fill a Vector3 with the extracted translation from the matrix
  4202. * @param result defines the Vector3 where to store the translation
  4203. * @returns the current matrix
  4204. */
  4205. getTranslationToRef(result: Vector3): Matrix;
  4206. /**
  4207. * Remove rotation and scaling part from the matrix
  4208. * @returns the updated matrix
  4209. */
  4210. removeRotationAndScaling(): Matrix;
  4211. /**
  4212. * Multiply two matrices
  4213. * @param other defines the second operand
  4214. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4215. */
  4216. multiply(other: DeepImmutable<Matrix>): Matrix;
  4217. /**
  4218. * Copy the current matrix from the given one
  4219. * @param other defines the source matrix
  4220. * @returns the current updated matrix
  4221. */
  4222. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4223. /**
  4224. * Populates the given array from the starting index with the current matrix values
  4225. * @param array defines the target array
  4226. * @param offset defines the offset in the target array where to start storing values
  4227. * @returns the current matrix
  4228. */
  4229. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4230. /**
  4231. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4232. * @param other defines the second operand
  4233. * @param result defines the matrix where to store the multiplication
  4234. * @returns the current matrix
  4235. */
  4236. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4237. /**
  4238. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4239. * @param other defines the second operand
  4240. * @param result defines the array where to store the multiplication
  4241. * @param offset defines the offset in the target array where to start storing values
  4242. * @returns the current matrix
  4243. */
  4244. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4245. /**
  4246. * Check equality between this matrix and a second one
  4247. * @param value defines the second matrix to compare
  4248. * @returns true is the current matrix and the given one values are strictly equal
  4249. */
  4250. equals(value: DeepImmutable<Matrix>): boolean;
  4251. /**
  4252. * Clone the current matrix
  4253. * @returns a new matrix from the current matrix
  4254. */
  4255. clone(): Matrix;
  4256. /**
  4257. * Returns the name of the current matrix class
  4258. * @returns the string "Matrix"
  4259. */
  4260. getClassName(): string;
  4261. /**
  4262. * Gets the hash code of the current matrix
  4263. * @returns the hash code
  4264. */
  4265. getHashCode(): number;
  4266. /**
  4267. * Decomposes the current Matrix into a translation, rotation and scaling components
  4268. * @param scale defines the scale vector3 given as a reference to update
  4269. * @param rotation defines the rotation quaternion given as a reference to update
  4270. * @param translation defines the translation vector3 given as a reference to update
  4271. * @returns true if operation was successful
  4272. */
  4273. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4274. /**
  4275. * Gets specific row of the matrix
  4276. * @param index defines the number of the row to get
  4277. * @returns the index-th row of the current matrix as a new Vector4
  4278. */
  4279. getRow(index: number): Nullable<Vector4>;
  4280. /**
  4281. * Sets the index-th row of the current matrix to the vector4 values
  4282. * @param index defines the number of the row to set
  4283. * @param row defines the target vector4
  4284. * @returns the updated current matrix
  4285. */
  4286. setRow(index: number, row: Vector4): Matrix;
  4287. /**
  4288. * Compute the transpose of the matrix
  4289. * @returns the new transposed matrix
  4290. */
  4291. transpose(): Matrix;
  4292. /**
  4293. * Compute the transpose of the matrix and store it in a given matrix
  4294. * @param result defines the target matrix
  4295. * @returns the current matrix
  4296. */
  4297. transposeToRef(result: Matrix): Matrix;
  4298. /**
  4299. * Sets the index-th row of the current matrix with the given 4 x float values
  4300. * @param index defines the row index
  4301. * @param x defines the x component to set
  4302. * @param y defines the y component to set
  4303. * @param z defines the z component to set
  4304. * @param w defines the w component to set
  4305. * @returns the updated current matrix
  4306. */
  4307. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4308. /**
  4309. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4310. * @param scale defines the scale factor
  4311. * @returns a new matrix
  4312. */
  4313. scale(scale: number): Matrix;
  4314. /**
  4315. * Scale the current matrix values by a factor to a given result matrix
  4316. * @param scale defines the scale factor
  4317. * @param result defines the matrix to store the result
  4318. * @returns the current matrix
  4319. */
  4320. scaleToRef(scale: number, result: Matrix): Matrix;
  4321. /**
  4322. * Scale the current matrix values by a factor and add the result to a given matrix
  4323. * @param scale defines the scale factor
  4324. * @param result defines the Matrix to store the result
  4325. * @returns the current matrix
  4326. */
  4327. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4328. /**
  4329. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4330. * @param ref matrix to store the result
  4331. */
  4332. toNormalMatrix(ref: Matrix): void;
  4333. /**
  4334. * Gets only rotation part of the current matrix
  4335. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4336. */
  4337. getRotationMatrix(): Matrix;
  4338. /**
  4339. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4340. * @param result defines the target matrix to store data to
  4341. * @returns the current matrix
  4342. */
  4343. getRotationMatrixToRef(result: Matrix): Matrix;
  4344. /**
  4345. * Toggles model matrix from being right handed to left handed in place and vice versa
  4346. */
  4347. toggleModelMatrixHandInPlace(): void;
  4348. /**
  4349. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4350. */
  4351. toggleProjectionMatrixHandInPlace(): void;
  4352. /**
  4353. * Creates a matrix from an array
  4354. * @param array defines the source array
  4355. * @param offset defines an offset in the source array
  4356. * @returns a new Matrix set from the starting index of the given array
  4357. */
  4358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4359. /**
  4360. * Copy the content of an array into a given matrix
  4361. * @param array defines the source array
  4362. * @param offset defines an offset in the source array
  4363. * @param result defines the target matrix
  4364. */
  4365. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4366. /**
  4367. * Stores an array into a matrix after having multiplied each component by a given factor
  4368. * @param array defines the source array
  4369. * @param offset defines the offset in the source array
  4370. * @param scale defines the scaling factor
  4371. * @param result defines the target matrix
  4372. */
  4373. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4374. /**
  4375. * Gets an identity matrix that must not be updated
  4376. */
  4377. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4378. /**
  4379. * Stores a list of values (16) inside a given matrix
  4380. * @param initialM11 defines 1st value of 1st row
  4381. * @param initialM12 defines 2nd value of 1st row
  4382. * @param initialM13 defines 3rd value of 1st row
  4383. * @param initialM14 defines 4th value of 1st row
  4384. * @param initialM21 defines 1st value of 2nd row
  4385. * @param initialM22 defines 2nd value of 2nd row
  4386. * @param initialM23 defines 3rd value of 2nd row
  4387. * @param initialM24 defines 4th value of 2nd row
  4388. * @param initialM31 defines 1st value of 3rd row
  4389. * @param initialM32 defines 2nd value of 3rd row
  4390. * @param initialM33 defines 3rd value of 3rd row
  4391. * @param initialM34 defines 4th value of 3rd row
  4392. * @param initialM41 defines 1st value of 4th row
  4393. * @param initialM42 defines 2nd value of 4th row
  4394. * @param initialM43 defines 3rd value of 4th row
  4395. * @param initialM44 defines 4th value of 4th row
  4396. * @param result defines the target matrix
  4397. */
  4398. 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;
  4399. /**
  4400. * Creates new matrix from a list of values (16)
  4401. * @param initialM11 defines 1st value of 1st row
  4402. * @param initialM12 defines 2nd value of 1st row
  4403. * @param initialM13 defines 3rd value of 1st row
  4404. * @param initialM14 defines 4th value of 1st row
  4405. * @param initialM21 defines 1st value of 2nd row
  4406. * @param initialM22 defines 2nd value of 2nd row
  4407. * @param initialM23 defines 3rd value of 2nd row
  4408. * @param initialM24 defines 4th value of 2nd row
  4409. * @param initialM31 defines 1st value of 3rd row
  4410. * @param initialM32 defines 2nd value of 3rd row
  4411. * @param initialM33 defines 3rd value of 3rd row
  4412. * @param initialM34 defines 4th value of 3rd row
  4413. * @param initialM41 defines 1st value of 4th row
  4414. * @param initialM42 defines 2nd value of 4th row
  4415. * @param initialM43 defines 3rd value of 4th row
  4416. * @param initialM44 defines 4th value of 4th row
  4417. * @returns the new matrix
  4418. */
  4419. 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;
  4420. /**
  4421. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4422. * @param scale defines the scale vector3
  4423. * @param rotation defines the rotation quaternion
  4424. * @param translation defines the translation vector3
  4425. * @returns a new matrix
  4426. */
  4427. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4428. /**
  4429. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4430. * @param scale defines the scale vector3
  4431. * @param rotation defines the rotation quaternion
  4432. * @param translation defines the translation vector3
  4433. * @param result defines the target matrix
  4434. */
  4435. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4436. /**
  4437. * Creates a new identity matrix
  4438. * @returns a new identity matrix
  4439. */
  4440. static Identity(): Matrix;
  4441. /**
  4442. * Creates a new identity matrix and stores the result in a given matrix
  4443. * @param result defines the target matrix
  4444. */
  4445. static IdentityToRef(result: Matrix): void;
  4446. /**
  4447. * Creates a new zero matrix
  4448. * @returns a new zero matrix
  4449. */
  4450. static Zero(): Matrix;
  4451. /**
  4452. * Creates a new rotation matrix for "angle" radians around the X axis
  4453. * @param angle defines the angle (in radians) to use
  4454. * @return the new matrix
  4455. */
  4456. static RotationX(angle: number): Matrix;
  4457. /**
  4458. * Creates a new matrix as the invert of a given matrix
  4459. * @param source defines the source matrix
  4460. * @returns the new matrix
  4461. */
  4462. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4463. /**
  4464. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4465. * @param angle defines the angle (in radians) to use
  4466. * @param result defines the target matrix
  4467. */
  4468. static RotationXToRef(angle: number, result: Matrix): void;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the Y axis
  4471. * @param angle defines the angle (in radians) to use
  4472. * @return the new matrix
  4473. */
  4474. static RotationY(angle: number): Matrix;
  4475. /**
  4476. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4477. * @param angle defines the angle (in radians) to use
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationYToRef(angle: number, result: Matrix): void;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the Z axis
  4483. * @param angle defines the angle (in radians) to use
  4484. * @return the new matrix
  4485. */
  4486. static RotationZ(angle: number): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4489. * @param angle defines the angle (in radians) to use
  4490. * @param result defines the target matrix
  4491. */
  4492. static RotationZToRef(angle: number, result: Matrix): void;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the given axis
  4495. * @param axis defines the axis to use
  4496. * @param angle defines the angle (in radians) to use
  4497. * @return the new matrix
  4498. */
  4499. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4500. /**
  4501. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4502. * @param axis defines the axis to use
  4503. * @param angle defines the angle (in radians) to use
  4504. * @param result defines the target matrix
  4505. */
  4506. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4507. /**
  4508. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4509. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4510. * @param from defines the vector to align
  4511. * @param to defines the vector to align to
  4512. * @param result defines the target matrix
  4513. */
  4514. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4515. /**
  4516. * Creates a rotation matrix
  4517. * @param yaw defines the yaw angle in radians (Y axis)
  4518. * @param pitch defines the pitch angle in radians (X axis)
  4519. * @param roll defines the roll angle in radians (Z axis)
  4520. * @returns the new rotation matrix
  4521. */
  4522. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4523. /**
  4524. * Creates a rotation matrix and stores it in a given matrix
  4525. * @param yaw defines the yaw angle in radians (Y axis)
  4526. * @param pitch defines the pitch angle in radians (X axis)
  4527. * @param roll defines the roll angle in radians (Z axis)
  4528. * @param result defines the target matrix
  4529. */
  4530. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4531. /**
  4532. * Creates a scaling matrix
  4533. * @param x defines the scale factor on X axis
  4534. * @param y defines the scale factor on Y axis
  4535. * @param z defines the scale factor on Z axis
  4536. * @returns the new matrix
  4537. */
  4538. static Scaling(x: number, y: number, z: number): Matrix;
  4539. /**
  4540. * Creates a scaling matrix and stores it in a given matrix
  4541. * @param x defines the scale factor on X axis
  4542. * @param y defines the scale factor on Y axis
  4543. * @param z defines the scale factor on Z axis
  4544. * @param result defines the target matrix
  4545. */
  4546. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4547. /**
  4548. * Creates a translation matrix
  4549. * @param x defines the translation on X axis
  4550. * @param y defines the translation on Y axis
  4551. * @param z defines the translationon Z axis
  4552. * @returns the new matrix
  4553. */
  4554. static Translation(x: number, y: number, z: number): Matrix;
  4555. /**
  4556. * Creates a translation matrix and stores it in a given matrix
  4557. * @param x defines the translation on X axis
  4558. * @param y defines the translation on Y axis
  4559. * @param z defines the translationon Z axis
  4560. * @param result defines the target matrix
  4561. */
  4562. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4563. /**
  4564. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4565. * @param startValue defines the start value
  4566. * @param endValue defines the end value
  4567. * @param gradient defines the gradient factor
  4568. * @returns the new matrix
  4569. */
  4570. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4571. /**
  4572. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4573. * @param startValue defines the start value
  4574. * @param endValue defines the end value
  4575. * @param gradient defines the gradient factor
  4576. * @param result defines the Matrix object where to store data
  4577. */
  4578. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4579. /**
  4580. * Builds a new matrix whose values are computed by:
  4581. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4582. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4583. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4584. * @param startValue defines the first matrix
  4585. * @param endValue defines the second matrix
  4586. * @param gradient defines the gradient between the two matrices
  4587. * @returns the new matrix
  4588. */
  4589. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4590. /**
  4591. * Update a matrix to values which are computed by:
  4592. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4593. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4594. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4595. * @param startValue defines the first matrix
  4596. * @param endValue defines the second matrix
  4597. * @param gradient defines the gradient between the two matrices
  4598. * @param result defines the target matrix
  4599. */
  4600. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4601. /**
  4602. * 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"
  4603. * This function works in left handed mode
  4604. * @param eye defines the final position of the entity
  4605. * @param target defines where the entity should look at
  4606. * @param up defines the up vector for the entity
  4607. * @returns the new matrix
  4608. */
  4609. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4610. /**
  4611. * 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".
  4612. * This function works in left handed mode
  4613. * @param eye defines the final position of the entity
  4614. * @param target defines where the entity should look at
  4615. * @param up defines the up vector for the entity
  4616. * @param result defines the target matrix
  4617. */
  4618. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4619. /**
  4620. * 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"
  4621. * This function works in right handed mode
  4622. * @param eye defines the final position of the entity
  4623. * @param target defines where the entity should look at
  4624. * @param up defines the up vector for the entity
  4625. * @returns the new matrix
  4626. */
  4627. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4628. /**
  4629. * 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".
  4630. * This function works in right handed mode
  4631. * @param eye defines the final position of the entity
  4632. * @param target defines where the entity should look at
  4633. * @param up defines the up vector for the entity
  4634. * @param result defines the target matrix
  4635. */
  4636. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4637. /**
  4638. * Create a left-handed orthographic 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 orthographic projection matrix
  4644. */
  4645. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4646. /**
  4647. * Store a left-handed orthographic projection to a given matrix
  4648. * @param width defines the viewport width
  4649. * @param height defines the viewport height
  4650. * @param znear defines the near clip plane
  4651. * @param zfar defines the far clip plane
  4652. * @param result defines the target matrix
  4653. */
  4654. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4655. /**
  4656. * Create a left-handed orthographic projection matrix
  4657. * @param left defines the viewport left coordinate
  4658. * @param right defines the viewport right coordinate
  4659. * @param bottom defines the viewport bottom coordinate
  4660. * @param top defines the viewport top coordinate
  4661. * @param znear defines the near clip plane
  4662. * @param zfar defines the far clip plane
  4663. * @returns a new matrix as a left-handed orthographic projection matrix
  4664. */
  4665. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4666. /**
  4667. * Stores a left-handed orthographic projection into a given matrix
  4668. * @param left defines the viewport left coordinate
  4669. * @param right defines the viewport right coordinate
  4670. * @param bottom defines the viewport bottom coordinate
  4671. * @param top defines the viewport top coordinate
  4672. * @param znear defines the near clip plane
  4673. * @param zfar defines the far clip plane
  4674. * @param result defines the target matrix
  4675. */
  4676. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4677. /**
  4678. * Creates a right-handed orthographic projection matrix
  4679. * @param left defines the viewport left coordinate
  4680. * @param right defines the viewport right coordinate
  4681. * @param bottom defines the viewport bottom coordinate
  4682. * @param top defines the viewport top coordinate
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @returns a new matrix as a right-handed orthographic projection matrix
  4686. */
  4687. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4688. /**
  4689. * Stores a right-handed orthographic projection into a given matrix
  4690. * @param left defines the viewport left coordinate
  4691. * @param right defines the viewport right coordinate
  4692. * @param bottom defines the viewport bottom coordinate
  4693. * @param top defines the viewport top coordinate
  4694. * @param znear defines the near clip plane
  4695. * @param zfar defines the far clip plane
  4696. * @param result defines the target matrix
  4697. */
  4698. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4699. /**
  4700. * Creates a left-handed perspective projection matrix
  4701. * @param width defines the viewport width
  4702. * @param height defines the viewport height
  4703. * @param znear defines the near clip plane
  4704. * @param zfar defines the far clip plane
  4705. * @returns a new matrix as a left-handed perspective projection matrix
  4706. */
  4707. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4708. /**
  4709. * Creates a left-handed perspective projection matrix
  4710. * @param fov defines the horizontal field of view
  4711. * @param aspect defines the aspect ratio
  4712. * @param znear defines the near clip plane
  4713. * @param zfar defines the far clip plane
  4714. * @returns a new matrix as a left-handed perspective projection matrix
  4715. */
  4716. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4717. /**
  4718. * Stores a left-handed perspective projection into a given matrix
  4719. * @param fov defines the horizontal field of view
  4720. * @param aspect defines the aspect ratio
  4721. * @param znear defines the near clip plane
  4722. * @param zfar defines the far clip plane
  4723. * @param result defines the target matrix
  4724. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4725. */
  4726. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4727. /**
  4728. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4729. * @param fov defines the horizontal field of view
  4730. * @param aspect defines the aspect ratio
  4731. * @param znear defines the near clip plane
  4732. * @param zfar not used as infinity is used as far clip
  4733. * @param result defines the target matrix
  4734. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4735. */
  4736. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4737. /**
  4738. * Creates a right-handed perspective projection matrix
  4739. * @param fov defines the horizontal field of view
  4740. * @param aspect defines the aspect ratio
  4741. * @param znear defines the near clip plane
  4742. * @param zfar defines the far clip plane
  4743. * @returns a new matrix as a right-handed perspective projection matrix
  4744. */
  4745. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4746. /**
  4747. * Stores a right-handed perspective projection into a given matrix
  4748. * @param fov defines the horizontal field of view
  4749. * @param aspect defines the aspect ratio
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4754. */
  4755. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4756. /**
  4757. * Stores a right-handed perspective projection into a given matrix
  4758. * @param fov defines the horizontal field of view
  4759. * @param aspect defines the aspect ratio
  4760. * @param znear defines the near clip plane
  4761. * @param zfar not used as infinity is used as far clip
  4762. * @param result defines the target matrix
  4763. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4764. */
  4765. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4766. /**
  4767. * Stores a perspective projection for WebVR info a given matrix
  4768. * @param fov defines the field of view
  4769. * @param znear defines the near clip plane
  4770. * @param zfar defines the far clip plane
  4771. * @param result defines the target matrix
  4772. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4773. */
  4774. static PerspectiveFovWebVRToRef(fov: {
  4775. upDegrees: number;
  4776. downDegrees: number;
  4777. leftDegrees: number;
  4778. rightDegrees: number;
  4779. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4780. /**
  4781. * Computes a complete transformation matrix
  4782. * @param viewport defines the viewport to use
  4783. * @param world defines the world matrix
  4784. * @param view defines the view matrix
  4785. * @param projection defines the projection matrix
  4786. * @param zmin defines the near clip plane
  4787. * @param zmax defines the far clip plane
  4788. * @returns the transformation matrix
  4789. */
  4790. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4791. /**
  4792. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4793. * @param matrix defines the matrix to use
  4794. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4795. */
  4796. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4797. /**
  4798. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4799. * @param matrix defines the matrix to use
  4800. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4801. */
  4802. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4803. /**
  4804. * Compute the transpose of a given matrix
  4805. * @param matrix defines the matrix to transpose
  4806. * @returns the new matrix
  4807. */
  4808. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4809. /**
  4810. * Compute the transpose of a matrix and store it in a target matrix
  4811. * @param matrix defines the matrix to transpose
  4812. * @param result defines the target matrix
  4813. */
  4814. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4815. /**
  4816. * Computes a reflection matrix from a plane
  4817. * @param plane defines the reflection plane
  4818. * @returns a new matrix
  4819. */
  4820. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4821. /**
  4822. * Computes a reflection matrix from a plane
  4823. * @param plane defines the reflection plane
  4824. * @param result defines the target matrix
  4825. */
  4826. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4827. /**
  4828. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4829. * @param xaxis defines the value of the 1st axis
  4830. * @param yaxis defines the value of the 2nd axis
  4831. * @param zaxis defines the value of the 3rd axis
  4832. * @param result defines the target matrix
  4833. */
  4834. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4835. /**
  4836. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4837. * @param quat defines the quaternion to use
  4838. * @param result defines the target matrix
  4839. */
  4840. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4841. }
  4842. /**
  4843. * @hidden
  4844. */
  4845. export class TmpVectors {
  4846. static Vector2: Vector2[];
  4847. static Vector3: Vector3[];
  4848. static Vector4: Vector4[];
  4849. static Quaternion: Quaternion[];
  4850. static Matrix: Matrix[];
  4851. }
  4852. }
  4853. declare module BABYLON {
  4854. /**
  4855. * Defines potential orientation for back face culling
  4856. */
  4857. export enum Orientation {
  4858. /**
  4859. * Clockwise
  4860. */
  4861. CW = 0,
  4862. /** Counter clockwise */
  4863. CCW = 1
  4864. }
  4865. /** Class used to represent a Bezier curve */
  4866. export class BezierCurve {
  4867. /**
  4868. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4869. * @param t defines the time
  4870. * @param x1 defines the left coordinate on X axis
  4871. * @param y1 defines the left coordinate on Y axis
  4872. * @param x2 defines the right coordinate on X axis
  4873. * @param y2 defines the right coordinate on Y axis
  4874. * @returns the interpolated value
  4875. */
  4876. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4877. }
  4878. /**
  4879. * Defines angle representation
  4880. */
  4881. export class Angle {
  4882. private _radians;
  4883. /**
  4884. * Creates an Angle object of "radians" radians (float).
  4885. * @param radians the angle in radians
  4886. */
  4887. constructor(radians: number);
  4888. /**
  4889. * Get value in degrees
  4890. * @returns the Angle value in degrees (float)
  4891. */
  4892. degrees(): number;
  4893. /**
  4894. * Get value in radians
  4895. * @returns the Angle value in radians (float)
  4896. */
  4897. radians(): number;
  4898. /**
  4899. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4900. * @param a defines first point as the origin
  4901. * @param b defines point
  4902. * @returns a new Angle
  4903. */
  4904. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4905. /**
  4906. * Gets a new Angle object from the given float in radians
  4907. * @param radians defines the angle value in radians
  4908. * @returns a new Angle
  4909. */
  4910. static FromRadians(radians: number): Angle;
  4911. /**
  4912. * Gets a new Angle object from the given float in degrees
  4913. * @param degrees defines the angle value in degrees
  4914. * @returns a new Angle
  4915. */
  4916. static FromDegrees(degrees: number): Angle;
  4917. }
  4918. /**
  4919. * This represents an arc in a 2d space.
  4920. */
  4921. export class Arc2 {
  4922. /** Defines the start point of the arc */
  4923. startPoint: Vector2;
  4924. /** Defines the mid point of the arc */
  4925. midPoint: Vector2;
  4926. /** Defines the end point of the arc */
  4927. endPoint: Vector2;
  4928. /**
  4929. * Defines the center point of the arc.
  4930. */
  4931. centerPoint: Vector2;
  4932. /**
  4933. * Defines the radius of the arc.
  4934. */
  4935. radius: number;
  4936. /**
  4937. * Defines the angle of the arc (from mid point to end point).
  4938. */
  4939. angle: Angle;
  4940. /**
  4941. * Defines the start angle of the arc (from start point to middle point).
  4942. */
  4943. startAngle: Angle;
  4944. /**
  4945. * Defines the orientation of the arc (clock wise/counter clock wise).
  4946. */
  4947. orientation: Orientation;
  4948. /**
  4949. * Creates an Arc object from the three given points : start, middle and end.
  4950. * @param startPoint Defines the start point of the arc
  4951. * @param midPoint Defines the midlle point of the arc
  4952. * @param endPoint Defines the end point of the arc
  4953. */
  4954. constructor(
  4955. /** Defines the start point of the arc */
  4956. startPoint: Vector2,
  4957. /** Defines the mid point of the arc */
  4958. midPoint: Vector2,
  4959. /** Defines the end point of the arc */
  4960. endPoint: Vector2);
  4961. }
  4962. /**
  4963. * Represents a 2D path made up of multiple 2D points
  4964. */
  4965. export class Path2 {
  4966. private _points;
  4967. private _length;
  4968. /**
  4969. * If the path start and end point are the same
  4970. */
  4971. closed: boolean;
  4972. /**
  4973. * Creates a Path2 object from the starting 2D coordinates x and y.
  4974. * @param x the starting points x value
  4975. * @param y the starting points y value
  4976. */
  4977. constructor(x: number, y: number);
  4978. /**
  4979. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4980. * @param x the added points x value
  4981. * @param y the added points y value
  4982. * @returns the updated Path2.
  4983. */
  4984. addLineTo(x: number, y: number): Path2;
  4985. /**
  4986. * 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.
  4987. * @param midX middle point x value
  4988. * @param midY middle point y value
  4989. * @param endX end point x value
  4990. * @param endY end point y value
  4991. * @param numberOfSegments (default: 36)
  4992. * @returns the updated Path2.
  4993. */
  4994. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4995. /**
  4996. * Closes the Path2.
  4997. * @returns the Path2.
  4998. */
  4999. close(): Path2;
  5000. /**
  5001. * Gets the sum of the distance between each sequential point in the path
  5002. * @returns the Path2 total length (float).
  5003. */
  5004. length(): number;
  5005. /**
  5006. * Gets the points which construct the path
  5007. * @returns the Path2 internal array of points.
  5008. */
  5009. getPoints(): Vector2[];
  5010. /**
  5011. * Retreives the point at the distance aways from the starting point
  5012. * @param normalizedLengthPosition the length along the path to retreive the point from
  5013. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5014. */
  5015. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5016. /**
  5017. * Creates a new path starting from an x and y position
  5018. * @param x starting x value
  5019. * @param y starting y value
  5020. * @returns a new Path2 starting at the coordinates (x, y).
  5021. */
  5022. static StartingAt(x: number, y: number): Path2;
  5023. }
  5024. /**
  5025. * Represents a 3D path made up of multiple 3D points
  5026. */
  5027. export class Path3D {
  5028. /**
  5029. * an array of Vector3, the curve axis of the Path3D
  5030. */
  5031. path: Vector3[];
  5032. private _curve;
  5033. private _distances;
  5034. private _tangents;
  5035. private _normals;
  5036. private _binormals;
  5037. private _raw;
  5038. private _alignTangentsWithPath;
  5039. private readonly _pointAtData;
  5040. /**
  5041. * new Path3D(path, normal, raw)
  5042. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5043. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5044. * @param path an array of Vector3, the curve axis of the Path3D
  5045. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5046. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5047. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5048. */
  5049. constructor(
  5050. /**
  5051. * an array of Vector3, the curve axis of the Path3D
  5052. */
  5053. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5054. /**
  5055. * Returns the Path3D array of successive Vector3 designing its curve.
  5056. * @returns the Path3D array of successive Vector3 designing its curve.
  5057. */
  5058. getCurve(): Vector3[];
  5059. /**
  5060. * Returns the Path3D array of successive Vector3 designing its curve.
  5061. * @returns the Path3D array of successive Vector3 designing its curve.
  5062. */
  5063. getPoints(): Vector3[];
  5064. /**
  5065. * @returns the computed length (float) of the path.
  5066. */
  5067. length(): number;
  5068. /**
  5069. * Returns an array populated with tangent vectors on each Path3D curve point.
  5070. * @returns an array populated with tangent vectors on each Path3D curve point.
  5071. */
  5072. getTangents(): Vector3[];
  5073. /**
  5074. * Returns an array populated with normal vectors on each Path3D curve point.
  5075. * @returns an array populated with normal vectors on each Path3D curve point.
  5076. */
  5077. getNormals(): Vector3[];
  5078. /**
  5079. * Returns an array populated with binormal vectors on each Path3D curve point.
  5080. * @returns an array populated with binormal vectors on each Path3D curve point.
  5081. */
  5082. getBinormals(): Vector3[];
  5083. /**
  5084. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5085. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5086. */
  5087. getDistances(): number[];
  5088. /**
  5089. * Returns an interpolated point along this path
  5090. * @param position the position of the point along this path, from 0.0 to 1.0
  5091. * @returns a new Vector3 as the point
  5092. */
  5093. getPointAt(position: number): Vector3;
  5094. /**
  5095. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5096. * @param position the position of the point along this path, from 0.0 to 1.0
  5097. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5098. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5099. */
  5100. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5101. /**
  5102. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5103. * @param position the position of the point along this path, from 0.0 to 1.0
  5104. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5105. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5106. */
  5107. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5108. /**
  5109. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5110. * @param position the position of the point along this path, from 0.0 to 1.0
  5111. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5112. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5113. */
  5114. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5115. /**
  5116. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5117. * @param position the position of the point along this path, from 0.0 to 1.0
  5118. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5119. */
  5120. getDistanceAt(position: number): number;
  5121. /**
  5122. * Returns the array index of the previous point of an interpolated point along this path
  5123. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5124. * @returns the array index
  5125. */
  5126. getPreviousPointIndexAt(position: number): number;
  5127. /**
  5128. * 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)
  5129. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5130. * @returns the sub position
  5131. */
  5132. getSubPositionAt(position: number): number;
  5133. /**
  5134. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5135. * @param target the vector of which to get the closest position to
  5136. * @returns the position of the closest virtual point on this path to the target vector
  5137. */
  5138. getClosestPositionTo(target: Vector3): number;
  5139. /**
  5140. * Returns a sub path (slice) of this path
  5141. * @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
  5142. * @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
  5143. * @returns a sub path (slice) of this path
  5144. */
  5145. slice(start?: number, end?: number): Path3D;
  5146. /**
  5147. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5148. * @param path path which all values are copied into the curves points
  5149. * @param firstNormal which should be projected onto the curve
  5150. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5151. * @returns the same object updated.
  5152. */
  5153. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5154. private _compute;
  5155. private _getFirstNonNullVector;
  5156. private _getLastNonNullVector;
  5157. private _normalVector;
  5158. /**
  5159. * Updates the point at data for an interpolated point along this curve
  5160. * @param position the position of the point along this curve, from 0.0 to 1.0
  5161. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5162. * @returns the (updated) point at data
  5163. */
  5164. private _updatePointAtData;
  5165. /**
  5166. * Updates the point at data from the specified parameters
  5167. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5168. * @param point the interpolated point
  5169. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5170. */
  5171. private _setPointAtData;
  5172. /**
  5173. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5174. */
  5175. private _updateInterpolationMatrix;
  5176. }
  5177. /**
  5178. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5179. * A Curve3 is designed from a series of successive Vector3.
  5180. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5181. */
  5182. export class Curve3 {
  5183. private _points;
  5184. private _length;
  5185. /**
  5186. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5187. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5188. * @param v1 (Vector3) the control point
  5189. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5190. * @param nbPoints (integer) the wanted number of points in the curve
  5191. * @returns the created Curve3
  5192. */
  5193. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5194. /**
  5195. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5196. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5197. * @param v1 (Vector3) the first control point
  5198. * @param v2 (Vector3) the second control point
  5199. * @param v3 (Vector3) the end point of the Cubic Bezier
  5200. * @param nbPoints (integer) the wanted number of points in the curve
  5201. * @returns the created Curve3
  5202. */
  5203. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5204. /**
  5205. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5206. * @param p1 (Vector3) the origin point of the Hermite Spline
  5207. * @param t1 (Vector3) the tangent vector at the origin point
  5208. * @param p2 (Vector3) the end point of the Hermite Spline
  5209. * @param t2 (Vector3) the tangent vector at the end point
  5210. * @param nbPoints (integer) the wanted number of points in the curve
  5211. * @returns the created Curve3
  5212. */
  5213. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5214. /**
  5215. * Returns a Curve3 object along a CatmullRom Spline curve :
  5216. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5217. * @param nbPoints (integer) the wanted number of points between each curve control points
  5218. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5219. * @returns the created Curve3
  5220. */
  5221. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5222. /**
  5223. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5224. * A Curve3 is designed from a series of successive Vector3.
  5225. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5226. * @param points points which make up the curve
  5227. */
  5228. constructor(points: Vector3[]);
  5229. /**
  5230. * @returns the Curve3 stored array of successive Vector3
  5231. */
  5232. getPoints(): Vector3[];
  5233. /**
  5234. * @returns the computed length (float) of the curve.
  5235. */
  5236. length(): number;
  5237. /**
  5238. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5239. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5240. * curveA and curveB keep unchanged.
  5241. * @param curve the curve to continue from this curve
  5242. * @returns the newly constructed curve
  5243. */
  5244. continue(curve: DeepImmutable<Curve3>): Curve3;
  5245. private _computeLength;
  5246. }
  5247. }
  5248. declare module BABYLON {
  5249. /**
  5250. * This represents the main contract an easing function should follow.
  5251. * Easing functions are used throughout the animation system.
  5252. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5253. */
  5254. export interface IEasingFunction {
  5255. /**
  5256. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5257. * of the easing function.
  5258. * The link below provides some of the most common examples of easing functions.
  5259. * @see https://easings.net/
  5260. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5261. * @returns the corresponding value on the curve defined by the easing function
  5262. */
  5263. ease(gradient: number): number;
  5264. }
  5265. /**
  5266. * Base class used for every default easing function.
  5267. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5268. */
  5269. export class EasingFunction implements IEasingFunction {
  5270. /**
  5271. * Interpolation follows the mathematical formula associated with the easing function.
  5272. */
  5273. static readonly EASINGMODE_EASEIN: number;
  5274. /**
  5275. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5276. */
  5277. static readonly EASINGMODE_EASEOUT: number;
  5278. /**
  5279. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5280. */
  5281. static readonly EASINGMODE_EASEINOUT: number;
  5282. private _easingMode;
  5283. /**
  5284. * Sets the easing mode of the current function.
  5285. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5286. */
  5287. setEasingMode(easingMode: number): void;
  5288. /**
  5289. * Gets the current easing mode.
  5290. * @returns the easing mode
  5291. */
  5292. getEasingMode(): number;
  5293. /**
  5294. * @hidden
  5295. */
  5296. easeInCore(gradient: number): number;
  5297. /**
  5298. * Given an input gradient between 0 and 1, this returns the corresponding value
  5299. * of the easing function.
  5300. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5301. * @returns the corresponding value on the curve defined by the easing function
  5302. */
  5303. ease(gradient: number): number;
  5304. }
  5305. /**
  5306. * Easing function with a circle shape (see link below).
  5307. * @see https://easings.net/#easeInCirc
  5308. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5309. */
  5310. export class CircleEase extends EasingFunction implements IEasingFunction {
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. /**
  5315. * Easing function with a ease back shape (see link below).
  5316. * @see https://easings.net/#easeInBack
  5317. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5318. */
  5319. export class BackEase extends EasingFunction implements IEasingFunction {
  5320. /** Defines the amplitude of the function */
  5321. amplitude: number;
  5322. /**
  5323. * Instantiates a back ease easing
  5324. * @see https://easings.net/#easeInBack
  5325. * @param amplitude Defines the amplitude of the function
  5326. */
  5327. constructor(
  5328. /** Defines the amplitude of the function */
  5329. amplitude?: number);
  5330. /** @hidden */
  5331. easeInCore(gradient: number): number;
  5332. }
  5333. /**
  5334. * Easing function with a bouncing shape (see link below).
  5335. * @see https://easings.net/#easeInBounce
  5336. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5337. */
  5338. export class BounceEase extends EasingFunction implements IEasingFunction {
  5339. /** Defines the number of bounces */
  5340. bounces: number;
  5341. /** Defines the amplitude of the bounce */
  5342. bounciness: number;
  5343. /**
  5344. * Instantiates a bounce easing
  5345. * @see https://easings.net/#easeInBounce
  5346. * @param bounces Defines the number of bounces
  5347. * @param bounciness Defines the amplitude of the bounce
  5348. */
  5349. constructor(
  5350. /** Defines the number of bounces */
  5351. bounces?: number,
  5352. /** Defines the amplitude of the bounce */
  5353. bounciness?: number);
  5354. /** @hidden */
  5355. easeInCore(gradient: number): number;
  5356. }
  5357. /**
  5358. * Easing function with a power of 3 shape (see link below).
  5359. * @see https://easings.net/#easeInCubic
  5360. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5361. */
  5362. export class CubicEase extends EasingFunction implements IEasingFunction {
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with an elastic shape (see link below).
  5368. * @see https://easings.net/#easeInElastic
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5372. /** Defines the number of oscillations*/
  5373. oscillations: number;
  5374. /** Defines the amplitude of the oscillations*/
  5375. springiness: number;
  5376. /**
  5377. * Instantiates an elastic easing function
  5378. * @see https://easings.net/#easeInElastic
  5379. * @param oscillations Defines the number of oscillations
  5380. * @param springiness Defines the amplitude of the oscillations
  5381. */
  5382. constructor(
  5383. /** Defines the number of oscillations*/
  5384. oscillations?: number,
  5385. /** Defines the amplitude of the oscillations*/
  5386. springiness?: number);
  5387. /** @hidden */
  5388. easeInCore(gradient: number): number;
  5389. }
  5390. /**
  5391. * Easing function with an exponential shape (see link below).
  5392. * @see https://easings.net/#easeInExpo
  5393. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5394. */
  5395. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5396. /** Defines the exponent of the function */
  5397. exponent: number;
  5398. /**
  5399. * Instantiates an exponential easing function
  5400. * @see https://easings.net/#easeInExpo
  5401. * @param exponent Defines the exponent of the function
  5402. */
  5403. constructor(
  5404. /** Defines the exponent of the function */
  5405. exponent?: number);
  5406. /** @hidden */
  5407. easeInCore(gradient: number): number;
  5408. }
  5409. /**
  5410. * Easing function with a power shape (see link below).
  5411. * @see https://easings.net/#easeInQuad
  5412. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5413. */
  5414. export class PowerEase extends EasingFunction implements IEasingFunction {
  5415. /** Defines the power of the function */
  5416. power: number;
  5417. /**
  5418. * Instantiates an power base easing function
  5419. * @see https://easings.net/#easeInQuad
  5420. * @param power Defines the power of the function
  5421. */
  5422. constructor(
  5423. /** Defines the power of the function */
  5424. power?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with a power of 2 shape (see link below).
  5430. * @see https://easings.net/#easeInQuad
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5434. /** @hidden */
  5435. easeInCore(gradient: number): number;
  5436. }
  5437. /**
  5438. * Easing function with a power of 4 shape (see link below).
  5439. * @see https://easings.net/#easeInQuart
  5440. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5441. */
  5442. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5443. /** @hidden */
  5444. easeInCore(gradient: number): number;
  5445. }
  5446. /**
  5447. * Easing function with a power of 5 shape (see link below).
  5448. * @see https://easings.net/#easeInQuint
  5449. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5450. */
  5451. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5452. /** @hidden */
  5453. easeInCore(gradient: number): number;
  5454. }
  5455. /**
  5456. * Easing function with a sin shape (see link below).
  5457. * @see https://easings.net/#easeInSine
  5458. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5459. */
  5460. export class SineEase extends EasingFunction implements IEasingFunction {
  5461. /** @hidden */
  5462. easeInCore(gradient: number): number;
  5463. }
  5464. /**
  5465. * Easing function with a bezier shape (see link below).
  5466. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5468. */
  5469. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5470. /** Defines the x component of the start tangent in the bezier curve */
  5471. x1: number;
  5472. /** Defines the y component of the start tangent in the bezier curve */
  5473. y1: number;
  5474. /** Defines the x component of the end tangent in the bezier curve */
  5475. x2: number;
  5476. /** Defines the y component of the end tangent in the bezier curve */
  5477. y2: number;
  5478. /**
  5479. * Instantiates a bezier function
  5480. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5481. * @param x1 Defines the x component of the start tangent in the bezier curve
  5482. * @param y1 Defines the y component of the start tangent in the bezier curve
  5483. * @param x2 Defines the x component of the end tangent in the bezier curve
  5484. * @param y2 Defines the y component of the end tangent in the bezier curve
  5485. */
  5486. constructor(
  5487. /** Defines the x component of the start tangent in the bezier curve */
  5488. x1?: number,
  5489. /** Defines the y component of the start tangent in the bezier curve */
  5490. y1?: number,
  5491. /** Defines the x component of the end tangent in the bezier curve */
  5492. x2?: number,
  5493. /** Defines the y component of the end tangent in the bezier curve */
  5494. y2?: number);
  5495. /** @hidden */
  5496. easeInCore(gradient: number): number;
  5497. }
  5498. }
  5499. declare module BABYLON {
  5500. /**
  5501. * Class used to hold a RBG color
  5502. */
  5503. export class Color3 {
  5504. /**
  5505. * Defines the red component (between 0 and 1, default is 0)
  5506. */
  5507. r: number;
  5508. /**
  5509. * Defines the green component (between 0 and 1, default is 0)
  5510. */
  5511. g: number;
  5512. /**
  5513. * Defines the blue component (between 0 and 1, default is 0)
  5514. */
  5515. b: number;
  5516. /**
  5517. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5518. * @param r defines the red component (between 0 and 1, default is 0)
  5519. * @param g defines the green component (between 0 and 1, default is 0)
  5520. * @param b defines the blue component (between 0 and 1, default is 0)
  5521. */
  5522. constructor(
  5523. /**
  5524. * Defines the red component (between 0 and 1, default is 0)
  5525. */
  5526. r?: number,
  5527. /**
  5528. * Defines the green component (between 0 and 1, default is 0)
  5529. */
  5530. g?: number,
  5531. /**
  5532. * Defines the blue component (between 0 and 1, default is 0)
  5533. */
  5534. b?: number);
  5535. /**
  5536. * Creates a string with the Color3 current values
  5537. * @returns the string representation of the Color3 object
  5538. */
  5539. toString(): string;
  5540. /**
  5541. * Returns the string "Color3"
  5542. * @returns "Color3"
  5543. */
  5544. getClassName(): string;
  5545. /**
  5546. * Compute the Color3 hash code
  5547. * @returns an unique number that can be used to hash Color3 objects
  5548. */
  5549. getHashCode(): number;
  5550. /**
  5551. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5552. * @param array defines the array where to store the r,g,b components
  5553. * @param index defines an optional index in the target array to define where to start storing values
  5554. * @returns the current Color3 object
  5555. */
  5556. toArray(array: FloatArray, index?: number): Color3;
  5557. /**
  5558. * Update the current color with values stored in an array from the starting index of the given array
  5559. * @param array defines the source array
  5560. * @param offset defines an offset in the source array
  5561. * @returns the current Color3 object
  5562. */
  5563. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5564. /**
  5565. * Returns a new Color4 object from the current Color3 and the given alpha
  5566. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5567. * @returns a new Color4 object
  5568. */
  5569. toColor4(alpha?: number): Color4;
  5570. /**
  5571. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5572. * @returns the new array
  5573. */
  5574. asArray(): number[];
  5575. /**
  5576. * Returns the luminance value
  5577. * @returns a float value
  5578. */
  5579. toLuminance(): number;
  5580. /**
  5581. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5582. * @param otherColor defines the second operand
  5583. * @returns the new Color3 object
  5584. */
  5585. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5586. /**
  5587. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5588. * @param otherColor defines the second operand
  5589. * @param result defines the Color3 object where to store the result
  5590. * @returns the current Color3
  5591. */
  5592. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5593. /**
  5594. * Determines equality between Color3 objects
  5595. * @param otherColor defines the second operand
  5596. * @returns true if the rgb values are equal to the given ones
  5597. */
  5598. equals(otherColor: DeepImmutable<Color3>): boolean;
  5599. /**
  5600. * Determines equality between the current Color3 object and a set of r,b,g values
  5601. * @param r defines the red component to check
  5602. * @param g defines the green component to check
  5603. * @param b defines the blue component to check
  5604. * @returns true if the rgb values are equal to the given ones
  5605. */
  5606. equalsFloats(r: number, g: number, b: number): boolean;
  5607. /**
  5608. * Multiplies in place each rgb value by scale
  5609. * @param scale defines the scaling factor
  5610. * @returns the updated Color3
  5611. */
  5612. scale(scale: number): Color3;
  5613. /**
  5614. * Multiplies the rgb values by scale and stores the result into "result"
  5615. * @param scale defines the scaling factor
  5616. * @param result defines the Color3 object where to store the result
  5617. * @returns the unmodified current Color3
  5618. */
  5619. scaleToRef(scale: number, result: Color3): Color3;
  5620. /**
  5621. * Scale the current Color3 values by a factor and add the result to a given Color3
  5622. * @param scale defines the scale factor
  5623. * @param result defines color to store the result into
  5624. * @returns the unmodified current Color3
  5625. */
  5626. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5627. /**
  5628. * Clamps the rgb values by the min and max values and stores the result into "result"
  5629. * @param min defines minimum clamping value (default is 0)
  5630. * @param max defines maximum clamping value (default is 1)
  5631. * @param result defines color to store the result into
  5632. * @returns the original Color3
  5633. */
  5634. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5635. /**
  5636. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5637. * @param otherColor defines the second operand
  5638. * @returns the new Color3
  5639. */
  5640. add(otherColor: DeepImmutable<Color3>): Color3;
  5641. /**
  5642. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5643. * @param otherColor defines the second operand
  5644. * @param result defines Color3 object to store the result into
  5645. * @returns the unmodified current Color3
  5646. */
  5647. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5648. /**
  5649. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5650. * @param otherColor defines the second operand
  5651. * @returns the new Color3
  5652. */
  5653. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5654. /**
  5655. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5656. * @param otherColor defines the second operand
  5657. * @param result defines Color3 object to store the result into
  5658. * @returns the unmodified current Color3
  5659. */
  5660. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5661. /**
  5662. * Copy the current object
  5663. * @returns a new Color3 copied the current one
  5664. */
  5665. clone(): Color3;
  5666. /**
  5667. * Copies the rgb values from the source in the current Color3
  5668. * @param source defines the source Color3 object
  5669. * @returns the updated Color3 object
  5670. */
  5671. copyFrom(source: DeepImmutable<Color3>): Color3;
  5672. /**
  5673. * Updates the Color3 rgb values from the given floats
  5674. * @param r defines the red component to read from
  5675. * @param g defines the green component to read from
  5676. * @param b defines the blue component to read from
  5677. * @returns the current Color3 object
  5678. */
  5679. copyFromFloats(r: number, g: number, b: number): Color3;
  5680. /**
  5681. * Updates the Color3 rgb values from the given floats
  5682. * @param r defines the red component to read from
  5683. * @param g defines the green component to read from
  5684. * @param b defines the blue component to read from
  5685. * @returns the current Color3 object
  5686. */
  5687. set(r: number, g: number, b: number): Color3;
  5688. /**
  5689. * Compute the Color3 hexadecimal code as a string
  5690. * @returns a string containing the hexadecimal representation of the Color3 object
  5691. */
  5692. toHexString(): string;
  5693. /**
  5694. * Computes a new Color3 converted from the current one to linear space
  5695. * @returns a new Color3 object
  5696. */
  5697. toLinearSpace(): Color3;
  5698. /**
  5699. * Converts current color in rgb space to HSV values
  5700. * @returns a new color3 representing the HSV values
  5701. */
  5702. toHSV(): Color3;
  5703. /**
  5704. * Converts current color in rgb space to HSV values
  5705. * @param result defines the Color3 where to store the HSV values
  5706. */
  5707. toHSVToRef(result: Color3): void;
  5708. /**
  5709. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5710. * @param convertedColor defines the Color3 object where to store the linear space version
  5711. * @returns the unmodified Color3
  5712. */
  5713. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5714. /**
  5715. * Computes a new Color3 converted from the current one to gamma space
  5716. * @returns a new Color3 object
  5717. */
  5718. toGammaSpace(): Color3;
  5719. /**
  5720. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5721. * @param convertedColor defines the Color3 object where to store the gamma space version
  5722. * @returns the unmodified Color3
  5723. */
  5724. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5725. private static _BlackReadOnly;
  5726. /**
  5727. * Convert Hue, saturation and value to a Color3 (RGB)
  5728. * @param hue defines the hue
  5729. * @param saturation defines the saturation
  5730. * @param value defines the value
  5731. * @param result defines the Color3 where to store the RGB values
  5732. */
  5733. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5734. /**
  5735. * Creates a new Color3 from the string containing valid hexadecimal values
  5736. * @param hex defines a string containing valid hexadecimal values
  5737. * @returns a new Color3 object
  5738. */
  5739. static FromHexString(hex: string): Color3;
  5740. /**
  5741. * Creates a new Color3 from the starting index of the given array
  5742. * @param array defines the source array
  5743. * @param offset defines an offset in the source array
  5744. * @returns a new Color3 object
  5745. */
  5746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5747. /**
  5748. * Creates a new Color3 from the starting index element of the given array
  5749. * @param array defines the source array to read from
  5750. * @param offset defines the offset in the source array
  5751. * @param result defines the target Color3 object
  5752. */
  5753. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5754. /**
  5755. * Creates a new Color3 from integer values (< 256)
  5756. * @param r defines the red component to read from (value between 0 and 255)
  5757. * @param g defines the green component to read from (value between 0 and 255)
  5758. * @param b defines the blue component to read from (value between 0 and 255)
  5759. * @returns a new Color3 object
  5760. */
  5761. static FromInts(r: number, g: number, b: number): Color3;
  5762. /**
  5763. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5764. * @param start defines the start Color3 value
  5765. * @param end defines the end Color3 value
  5766. * @param amount defines the gradient value between start and end
  5767. * @returns a new Color3 object
  5768. */
  5769. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5770. /**
  5771. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5772. * @param left defines the start value
  5773. * @param right defines the end value
  5774. * @param amount defines the gradient factor
  5775. * @param result defines the Color3 object where to store the result
  5776. */
  5777. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5778. /**
  5779. * Returns a Color3 value containing a red color
  5780. * @returns a new Color3 object
  5781. */
  5782. static Red(): Color3;
  5783. /**
  5784. * Returns a Color3 value containing a green color
  5785. * @returns a new Color3 object
  5786. */
  5787. static Green(): Color3;
  5788. /**
  5789. * Returns a Color3 value containing a blue color
  5790. * @returns a new Color3 object
  5791. */
  5792. static Blue(): Color3;
  5793. /**
  5794. * Returns a Color3 value containing a black color
  5795. * @returns a new Color3 object
  5796. */
  5797. static Black(): Color3;
  5798. /**
  5799. * Gets a Color3 value containing a black color that must not be updated
  5800. */
  5801. static get BlackReadOnly(): DeepImmutable<Color3>;
  5802. /**
  5803. * Returns a Color3 value containing a white color
  5804. * @returns a new Color3 object
  5805. */
  5806. static White(): Color3;
  5807. /**
  5808. * Returns a Color3 value containing a purple color
  5809. * @returns a new Color3 object
  5810. */
  5811. static Purple(): Color3;
  5812. /**
  5813. * Returns a Color3 value containing a magenta color
  5814. * @returns a new Color3 object
  5815. */
  5816. static Magenta(): Color3;
  5817. /**
  5818. * Returns a Color3 value containing a yellow color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Yellow(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a gray color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Gray(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a teal color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Teal(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a random color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Random(): Color3;
  5837. }
  5838. /**
  5839. * Class used to hold a RBGA color
  5840. */
  5841. export class Color4 {
  5842. /**
  5843. * Defines the red component (between 0 and 1, default is 0)
  5844. */
  5845. r: number;
  5846. /**
  5847. * Defines the green component (between 0 and 1, default is 0)
  5848. */
  5849. g: number;
  5850. /**
  5851. * Defines the blue component (between 0 and 1, default is 0)
  5852. */
  5853. b: number;
  5854. /**
  5855. * Defines the alpha component (between 0 and 1, default is 1)
  5856. */
  5857. a: number;
  5858. /**
  5859. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5860. * @param r defines the red component (between 0 and 1, default is 0)
  5861. * @param g defines the green component (between 0 and 1, default is 0)
  5862. * @param b defines the blue component (between 0 and 1, default is 0)
  5863. * @param a defines the alpha component (between 0 and 1, default is 1)
  5864. */
  5865. constructor(
  5866. /**
  5867. * Defines the red component (between 0 and 1, default is 0)
  5868. */
  5869. r?: number,
  5870. /**
  5871. * Defines the green component (between 0 and 1, default is 0)
  5872. */
  5873. g?: number,
  5874. /**
  5875. * Defines the blue component (between 0 and 1, default is 0)
  5876. */
  5877. b?: number,
  5878. /**
  5879. * Defines the alpha component (between 0 and 1, default is 1)
  5880. */
  5881. a?: number);
  5882. /**
  5883. * Adds in place the given Color4 values to the current Color4 object
  5884. * @param right defines the second operand
  5885. * @returns the current updated Color4 object
  5886. */
  5887. addInPlace(right: DeepImmutable<Color4>): Color4;
  5888. /**
  5889. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5890. * @returns the new array
  5891. */
  5892. asArray(): number[];
  5893. /**
  5894. * Stores from the starting index in the given array the Color4 successive values
  5895. * @param array defines the array where to store the r,g,b components
  5896. * @param index defines an optional index in the target array to define where to start storing values
  5897. * @returns the current Color4 object
  5898. */
  5899. toArray(array: number[], index?: number): Color4;
  5900. /**
  5901. * Update the current color with values stored in an array from the starting index of the given array
  5902. * @param array defines the source array
  5903. * @param offset defines an offset in the source array
  5904. * @returns the current Color4 object
  5905. */
  5906. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5907. /**
  5908. * Determines equality between Color4 objects
  5909. * @param otherColor defines the second operand
  5910. * @returns true if the rgba values are equal to the given ones
  5911. */
  5912. equals(otherColor: DeepImmutable<Color4>): boolean;
  5913. /**
  5914. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5915. * @param right defines the second operand
  5916. * @returns a new Color4 object
  5917. */
  5918. add(right: DeepImmutable<Color4>): Color4;
  5919. /**
  5920. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5921. * @param right defines the second operand
  5922. * @returns a new Color4 object
  5923. */
  5924. subtract(right: DeepImmutable<Color4>): Color4;
  5925. /**
  5926. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5927. * @param right defines the second operand
  5928. * @param result defines the Color4 object where to store the result
  5929. * @returns the current Color4 object
  5930. */
  5931. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5932. /**
  5933. * Creates a new Color4 with the current Color4 values multiplied by scale
  5934. * @param scale defines the scaling factor to apply
  5935. * @returns a new Color4 object
  5936. */
  5937. scale(scale: number): Color4;
  5938. /**
  5939. * Multiplies the current Color4 values by scale and stores the result in "result"
  5940. * @param scale defines the scaling factor to apply
  5941. * @param result defines the Color4 object where to store the result
  5942. * @returns the current unmodified Color4
  5943. */
  5944. scaleToRef(scale: number, result: Color4): Color4;
  5945. /**
  5946. * Scale the current Color4 values by a factor and add the result to a given Color4
  5947. * @param scale defines the scale factor
  5948. * @param result defines the Color4 object where to store the result
  5949. * @returns the unmodified current Color4
  5950. */
  5951. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5952. /**
  5953. * Clamps the rgb values by the min and max values and stores the result into "result"
  5954. * @param min defines minimum clamping value (default is 0)
  5955. * @param max defines maximum clamping value (default is 1)
  5956. * @param result defines color to store the result into.
  5957. * @returns the cuurent Color4
  5958. */
  5959. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5960. /**
  5961. * Multipy an Color4 value by another and return a new Color4 object
  5962. * @param color defines the Color4 value to multiply by
  5963. * @returns a new Color4 object
  5964. */
  5965. multiply(color: Color4): Color4;
  5966. /**
  5967. * Multipy a Color4 value by another and push the result in a reference value
  5968. * @param color defines the Color4 value to multiply by
  5969. * @param result defines the Color4 to fill the result in
  5970. * @returns the result Color4
  5971. */
  5972. multiplyToRef(color: Color4, result: Color4): Color4;
  5973. /**
  5974. * Creates a string with the Color4 current values
  5975. * @returns the string representation of the Color4 object
  5976. */
  5977. toString(): string;
  5978. /**
  5979. * Returns the string "Color4"
  5980. * @returns "Color4"
  5981. */
  5982. getClassName(): string;
  5983. /**
  5984. * Compute the Color4 hash code
  5985. * @returns an unique number that can be used to hash Color4 objects
  5986. */
  5987. getHashCode(): number;
  5988. /**
  5989. * Creates a new Color4 copied from the current one
  5990. * @returns a new Color4 object
  5991. */
  5992. clone(): Color4;
  5993. /**
  5994. * Copies the given Color4 values into the current one
  5995. * @param source defines the source Color4 object
  5996. * @returns the current updated Color4 object
  5997. */
  5998. copyFrom(source: Color4): Color4;
  5999. /**
  6000. * Copies the given float values into the current one
  6001. * @param r defines the red component to read from
  6002. * @param g defines the green component to read from
  6003. * @param b defines the blue component to read from
  6004. * @param a defines the alpha component to read from
  6005. * @returns the current updated Color4 object
  6006. */
  6007. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6008. /**
  6009. * Copies the given float values into the current one
  6010. * @param r defines the red component to read from
  6011. * @param g defines the green component to read from
  6012. * @param b defines the blue component to read from
  6013. * @param a defines the alpha component to read from
  6014. * @returns the current updated Color4 object
  6015. */
  6016. set(r: number, g: number, b: number, a: number): Color4;
  6017. /**
  6018. * Compute the Color4 hexadecimal code as a string
  6019. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6020. * @returns a string containing the hexadecimal representation of the Color4 object
  6021. */
  6022. toHexString(returnAsColor3?: boolean): string;
  6023. /**
  6024. * Computes a new Color4 converted from the current one to linear space
  6025. * @returns a new Color4 object
  6026. */
  6027. toLinearSpace(): Color4;
  6028. /**
  6029. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6030. * @param convertedColor defines the Color4 object where to store the linear space version
  6031. * @returns the unmodified Color4
  6032. */
  6033. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6034. /**
  6035. * Computes a new Color4 converted from the current one to gamma space
  6036. * @returns a new Color4 object
  6037. */
  6038. toGammaSpace(): Color4;
  6039. /**
  6040. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6041. * @param convertedColor defines the Color4 object where to store the gamma space version
  6042. * @returns the unmodified Color4
  6043. */
  6044. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6045. /**
  6046. * Creates a new Color4 from the string containing valid hexadecimal values
  6047. * @param hex defines a string containing valid hexadecimal values
  6048. * @returns a new Color4 object
  6049. */
  6050. static FromHexString(hex: string): Color4;
  6051. /**
  6052. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6053. * @param left defines the start value
  6054. * @param right defines the end value
  6055. * @param amount defines the gradient factor
  6056. * @returns a new Color4 object
  6057. */
  6058. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6059. /**
  6060. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6061. * @param left defines the start value
  6062. * @param right defines the end value
  6063. * @param amount defines the gradient factor
  6064. * @param result defines the Color4 object where to store data
  6065. */
  6066. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6067. /**
  6068. * Creates a new Color4 from a Color3 and an alpha value
  6069. * @param color3 defines the source Color3 to read from
  6070. * @param alpha defines the alpha component (1.0 by default)
  6071. * @returns a new Color4 object
  6072. */
  6073. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6074. /**
  6075. * Creates a new Color4 from the starting index element of the given array
  6076. * @param array defines the source array to read from
  6077. * @param offset defines the offset in the source array
  6078. * @returns a new Color4 object
  6079. */
  6080. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6081. /**
  6082. * Creates a new Color4 from the starting index element of the given array
  6083. * @param array defines the source array to read from
  6084. * @param offset defines the offset in the source array
  6085. * @param result defines the target Color4 object
  6086. */
  6087. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6088. /**
  6089. * Creates a new Color3 from integer values (< 256)
  6090. * @param r defines the red component to read from (value between 0 and 255)
  6091. * @param g defines the green component to read from (value between 0 and 255)
  6092. * @param b defines the blue component to read from (value between 0 and 255)
  6093. * @param a defines the alpha component to read from (value between 0 and 255)
  6094. * @returns a new Color3 object
  6095. */
  6096. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6097. /**
  6098. * Check the content of a given array and convert it to an array containing RGBA data
  6099. * If the original array was already containing count * 4 values then it is returned directly
  6100. * @param colors defines the array to check
  6101. * @param count defines the number of RGBA data to expect
  6102. * @returns an array containing count * 4 values (RGBA)
  6103. */
  6104. static CheckColors4(colors: number[], count: number): number[];
  6105. }
  6106. /**
  6107. * @hidden
  6108. */
  6109. export class TmpColors {
  6110. static Color3: Color3[];
  6111. static Color4: Color4[];
  6112. }
  6113. }
  6114. declare module BABYLON {
  6115. /**
  6116. * Defines an interface which represents an animation key frame
  6117. */
  6118. export interface IAnimationKey {
  6119. /**
  6120. * Frame of the key frame
  6121. */
  6122. frame: number;
  6123. /**
  6124. * Value at the specifies key frame
  6125. */
  6126. value: any;
  6127. /**
  6128. * The input tangent for the cubic hermite spline
  6129. */
  6130. inTangent?: any;
  6131. /**
  6132. * The output tangent for the cubic hermite spline
  6133. */
  6134. outTangent?: any;
  6135. /**
  6136. * The animation interpolation type
  6137. */
  6138. interpolation?: AnimationKeyInterpolation;
  6139. }
  6140. /**
  6141. * Enum for the animation key frame interpolation type
  6142. */
  6143. export enum AnimationKeyInterpolation {
  6144. /**
  6145. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6146. */
  6147. STEP = 1
  6148. }
  6149. }
  6150. declare module BABYLON {
  6151. /**
  6152. * Represents the range of an animation
  6153. */
  6154. export class AnimationRange {
  6155. /**The name of the animation range**/
  6156. name: string;
  6157. /**The starting frame of the animation */
  6158. from: number;
  6159. /**The ending frame of the animation*/
  6160. to: number;
  6161. /**
  6162. * Initializes the range of an animation
  6163. * @param name The name of the animation range
  6164. * @param from The starting frame of the animation
  6165. * @param to The ending frame of the animation
  6166. */
  6167. constructor(
  6168. /**The name of the animation range**/
  6169. name: string,
  6170. /**The starting frame of the animation */
  6171. from: number,
  6172. /**The ending frame of the animation*/
  6173. to: number);
  6174. /**
  6175. * Makes a copy of the animation range
  6176. * @returns A copy of the animation range
  6177. */
  6178. clone(): AnimationRange;
  6179. }
  6180. }
  6181. declare module BABYLON {
  6182. /**
  6183. * Composed of a frame, and an action function
  6184. */
  6185. export class AnimationEvent {
  6186. /** The frame for which the event is triggered **/
  6187. frame: number;
  6188. /** The event to perform when triggered **/
  6189. action: (currentFrame: number) => void;
  6190. /** Specifies if the event should be triggered only once**/
  6191. onlyOnce?: boolean | undefined;
  6192. /**
  6193. * Specifies if the animation event is done
  6194. */
  6195. isDone: boolean;
  6196. /**
  6197. * Initializes the animation event
  6198. * @param frame The frame for which the event is triggered
  6199. * @param action The event to perform when triggered
  6200. * @param onlyOnce Specifies if the event should be triggered only once
  6201. */
  6202. constructor(
  6203. /** The frame for which the event is triggered **/
  6204. frame: number,
  6205. /** The event to perform when triggered **/
  6206. action: (currentFrame: number) => void,
  6207. /** Specifies if the event should be triggered only once**/
  6208. onlyOnce?: boolean | undefined);
  6209. /** @hidden */
  6210. _clone(): AnimationEvent;
  6211. }
  6212. }
  6213. declare module BABYLON {
  6214. /**
  6215. * Interface used to define a behavior
  6216. */
  6217. export interface Behavior<T> {
  6218. /** gets or sets behavior's name */
  6219. name: string;
  6220. /**
  6221. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6222. */
  6223. init(): void;
  6224. /**
  6225. * Called when the behavior is attached to a target
  6226. * @param target defines the target where the behavior is attached to
  6227. */
  6228. attach(target: T): void;
  6229. /**
  6230. * Called when the behavior is detached from its target
  6231. */
  6232. detach(): void;
  6233. }
  6234. /**
  6235. * Interface implemented by classes supporting behaviors
  6236. */
  6237. export interface IBehaviorAware<T> {
  6238. /**
  6239. * Attach a behavior
  6240. * @param behavior defines the behavior to attach
  6241. * @returns the current host
  6242. */
  6243. addBehavior(behavior: Behavior<T>): T;
  6244. /**
  6245. * Remove a behavior from the current object
  6246. * @param behavior defines the behavior to detach
  6247. * @returns the current host
  6248. */
  6249. removeBehavior(behavior: Behavior<T>): T;
  6250. /**
  6251. * Gets a behavior using its name to search
  6252. * @param name defines the name to search
  6253. * @returns the behavior or null if not found
  6254. */
  6255. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6256. }
  6257. }
  6258. declare module BABYLON {
  6259. /**
  6260. * Defines an array and its length.
  6261. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6262. */
  6263. export interface ISmartArrayLike<T> {
  6264. /**
  6265. * The data of the array.
  6266. */
  6267. data: Array<T>;
  6268. /**
  6269. * The active length of the array.
  6270. */
  6271. length: number;
  6272. }
  6273. /**
  6274. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6275. */
  6276. export class SmartArray<T> implements ISmartArrayLike<T> {
  6277. /**
  6278. * The full set of data from the array.
  6279. */
  6280. data: Array<T>;
  6281. /**
  6282. * The active length of the array.
  6283. */
  6284. length: number;
  6285. protected _id: number;
  6286. /**
  6287. * Instantiates a Smart Array.
  6288. * @param capacity defines the default capacity of the array.
  6289. */
  6290. constructor(capacity: number);
  6291. /**
  6292. * Pushes a value at the end of the active data.
  6293. * @param value defines the object to push in the array.
  6294. */
  6295. push(value: T): void;
  6296. /**
  6297. * Iterates over the active data and apply the lambda to them.
  6298. * @param func defines the action to apply on each value.
  6299. */
  6300. forEach(func: (content: T) => void): void;
  6301. /**
  6302. * Sorts the full sets of data.
  6303. * @param compareFn defines the comparison function to apply.
  6304. */
  6305. sort(compareFn: (a: T, b: T) => number): void;
  6306. /**
  6307. * Resets the active data to an empty array.
  6308. */
  6309. reset(): void;
  6310. /**
  6311. * Releases all the data from the array as well as the array.
  6312. */
  6313. dispose(): void;
  6314. /**
  6315. * Concats the active data with a given array.
  6316. * @param array defines the data to concatenate with.
  6317. */
  6318. concat(array: any): void;
  6319. /**
  6320. * Returns the position of a value in the active data.
  6321. * @param value defines the value to find the index for
  6322. * @returns the index if found in the active data otherwise -1
  6323. */
  6324. indexOf(value: T): number;
  6325. /**
  6326. * Returns whether an element is part of the active data.
  6327. * @param value defines the value to look for
  6328. * @returns true if found in the active data otherwise false
  6329. */
  6330. contains(value: T): boolean;
  6331. private static _GlobalId;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. * The data in this array can only be present once
  6336. */
  6337. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6338. private _duplicateId;
  6339. /**
  6340. * Pushes a value at the end of the active data.
  6341. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6342. * @param value defines the object to push in the array.
  6343. */
  6344. push(value: T): void;
  6345. /**
  6346. * Pushes a value at the end of the active data.
  6347. * If the data is already present, it won t be added again
  6348. * @param value defines the object to push in the array.
  6349. * @returns true if added false if it was already present
  6350. */
  6351. pushNoDuplicate(value: T): boolean;
  6352. /**
  6353. * Resets the active data to an empty array.
  6354. */
  6355. reset(): void;
  6356. /**
  6357. * Concats the active data with a given array.
  6358. * This ensures no dupplicate will be present in the result.
  6359. * @param array defines the data to concatenate with.
  6360. */
  6361. concatWithNoDuplicate(array: any): void;
  6362. }
  6363. }
  6364. declare module BABYLON {
  6365. /**
  6366. * @ignore
  6367. * This is a list of all the different input types that are available in the application.
  6368. * Fo instance: ArcRotateCameraGamepadInput...
  6369. */
  6370. export var CameraInputTypes: {};
  6371. /**
  6372. * This is the contract to implement in order to create a new input class.
  6373. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6374. */
  6375. export interface ICameraInput<TCamera extends Camera> {
  6376. /**
  6377. * Defines the camera the input is attached to.
  6378. */
  6379. camera: Nullable<TCamera>;
  6380. /**
  6381. * Gets the class name of the current intput.
  6382. * @returns the class name
  6383. */
  6384. getClassName(): string;
  6385. /**
  6386. * Get the friendly name associated with the input class.
  6387. * @returns the input friendly name
  6388. */
  6389. getSimpleName(): string;
  6390. /**
  6391. * Attach the input controls to a specific dom element to get the input from.
  6392. * @param element Defines the element the controls should be listened from
  6393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6394. */
  6395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6396. /**
  6397. * Detach the current controls from the specified dom element.
  6398. * @param element Defines the element to stop listening the inputs from
  6399. */
  6400. detachControl(element: Nullable<HTMLElement>): void;
  6401. /**
  6402. * Update the current camera state depending on the inputs that have been used this frame.
  6403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6404. */
  6405. checkInputs?: () => void;
  6406. }
  6407. /**
  6408. * Represents a map of input types to input instance or input index to input instance.
  6409. */
  6410. export interface CameraInputsMap<TCamera extends Camera> {
  6411. /**
  6412. * Accessor to the input by input type.
  6413. */
  6414. [name: string]: ICameraInput<TCamera>;
  6415. /**
  6416. * Accessor to the input by input index.
  6417. */
  6418. [idx: number]: ICameraInput<TCamera>;
  6419. }
  6420. /**
  6421. * This represents the input manager used within a camera.
  6422. * It helps dealing with all the different kind of input attached to a camera.
  6423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6424. */
  6425. export class CameraInputsManager<TCamera extends Camera> {
  6426. /**
  6427. * Defines the list of inputs attahed to the camera.
  6428. */
  6429. attached: CameraInputsMap<TCamera>;
  6430. /**
  6431. * Defines the dom element the camera is collecting inputs from.
  6432. * This is null if the controls have not been attached.
  6433. */
  6434. attachedElement: Nullable<HTMLElement>;
  6435. /**
  6436. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6437. */
  6438. noPreventDefault: boolean;
  6439. /**
  6440. * Defined the camera the input manager belongs to.
  6441. */
  6442. camera: TCamera;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs: () => void;
  6448. /**
  6449. * Instantiate a new Camera Input Manager.
  6450. * @param camera Defines the camera the input manager blongs to
  6451. */
  6452. constructor(camera: TCamera);
  6453. /**
  6454. * Add an input method to a camera
  6455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6456. * @param input camera input method
  6457. */
  6458. add(input: ICameraInput<TCamera>): void;
  6459. /**
  6460. * Remove a specific input method from a camera
  6461. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6462. * @param inputToRemove camera input method
  6463. */
  6464. remove(inputToRemove: ICameraInput<TCamera>): void;
  6465. /**
  6466. * Remove a specific input type from a camera
  6467. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6468. * @param inputType the type of the input to remove
  6469. */
  6470. removeByType(inputType: string): void;
  6471. private _addCheckInputs;
  6472. /**
  6473. * Attach the input controls to the currently attached dom element to listen the events from.
  6474. * @param input Defines the input to attach
  6475. */
  6476. attachInput(input: ICameraInput<TCamera>): void;
  6477. /**
  6478. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6479. * @param element Defines the dom element to collect the events from
  6480. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6481. */
  6482. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6483. /**
  6484. * Detach the current manager inputs controls from a specific dom element.
  6485. * @param element Defines the dom element to collect the events from
  6486. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6487. */
  6488. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6489. /**
  6490. * Rebuild the dynamic inputCheck function from the current list of
  6491. * defined inputs in the manager.
  6492. */
  6493. rebuildInputCheck(): void;
  6494. /**
  6495. * Remove all attached input methods from a camera
  6496. */
  6497. clear(): void;
  6498. /**
  6499. * Serialize the current input manager attached to a camera.
  6500. * This ensures than once parsed,
  6501. * the input associated to the camera will be identical to the current ones
  6502. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6503. */
  6504. serialize(serializedCamera: any): void;
  6505. /**
  6506. * Parses an input manager serialized JSON to restore the previous list of inputs
  6507. * and states associated to a camera.
  6508. * @param parsedCamera Defines the JSON to parse
  6509. */
  6510. parse(parsedCamera: any): void;
  6511. }
  6512. }
  6513. declare module BABYLON {
  6514. /**
  6515. * Class used to store data that will be store in GPU memory
  6516. */
  6517. export class Buffer {
  6518. private _engine;
  6519. private _buffer;
  6520. /** @hidden */
  6521. _data: Nullable<DataArray>;
  6522. private _updatable;
  6523. private _instanced;
  6524. private _divisor;
  6525. /**
  6526. * Gets the byte stride.
  6527. */
  6528. readonly byteStride: number;
  6529. /**
  6530. * Constructor
  6531. * @param engine the engine
  6532. * @param data the data to use for this buffer
  6533. * @param updatable whether the data is updatable
  6534. * @param stride the stride (optional)
  6535. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6536. * @param instanced whether the buffer is instanced (optional)
  6537. * @param useBytes set to true if the stride in in bytes (optional)
  6538. * @param divisor sets an optional divisor for instances (1 by default)
  6539. */
  6540. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6541. /**
  6542. * Create a new VertexBuffer based on the current buffer
  6543. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6544. * @param offset defines offset in the buffer (0 by default)
  6545. * @param size defines the size in floats of attributes (position is 3 for instance)
  6546. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6547. * @param instanced defines if the vertex buffer contains indexed data
  6548. * @param useBytes defines if the offset and stride are in bytes *
  6549. * @param divisor sets an optional divisor for instances (1 by default)
  6550. * @returns the new vertex buffer
  6551. */
  6552. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6553. /**
  6554. * Gets a boolean indicating if the Buffer is updatable?
  6555. * @returns true if the buffer is updatable
  6556. */
  6557. isUpdatable(): boolean;
  6558. /**
  6559. * Gets current buffer's data
  6560. * @returns a DataArray or null
  6561. */
  6562. getData(): Nullable<DataArray>;
  6563. /**
  6564. * Gets underlying native buffer
  6565. * @returns underlying native buffer
  6566. */
  6567. getBuffer(): Nullable<DataBuffer>;
  6568. /**
  6569. * Gets the stride in float32 units (i.e. byte stride / 4).
  6570. * May not be an integer if the byte stride is not divisible by 4.
  6571. * @returns the stride in float32 units
  6572. * @deprecated Please use byteStride instead.
  6573. */
  6574. getStrideSize(): number;
  6575. /**
  6576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6577. * @param data defines the data to store
  6578. */
  6579. create(data?: Nullable<DataArray>): void;
  6580. /** @hidden */
  6581. _rebuild(): void;
  6582. /**
  6583. * Update current buffer data
  6584. * @param data defines the data to store
  6585. */
  6586. update(data: DataArray): void;
  6587. /**
  6588. * Updates the data directly.
  6589. * @param data the new data
  6590. * @param offset the new offset
  6591. * @param vertexCount the vertex count (optional)
  6592. * @param useBytes set to true if the offset is in bytes
  6593. */
  6594. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6595. /**
  6596. * Release all resources
  6597. */
  6598. dispose(): void;
  6599. }
  6600. /**
  6601. * Specialized buffer used to store vertex data
  6602. */
  6603. export class VertexBuffer {
  6604. /** @hidden */
  6605. _buffer: Buffer;
  6606. private _kind;
  6607. private _size;
  6608. private _ownsBuffer;
  6609. private _instanced;
  6610. private _instanceDivisor;
  6611. /**
  6612. * The byte type.
  6613. */
  6614. static readonly BYTE: number;
  6615. /**
  6616. * The unsigned byte type.
  6617. */
  6618. static readonly UNSIGNED_BYTE: number;
  6619. /**
  6620. * The short type.
  6621. */
  6622. static readonly SHORT: number;
  6623. /**
  6624. * The unsigned short type.
  6625. */
  6626. static readonly UNSIGNED_SHORT: number;
  6627. /**
  6628. * The integer type.
  6629. */
  6630. static readonly INT: number;
  6631. /**
  6632. * The unsigned integer type.
  6633. */
  6634. static readonly UNSIGNED_INT: number;
  6635. /**
  6636. * The float type.
  6637. */
  6638. static readonly FLOAT: number;
  6639. /**
  6640. * Gets or sets the instance divisor when in instanced mode
  6641. */
  6642. get instanceDivisor(): number;
  6643. set instanceDivisor(value: number);
  6644. /**
  6645. * Gets the byte stride.
  6646. */
  6647. readonly byteStride: number;
  6648. /**
  6649. * Gets the byte offset.
  6650. */
  6651. readonly byteOffset: number;
  6652. /**
  6653. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6654. */
  6655. readonly normalized: boolean;
  6656. /**
  6657. * Gets the data type of each component in the array.
  6658. */
  6659. readonly type: number;
  6660. /**
  6661. * Constructor
  6662. * @param engine the engine
  6663. * @param data the data to use for this vertex buffer
  6664. * @param kind the vertex buffer kind
  6665. * @param updatable whether the data is updatable
  6666. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6667. * @param stride the stride (optional)
  6668. * @param instanced whether the buffer is instanced (optional)
  6669. * @param offset the offset of the data (optional)
  6670. * @param size the number of components (optional)
  6671. * @param type the type of the component (optional)
  6672. * @param normalized whether the data contains normalized data (optional)
  6673. * @param useBytes set to true if stride and offset are in bytes (optional)
  6674. * @param divisor defines the instance divisor to use (1 by default)
  6675. */
  6676. 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);
  6677. /** @hidden */
  6678. _rebuild(): void;
  6679. /**
  6680. * Returns the kind of the VertexBuffer (string)
  6681. * @returns a string
  6682. */
  6683. getKind(): string;
  6684. /**
  6685. * Gets a boolean indicating if the VertexBuffer is updatable?
  6686. * @returns true if the buffer is updatable
  6687. */
  6688. isUpdatable(): boolean;
  6689. /**
  6690. * Gets current buffer's data
  6691. * @returns a DataArray or null
  6692. */
  6693. getData(): Nullable<DataArray>;
  6694. /**
  6695. * Gets underlying native buffer
  6696. * @returns underlying native buffer
  6697. */
  6698. getBuffer(): Nullable<DataBuffer>;
  6699. /**
  6700. * Gets the stride in float32 units (i.e. byte stride / 4).
  6701. * May not be an integer if the byte stride is not divisible by 4.
  6702. * @returns the stride in float32 units
  6703. * @deprecated Please use byteStride instead.
  6704. */
  6705. getStrideSize(): number;
  6706. /**
  6707. * Returns the offset as a multiple of the type byte length.
  6708. * @returns the offset in bytes
  6709. * @deprecated Please use byteOffset instead.
  6710. */
  6711. getOffset(): number;
  6712. /**
  6713. * Returns the number of components per vertex attribute (integer)
  6714. * @returns the size in float
  6715. */
  6716. getSize(): number;
  6717. /**
  6718. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6719. * @returns true if this buffer is instanced
  6720. */
  6721. getIsInstanced(): boolean;
  6722. /**
  6723. * Returns the instancing divisor, zero for non-instanced (integer).
  6724. * @returns a number
  6725. */
  6726. getInstanceDivisor(): number;
  6727. /**
  6728. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6729. * @param data defines the data to store
  6730. */
  6731. create(data?: DataArray): void;
  6732. /**
  6733. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6734. * This function will create a new buffer if the current one is not updatable
  6735. * @param data defines the data to store
  6736. */
  6737. update(data: DataArray): void;
  6738. /**
  6739. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6740. * Returns the directly updated WebGLBuffer.
  6741. * @param data the new data
  6742. * @param offset the new offset
  6743. * @param useBytes set to true if the offset is in bytes
  6744. */
  6745. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6746. /**
  6747. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6748. */
  6749. dispose(): void;
  6750. /**
  6751. * Enumerates each value of this vertex buffer as numbers.
  6752. * @param count the number of values to enumerate
  6753. * @param callback the callback function called for each value
  6754. */
  6755. forEach(count: number, callback: (value: number, index: number) => void): void;
  6756. /**
  6757. * Positions
  6758. */
  6759. static readonly PositionKind: string;
  6760. /**
  6761. * Normals
  6762. */
  6763. static readonly NormalKind: string;
  6764. /**
  6765. * Tangents
  6766. */
  6767. static readonly TangentKind: string;
  6768. /**
  6769. * Texture coordinates
  6770. */
  6771. static readonly UVKind: string;
  6772. /**
  6773. * Texture coordinates 2
  6774. */
  6775. static readonly UV2Kind: string;
  6776. /**
  6777. * Texture coordinates 3
  6778. */
  6779. static readonly UV3Kind: string;
  6780. /**
  6781. * Texture coordinates 4
  6782. */
  6783. static readonly UV4Kind: string;
  6784. /**
  6785. * Texture coordinates 5
  6786. */
  6787. static readonly UV5Kind: string;
  6788. /**
  6789. * Texture coordinates 6
  6790. */
  6791. static readonly UV6Kind: string;
  6792. /**
  6793. * Colors
  6794. */
  6795. static readonly ColorKind: string;
  6796. /**
  6797. * Matrix indices (for bones)
  6798. */
  6799. static readonly MatricesIndicesKind: string;
  6800. /**
  6801. * Matrix weights (for bones)
  6802. */
  6803. static readonly MatricesWeightsKind: string;
  6804. /**
  6805. * Additional matrix indices (for bones)
  6806. */
  6807. static readonly MatricesIndicesExtraKind: string;
  6808. /**
  6809. * Additional matrix weights (for bones)
  6810. */
  6811. static readonly MatricesWeightsExtraKind: string;
  6812. /**
  6813. * Deduces the stride given a kind.
  6814. * @param kind The kind string to deduce
  6815. * @returns The deduced stride
  6816. */
  6817. static DeduceStride(kind: string): number;
  6818. /**
  6819. * Gets the byte length of the given type.
  6820. * @param type the type
  6821. * @returns the number of bytes
  6822. */
  6823. static GetTypeByteLength(type: number): number;
  6824. /**
  6825. * Enumerates each value of the given parameters as numbers.
  6826. * @param data the data to enumerate
  6827. * @param byteOffset the byte offset of the data
  6828. * @param byteStride the byte stride of the data
  6829. * @param componentCount the number of components per element
  6830. * @param componentType the type of the component
  6831. * @param count the number of values to enumerate
  6832. * @param normalized whether the data is normalized
  6833. * @param callback the callback function called for each value
  6834. */
  6835. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6836. private static _GetFloatValue;
  6837. }
  6838. }
  6839. declare module BABYLON {
  6840. /**
  6841. * The options Interface for creating a Capsule Mesh
  6842. */
  6843. export interface ICreateCapsuleOptions {
  6844. /** The Orientation of the capsule. Default : Vector3.Up() */
  6845. orientation?: Vector3;
  6846. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6847. subdivisions: number;
  6848. /** Number of cylindrical segments on the capsule. */
  6849. tessellation: number;
  6850. /** Height or Length of the capsule. */
  6851. height: number;
  6852. /** Radius of the capsule. */
  6853. radius: number;
  6854. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6855. capSubdivisions: number;
  6856. /** Overwrite for the top radius. */
  6857. radiusTop?: number;
  6858. /** Overwrite for the bottom radius. */
  6859. radiusBottom?: number;
  6860. /** Overwrite for the top capSubdivisions. */
  6861. topCapSubdivisions?: number;
  6862. /** Overwrite for the bottom capSubdivisions. */
  6863. bottomCapSubdivisions?: number;
  6864. }
  6865. /**
  6866. * Class containing static functions to help procedurally build meshes
  6867. */
  6868. export class CapsuleBuilder {
  6869. /**
  6870. * Creates a capsule or a pill mesh
  6871. * @param name defines the name of the mesh
  6872. * @param options The constructors options.
  6873. * @param scene The scene the mesh is scoped to.
  6874. * @returns Capsule Mesh
  6875. */
  6876. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6877. }
  6878. }
  6879. declare module BABYLON {
  6880. /**
  6881. * @hidden
  6882. */
  6883. export class IntersectionInfo {
  6884. bu: Nullable<number>;
  6885. bv: Nullable<number>;
  6886. distance: number;
  6887. faceId: number;
  6888. subMeshId: number;
  6889. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * Class used to store bounding sphere information
  6895. */
  6896. export class BoundingSphere {
  6897. /**
  6898. * Gets the center of the bounding sphere in local space
  6899. */
  6900. readonly center: Vector3;
  6901. /**
  6902. * Radius of the bounding sphere in local space
  6903. */
  6904. radius: number;
  6905. /**
  6906. * Gets the center of the bounding sphere in world space
  6907. */
  6908. readonly centerWorld: Vector3;
  6909. /**
  6910. * Radius of the bounding sphere in world space
  6911. */
  6912. radiusWorld: number;
  6913. /**
  6914. * Gets the minimum vector in local space
  6915. */
  6916. readonly minimum: Vector3;
  6917. /**
  6918. * Gets the maximum vector in local space
  6919. */
  6920. readonly maximum: Vector3;
  6921. private _worldMatrix;
  6922. private static readonly TmpVector3;
  6923. /**
  6924. * Creates a new bounding sphere
  6925. * @param min defines the minimum vector (in local space)
  6926. * @param max defines the maximum vector (in local space)
  6927. * @param worldMatrix defines the new world matrix
  6928. */
  6929. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6930. /**
  6931. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6932. * @param min defines the new minimum vector (in local space)
  6933. * @param max defines the new maximum vector (in local space)
  6934. * @param worldMatrix defines the new world matrix
  6935. */
  6936. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6937. /**
  6938. * Scale the current bounding sphere by applying a scale factor
  6939. * @param factor defines the scale factor to apply
  6940. * @returns the current bounding box
  6941. */
  6942. scale(factor: number): BoundingSphere;
  6943. /**
  6944. * Gets the world matrix of the bounding box
  6945. * @returns a matrix
  6946. */
  6947. getWorldMatrix(): DeepImmutable<Matrix>;
  6948. /** @hidden */
  6949. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6950. /**
  6951. * Tests if the bounding sphere is intersecting the frustum planes
  6952. * @param frustumPlanes defines the frustum planes to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6956. /**
  6957. * Tests if the bounding sphere center is in between the frustum planes.
  6958. * Used for optimistic fast inclusion.
  6959. * @param frustumPlanes defines the frustum planes to test
  6960. * @returns true if the sphere center is in between the frustum planes
  6961. */
  6962. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6963. /**
  6964. * Tests if a point is inside the bounding sphere
  6965. * @param point defines the point to test
  6966. * @returns true if the point is inside the bounding sphere
  6967. */
  6968. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6969. /**
  6970. * Checks if two sphere intersct
  6971. * @param sphere0 sphere 0
  6972. * @param sphere1 sphere 1
  6973. * @returns true if the speres intersect
  6974. */
  6975. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6976. }
  6977. }
  6978. declare module BABYLON {
  6979. /**
  6980. * Class used to store bounding box information
  6981. */
  6982. export class BoundingBox implements ICullable {
  6983. /**
  6984. * Gets the 8 vectors representing the bounding box in local space
  6985. */
  6986. readonly vectors: Vector3[];
  6987. /**
  6988. * Gets the center of the bounding box in local space
  6989. */
  6990. readonly center: Vector3;
  6991. /**
  6992. * Gets the center of the bounding box in world space
  6993. */
  6994. readonly centerWorld: Vector3;
  6995. /**
  6996. * Gets the extend size in local space
  6997. */
  6998. readonly extendSize: Vector3;
  6999. /**
  7000. * Gets the extend size in world space
  7001. */
  7002. readonly extendSizeWorld: Vector3;
  7003. /**
  7004. * Gets the OBB (object bounding box) directions
  7005. */
  7006. readonly directions: Vector3[];
  7007. /**
  7008. * Gets the 8 vectors representing the bounding box in world space
  7009. */
  7010. readonly vectorsWorld: Vector3[];
  7011. /**
  7012. * Gets the minimum vector in world space
  7013. */
  7014. readonly minimumWorld: Vector3;
  7015. /**
  7016. * Gets the maximum vector in world space
  7017. */
  7018. readonly maximumWorld: Vector3;
  7019. /**
  7020. * Gets the minimum vector in local space
  7021. */
  7022. readonly minimum: Vector3;
  7023. /**
  7024. * Gets the maximum vector in local space
  7025. */
  7026. readonly maximum: Vector3;
  7027. private _worldMatrix;
  7028. private static readonly TmpVector3;
  7029. /**
  7030. * @hidden
  7031. */
  7032. _tag: number;
  7033. /**
  7034. * Creates a new bounding box
  7035. * @param min defines the minimum vector (in local space)
  7036. * @param max defines the maximum vector (in local space)
  7037. * @param worldMatrix defines the new world matrix
  7038. */
  7039. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7040. /**
  7041. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7042. * @param min defines the new minimum vector (in local space)
  7043. * @param max defines the new maximum vector (in local space)
  7044. * @param worldMatrix defines the new world matrix
  7045. */
  7046. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7047. /**
  7048. * Scale the current bounding box by applying a scale factor
  7049. * @param factor defines the scale factor to apply
  7050. * @returns the current bounding box
  7051. */
  7052. scale(factor: number): BoundingBox;
  7053. /**
  7054. * Gets the world matrix of the bounding box
  7055. * @returns a matrix
  7056. */
  7057. getWorldMatrix(): DeepImmutable<Matrix>;
  7058. /** @hidden */
  7059. _update(world: DeepImmutable<Matrix>): void;
  7060. /**
  7061. * Tests if the bounding box is intersecting the frustum planes
  7062. * @param frustumPlanes defines the frustum planes to test
  7063. * @returns true if there is an intersection
  7064. */
  7065. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7066. /**
  7067. * Tests if the bounding box is entirely inside the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an inclusion
  7070. */
  7071. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if a point is inside the bounding box
  7074. * @param point defines the point to test
  7075. * @returns true if the point is inside the bounding box
  7076. */
  7077. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7078. /**
  7079. * Tests if the bounding box intersects with a bounding sphere
  7080. * @param sphere defines the sphere to test
  7081. * @returns true if there is an intersection
  7082. */
  7083. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7084. /**
  7085. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7086. * @param min defines the min vector to use
  7087. * @param max defines the max vector to use
  7088. * @returns true if there is an intersection
  7089. */
  7090. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7091. /**
  7092. * Tests if two bounding boxes are intersections
  7093. * @param box0 defines the first box to test
  7094. * @param box1 defines the second box to test
  7095. * @returns true if there is an intersection
  7096. */
  7097. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7098. /**
  7099. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7100. * @param minPoint defines the minimum vector of the bounding box
  7101. * @param maxPoint defines the maximum vector of the bounding box
  7102. * @param sphereCenter defines the sphere center
  7103. * @param sphereRadius defines the sphere radius
  7104. * @returns true if there is an intersection
  7105. */
  7106. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7107. /**
  7108. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7109. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7110. * @param frustumPlanes defines the frustum planes to test
  7111. * @return true if there is an inclusion
  7112. */
  7113. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7114. /**
  7115. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7116. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @return true if there is an intersection
  7119. */
  7120. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. }
  7122. }
  7123. declare module BABYLON {
  7124. /** @hidden */
  7125. export class Collider {
  7126. /** Define if a collision was found */
  7127. collisionFound: boolean;
  7128. /**
  7129. * Define last intersection point in local space
  7130. */
  7131. intersectionPoint: Vector3;
  7132. /**
  7133. * Define last collided mesh
  7134. */
  7135. collidedMesh: Nullable<AbstractMesh>;
  7136. private _collisionPoint;
  7137. private _planeIntersectionPoint;
  7138. private _tempVector;
  7139. private _tempVector2;
  7140. private _tempVector3;
  7141. private _tempVector4;
  7142. private _edge;
  7143. private _baseToVertex;
  7144. private _destinationPoint;
  7145. private _slidePlaneNormal;
  7146. private _displacementVector;
  7147. /** @hidden */
  7148. _radius: Vector3;
  7149. /** @hidden */
  7150. _retry: number;
  7151. private _velocity;
  7152. private _basePoint;
  7153. private _epsilon;
  7154. /** @hidden */
  7155. _velocityWorldLength: number;
  7156. /** @hidden */
  7157. _basePointWorld: Vector3;
  7158. private _velocityWorld;
  7159. private _normalizedVelocity;
  7160. /** @hidden */
  7161. _initialVelocity: Vector3;
  7162. /** @hidden */
  7163. _initialPosition: Vector3;
  7164. private _nearestDistance;
  7165. private _collisionMask;
  7166. get collisionMask(): number;
  7167. set collisionMask(mask: number);
  7168. /**
  7169. * Gets the plane normal used to compute the sliding response (in local space)
  7170. */
  7171. get slidePlaneNormal(): Vector3;
  7172. /** @hidden */
  7173. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7174. /** @hidden */
  7175. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7176. /** @hidden */
  7177. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7178. /** @hidden */
  7179. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7180. /** @hidden */
  7181. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7182. /** @hidden */
  7183. _getResponse(pos: Vector3, vel: Vector3): void;
  7184. }
  7185. }
  7186. declare module BABYLON {
  7187. /**
  7188. * Interface for cullable objects
  7189. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7190. */
  7191. export interface ICullable {
  7192. /**
  7193. * Checks if the object or part of the object is in the frustum
  7194. * @param frustumPlanes Camera near/planes
  7195. * @returns true if the object is in frustum otherwise false
  7196. */
  7197. isInFrustum(frustumPlanes: Plane[]): boolean;
  7198. /**
  7199. * Checks if a cullable object (mesh...) is in the camera frustum
  7200. * Unlike isInFrustum this cheks the full bounding box
  7201. * @param frustumPlanes Camera near/planes
  7202. * @returns true if the object is in frustum otherwise false
  7203. */
  7204. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7205. }
  7206. /**
  7207. * Info for a bounding data of a mesh
  7208. */
  7209. export class BoundingInfo implements ICullable {
  7210. /**
  7211. * Bounding box for the mesh
  7212. */
  7213. readonly boundingBox: BoundingBox;
  7214. /**
  7215. * Bounding sphere for the mesh
  7216. */
  7217. readonly boundingSphere: BoundingSphere;
  7218. private _isLocked;
  7219. private static readonly TmpVector3;
  7220. /**
  7221. * Constructs bounding info
  7222. * @param minimum min vector of the bounding box/sphere
  7223. * @param maximum max vector of the bounding box/sphere
  7224. * @param worldMatrix defines the new world matrix
  7225. */
  7226. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7227. /**
  7228. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7229. * @param min defines the new minimum vector (in local space)
  7230. * @param max defines the new maximum vector (in local space)
  7231. * @param worldMatrix defines the new world matrix
  7232. */
  7233. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7234. /**
  7235. * min vector of the bounding box/sphere
  7236. */
  7237. get minimum(): Vector3;
  7238. /**
  7239. * max vector of the bounding box/sphere
  7240. */
  7241. get maximum(): Vector3;
  7242. /**
  7243. * If the info is locked and won't be updated to avoid perf overhead
  7244. */
  7245. get isLocked(): boolean;
  7246. set isLocked(value: boolean);
  7247. /**
  7248. * Updates the bounding sphere and box
  7249. * @param world world matrix to be used to update
  7250. */
  7251. update(world: DeepImmutable<Matrix>): void;
  7252. /**
  7253. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7254. * @param center New center of the bounding info
  7255. * @param extend New extend of the bounding info
  7256. * @returns the current bounding info
  7257. */
  7258. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7259. /**
  7260. * Scale the current bounding info by applying a scale factor
  7261. * @param factor defines the scale factor to apply
  7262. * @returns the current bounding info
  7263. */
  7264. scale(factor: number): BoundingInfo;
  7265. /**
  7266. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7267. * @param frustumPlanes defines the frustum to test
  7268. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7269. * @returns true if the bounding info is in the frustum planes
  7270. */
  7271. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7272. /**
  7273. * Gets the world distance between the min and max points of the bounding box
  7274. */
  7275. get diagonalLength(): number;
  7276. /**
  7277. * Checks if a cullable object (mesh...) is in the camera frustum
  7278. * Unlike isInFrustum this cheks the full bounding box
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7283. /** @hidden */
  7284. _checkCollision(collider: Collider): boolean;
  7285. /**
  7286. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7287. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7288. * @param point the point to check intersection with
  7289. * @returns if the point intersects
  7290. */
  7291. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7292. /**
  7293. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7294. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7295. * @param boundingInfo the bounding info to check intersection with
  7296. * @param precise if the intersection should be done using OBB
  7297. * @returns if the bounding info intersects
  7298. */
  7299. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7300. }
  7301. }
  7302. declare module BABYLON {
  7303. /**
  7304. * Extracts minimum and maximum values from a list of indexed positions
  7305. * @param positions defines the positions to use
  7306. * @param indices defines the indices to the positions
  7307. * @param indexStart defines the start index
  7308. * @param indexCount defines the end index
  7309. * @param bias defines bias value to add to the result
  7310. * @return minimum and maximum values
  7311. */
  7312. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7313. minimum: Vector3;
  7314. maximum: Vector3;
  7315. };
  7316. /**
  7317. * Extracts minimum and maximum values from a list of positions
  7318. * @param positions defines the positions to use
  7319. * @param start defines the start index in the positions array
  7320. * @param count defines the number of positions to handle
  7321. * @param bias defines bias value to add to the result
  7322. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7323. * @return minimum and maximum values
  7324. */
  7325. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7326. minimum: Vector3;
  7327. maximum: Vector3;
  7328. };
  7329. }
  7330. declare module BABYLON {
  7331. /** @hidden */
  7332. export class WebGLDataBuffer extends DataBuffer {
  7333. private _buffer;
  7334. constructor(resource: WebGLBuffer);
  7335. get underlyingResource(): any;
  7336. }
  7337. }
  7338. declare module BABYLON {
  7339. /** @hidden */
  7340. export class WebGLPipelineContext implements IPipelineContext {
  7341. engine: ThinEngine;
  7342. program: Nullable<WebGLProgram>;
  7343. context?: WebGLRenderingContext;
  7344. vertexShader?: WebGLShader;
  7345. fragmentShader?: WebGLShader;
  7346. isParallelCompiled: boolean;
  7347. onCompiled?: () => void;
  7348. transformFeedback?: WebGLTransformFeedback | null;
  7349. vertexCompilationError: Nullable<string>;
  7350. fragmentCompilationError: Nullable<string>;
  7351. programLinkError: Nullable<string>;
  7352. programValidationError: Nullable<string>;
  7353. get isAsync(): boolean;
  7354. get isReady(): boolean;
  7355. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7356. _getVertexShaderCode(): string | null;
  7357. _getFragmentShaderCode(): string | null;
  7358. }
  7359. }
  7360. declare module BABYLON {
  7361. interface ThinEngine {
  7362. /**
  7363. * Create an uniform buffer
  7364. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7365. * @param elements defines the content of the uniform buffer
  7366. * @returns the webGL uniform buffer
  7367. */
  7368. createUniformBuffer(elements: FloatArray): DataBuffer;
  7369. /**
  7370. * Create a dynamic uniform buffer
  7371. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7372. * @param elements defines the content of the uniform buffer
  7373. * @returns the webGL uniform buffer
  7374. */
  7375. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7376. /**
  7377. * Update an existing uniform buffer
  7378. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7379. * @param uniformBuffer defines the target uniform buffer
  7380. * @param elements defines the content to update
  7381. * @param offset defines the offset in the uniform buffer where update should start
  7382. * @param count defines the size of the data to update
  7383. */
  7384. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7385. /**
  7386. * Bind an uniform buffer to the current webGL context
  7387. * @param buffer defines the buffer to bind
  7388. */
  7389. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7390. /**
  7391. * Bind a buffer to the current webGL context at a given location
  7392. * @param buffer defines the buffer to bind
  7393. * @param location defines the index where to bind the buffer
  7394. */
  7395. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7396. /**
  7397. * Bind a specific block at a given index in a specific shader program
  7398. * @param pipelineContext defines the pipeline context to use
  7399. * @param blockName defines the block name
  7400. * @param index defines the index where to bind the block
  7401. */
  7402. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7403. }
  7404. }
  7405. declare module BABYLON {
  7406. /**
  7407. * Uniform buffer objects.
  7408. *
  7409. * Handles blocks of uniform on the GPU.
  7410. *
  7411. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7412. *
  7413. * For more information, please refer to :
  7414. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7415. */
  7416. export class UniformBuffer {
  7417. private _engine;
  7418. private _buffer;
  7419. private _data;
  7420. private _bufferData;
  7421. private _dynamic?;
  7422. private _uniformLocations;
  7423. private _uniformSizes;
  7424. private _uniformLocationPointer;
  7425. private _needSync;
  7426. private _noUBO;
  7427. private _currentEffect;
  7428. /** @hidden */
  7429. _alreadyBound: boolean;
  7430. private static _MAX_UNIFORM_SIZE;
  7431. private static _tempBuffer;
  7432. /**
  7433. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7434. * This is dynamic to allow compat with webgl 1 and 2.
  7435. * You will need to pass the name of the uniform as well as the value.
  7436. */
  7437. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7438. /**
  7439. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7440. * This is dynamic to allow compat with webgl 1 and 2.
  7441. * You will need to pass the name of the uniform as well as the value.
  7442. */
  7443. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7444. /**
  7445. * Lambda to Update a single float in a uniform buffer.
  7446. * This is dynamic to allow compat with webgl 1 and 2.
  7447. * You will need to pass the name of the uniform as well as the value.
  7448. */
  7449. updateFloat: (name: string, x: number) => void;
  7450. /**
  7451. * Lambda to Update a vec2 of float in a uniform buffer.
  7452. * This is dynamic to allow compat with webgl 1 and 2.
  7453. * You will need to pass the name of the uniform as well as the value.
  7454. */
  7455. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7456. /**
  7457. * Lambda to Update a vec3 of float in a uniform buffer.
  7458. * This is dynamic to allow compat with webgl 1 and 2.
  7459. * You will need to pass the name of the uniform as well as the value.
  7460. */
  7461. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7462. /**
  7463. * Lambda to Update a vec4 of float in a uniform buffer.
  7464. * This is dynamic to allow compat with webgl 1 and 2.
  7465. * You will need to pass the name of the uniform as well as the value.
  7466. */
  7467. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7468. /**
  7469. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7470. * This is dynamic to allow compat with webgl 1 and 2.
  7471. * You will need to pass the name of the uniform as well as the value.
  7472. */
  7473. updateMatrix: (name: string, mat: Matrix) => void;
  7474. /**
  7475. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7476. * This is dynamic to allow compat with webgl 1 and 2.
  7477. * You will need to pass the name of the uniform as well as the value.
  7478. */
  7479. updateVector3: (name: string, vector: Vector3) => void;
  7480. /**
  7481. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7482. * This is dynamic to allow compat with webgl 1 and 2.
  7483. * You will need to pass the name of the uniform as well as the value.
  7484. */
  7485. updateVector4: (name: string, vector: Vector4) => void;
  7486. /**
  7487. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7488. * This is dynamic to allow compat with webgl 1 and 2.
  7489. * You will need to pass the name of the uniform as well as the value.
  7490. */
  7491. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7492. /**
  7493. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7494. * This is dynamic to allow compat with webgl 1 and 2.
  7495. * You will need to pass the name of the uniform as well as the value.
  7496. */
  7497. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7498. /**
  7499. * Instantiates a new Uniform buffer objects.
  7500. *
  7501. * Handles blocks of uniform on the GPU.
  7502. *
  7503. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7504. *
  7505. * For more information, please refer to :
  7506. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7507. * @param engine Define the engine the buffer is associated with
  7508. * @param data Define the data contained in the buffer
  7509. * @param dynamic Define if the buffer is updatable
  7510. */
  7511. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7512. /**
  7513. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7514. * or just falling back on setUniformXXX calls.
  7515. */
  7516. get useUbo(): boolean;
  7517. /**
  7518. * Indicates if the WebGL underlying uniform buffer is in sync
  7519. * with the javascript cache data.
  7520. */
  7521. get isSync(): boolean;
  7522. /**
  7523. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7524. * Also, a dynamic UniformBuffer will disable cache verification and always
  7525. * update the underlying WebGL uniform buffer to the GPU.
  7526. * @returns if Dynamic, otherwise false
  7527. */
  7528. isDynamic(): boolean;
  7529. /**
  7530. * The data cache on JS side.
  7531. * @returns the underlying data as a float array
  7532. */
  7533. getData(): Float32Array;
  7534. /**
  7535. * The underlying WebGL Uniform buffer.
  7536. * @returns the webgl buffer
  7537. */
  7538. getBuffer(): Nullable<DataBuffer>;
  7539. /**
  7540. * std140 layout specifies how to align data within an UBO structure.
  7541. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7542. * for specs.
  7543. */
  7544. private _fillAlignment;
  7545. /**
  7546. * Adds an uniform in the buffer.
  7547. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7548. * for the layout to be correct !
  7549. * @param name Name of the uniform, as used in the uniform block in the shader.
  7550. * @param size Data size, or data directly.
  7551. */
  7552. addUniform(name: string, size: number | number[]): void;
  7553. /**
  7554. * Adds a Matrix 4x4 to the uniform buffer.
  7555. * @param name Name of the uniform, as used in the uniform block in the shader.
  7556. * @param mat A 4x4 matrix.
  7557. */
  7558. addMatrix(name: string, mat: Matrix): void;
  7559. /**
  7560. * Adds a vec2 to the uniform buffer.
  7561. * @param name Name of the uniform, as used in the uniform block in the shader.
  7562. * @param x Define the x component value of the vec2
  7563. * @param y Define the y component value of the vec2
  7564. */
  7565. addFloat2(name: string, x: number, y: number): void;
  7566. /**
  7567. * Adds a vec3 to the uniform buffer.
  7568. * @param name Name of the uniform, as used in the uniform block in the shader.
  7569. * @param x Define the x component value of the vec3
  7570. * @param y Define the y component value of the vec3
  7571. * @param z Define the z component value of the vec3
  7572. */
  7573. addFloat3(name: string, x: number, y: number, z: number): void;
  7574. /**
  7575. * Adds a vec3 to the uniform buffer.
  7576. * @param name Name of the uniform, as used in the uniform block in the shader.
  7577. * @param color Define the vec3 from a Color
  7578. */
  7579. addColor3(name: string, color: Color3): void;
  7580. /**
  7581. * Adds a vec4 to the uniform buffer.
  7582. * @param name Name of the uniform, as used in the uniform block in the shader.
  7583. * @param color Define the rgb components from a Color
  7584. * @param alpha Define the a component of the vec4
  7585. */
  7586. addColor4(name: string, color: Color3, alpha: number): void;
  7587. /**
  7588. * Adds a vec3 to the uniform buffer.
  7589. * @param name Name of the uniform, as used in the uniform block in the shader.
  7590. * @param vector Define the vec3 components from a Vector
  7591. */
  7592. addVector3(name: string, vector: Vector3): void;
  7593. /**
  7594. * Adds a Matrix 3x3 to the uniform buffer.
  7595. * @param name Name of the uniform, as used in the uniform block in the shader.
  7596. */
  7597. addMatrix3x3(name: string): void;
  7598. /**
  7599. * Adds a Matrix 2x2 to the uniform buffer.
  7600. * @param name Name of the uniform, as used in the uniform block in the shader.
  7601. */
  7602. addMatrix2x2(name: string): void;
  7603. /**
  7604. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7605. */
  7606. create(): void;
  7607. /** @hidden */
  7608. _rebuild(): void;
  7609. /**
  7610. * Updates the WebGL Uniform Buffer on the GPU.
  7611. * If the `dynamic` flag is set to true, no cache comparison is done.
  7612. * Otherwise, the buffer will be updated only if the cache differs.
  7613. */
  7614. update(): void;
  7615. /**
  7616. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7617. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7618. * @param data Define the flattened data
  7619. * @param size Define the size of the data.
  7620. */
  7621. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7622. private _valueCache;
  7623. private _cacheMatrix;
  7624. private _updateMatrix3x3ForUniform;
  7625. private _updateMatrix3x3ForEffect;
  7626. private _updateMatrix2x2ForEffect;
  7627. private _updateMatrix2x2ForUniform;
  7628. private _updateFloatForEffect;
  7629. private _updateFloatForUniform;
  7630. private _updateFloat2ForEffect;
  7631. private _updateFloat2ForUniform;
  7632. private _updateFloat3ForEffect;
  7633. private _updateFloat3ForUniform;
  7634. private _updateFloat4ForEffect;
  7635. private _updateFloat4ForUniform;
  7636. private _updateMatrixForEffect;
  7637. private _updateMatrixForUniform;
  7638. private _updateVector3ForEffect;
  7639. private _updateVector3ForUniform;
  7640. private _updateVector4ForEffect;
  7641. private _updateVector4ForUniform;
  7642. private _updateColor3ForEffect;
  7643. private _updateColor3ForUniform;
  7644. private _updateColor4ForEffect;
  7645. private _updateColor4ForUniform;
  7646. /**
  7647. * Sets a sampler uniform on the effect.
  7648. * @param name Define the name of the sampler.
  7649. * @param texture Define the texture to set in the sampler
  7650. */
  7651. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7652. /**
  7653. * Directly updates the value of the uniform in the cache AND on the GPU.
  7654. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7655. * @param data Define the flattened data
  7656. */
  7657. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7658. /**
  7659. * Binds this uniform buffer to an effect.
  7660. * @param effect Define the effect to bind the buffer to
  7661. * @param name Name of the uniform block in the shader.
  7662. */
  7663. bindToEffect(effect: Effect, name: string): void;
  7664. /**
  7665. * Disposes the uniform buffer.
  7666. */
  7667. dispose(): void;
  7668. }
  7669. }
  7670. declare module BABYLON {
  7671. /**
  7672. * Enum that determines the text-wrapping mode to use.
  7673. */
  7674. export enum InspectableType {
  7675. /**
  7676. * Checkbox for booleans
  7677. */
  7678. Checkbox = 0,
  7679. /**
  7680. * Sliders for numbers
  7681. */
  7682. Slider = 1,
  7683. /**
  7684. * Vector3
  7685. */
  7686. Vector3 = 2,
  7687. /**
  7688. * Quaternions
  7689. */
  7690. Quaternion = 3,
  7691. /**
  7692. * Color3
  7693. */
  7694. Color3 = 4,
  7695. /**
  7696. * String
  7697. */
  7698. String = 5
  7699. }
  7700. /**
  7701. * Interface used to define custom inspectable properties.
  7702. * This interface is used by the inspector to display custom property grids
  7703. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7704. */
  7705. export interface IInspectable {
  7706. /**
  7707. * Gets the label to display
  7708. */
  7709. label: string;
  7710. /**
  7711. * Gets the name of the property to edit
  7712. */
  7713. propertyName: string;
  7714. /**
  7715. * Gets the type of the editor to use
  7716. */
  7717. type: InspectableType;
  7718. /**
  7719. * Gets the minimum value of the property when using in "slider" mode
  7720. */
  7721. min?: number;
  7722. /**
  7723. * Gets the maximum value of the property when using in "slider" mode
  7724. */
  7725. max?: number;
  7726. /**
  7727. * Gets the setp to use when using in "slider" mode
  7728. */
  7729. step?: number;
  7730. }
  7731. }
  7732. declare module BABYLON {
  7733. /**
  7734. * Class used to provide helper for timing
  7735. */
  7736. export class TimingTools {
  7737. /**
  7738. * Polyfill for setImmediate
  7739. * @param action defines the action to execute after the current execution block
  7740. */
  7741. static SetImmediate(action: () => void): void;
  7742. }
  7743. }
  7744. declare module BABYLON {
  7745. /**
  7746. * Class used to enable instatition of objects by class name
  7747. */
  7748. export class InstantiationTools {
  7749. /**
  7750. * Use this object to register external classes like custom textures or material
  7751. * to allow the laoders to instantiate them
  7752. */
  7753. static RegisteredExternalClasses: {
  7754. [key: string]: Object;
  7755. };
  7756. /**
  7757. * Tries to instantiate a new object from a given class name
  7758. * @param className defines the class name to instantiate
  7759. * @returns the new object or null if the system was not able to do the instantiation
  7760. */
  7761. static Instantiate(className: string): any;
  7762. }
  7763. }
  7764. declare module BABYLON {
  7765. /**
  7766. * Define options used to create a depth texture
  7767. */
  7768. export class DepthTextureCreationOptions {
  7769. /** Specifies whether or not a stencil should be allocated in the texture */
  7770. generateStencil?: boolean;
  7771. /** Specifies whether or not bilinear filtering is enable on the texture */
  7772. bilinearFiltering?: boolean;
  7773. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7774. comparisonFunction?: number;
  7775. /** Specifies if the created texture is a cube texture */
  7776. isCube?: boolean;
  7777. }
  7778. }
  7779. declare module BABYLON {
  7780. interface ThinEngine {
  7781. /**
  7782. * Creates a depth stencil cube texture.
  7783. * This is only available in WebGL 2.
  7784. * @param size The size of face edge in the cube texture.
  7785. * @param options The options defining the cube texture.
  7786. * @returns The cube texture
  7787. */
  7788. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7789. /**
  7790. * Creates a cube texture
  7791. * @param rootUrl defines the url where the files to load is located
  7792. * @param scene defines the current scene
  7793. * @param files defines the list of files to load (1 per face)
  7794. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7795. * @param onLoad defines an optional callback raised when the texture is loaded
  7796. * @param onError defines an optional callback raised if there is an issue to load the texture
  7797. * @param format defines the format of the data
  7798. * @param forcedExtension defines the extension to use to pick the right loader
  7799. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7800. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7801. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7802. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7803. * @returns the cube texture as an InternalTexture
  7804. */
  7805. 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;
  7806. /**
  7807. * Creates a cube texture
  7808. * @param rootUrl defines the url where the files to load is located
  7809. * @param scene defines the current scene
  7810. * @param files defines the list of files to load (1 per face)
  7811. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7812. * @param onLoad defines an optional callback raised when the texture is loaded
  7813. * @param onError defines an optional callback raised if there is an issue to load the texture
  7814. * @param format defines the format of the data
  7815. * @param forcedExtension defines the extension to use to pick the right loader
  7816. * @returns the cube texture as an InternalTexture
  7817. */
  7818. 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;
  7819. /**
  7820. * Creates a cube texture
  7821. * @param rootUrl defines the url where the files to load is located
  7822. * @param scene defines the current scene
  7823. * @param files defines the list of files to load (1 per face)
  7824. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7825. * @param onLoad defines an optional callback raised when the texture is loaded
  7826. * @param onError defines an optional callback raised if there is an issue to load the texture
  7827. * @param format defines the format of the data
  7828. * @param forcedExtension defines the extension to use to pick the right loader
  7829. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7830. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7831. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7832. * @returns the cube texture as an InternalTexture
  7833. */
  7834. 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;
  7835. /** @hidden */
  7836. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7837. /** @hidden */
  7838. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7839. /** @hidden */
  7840. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7841. /** @hidden */
  7842. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7843. /**
  7844. * @hidden
  7845. */
  7846. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7847. }
  7848. }
  7849. declare module BABYLON {
  7850. /**
  7851. * Class for creating a cube texture
  7852. */
  7853. export class CubeTexture extends BaseTexture {
  7854. private _delayedOnLoad;
  7855. /**
  7856. * Observable triggered once the texture has been loaded.
  7857. */
  7858. onLoadObservable: Observable<CubeTexture>;
  7859. /**
  7860. * The url of the texture
  7861. */
  7862. url: string;
  7863. /**
  7864. * Gets or sets the center of the bounding box associated with the cube texture.
  7865. * It must define where the camera used to render the texture was set
  7866. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7867. */
  7868. boundingBoxPosition: Vector3;
  7869. private _boundingBoxSize;
  7870. /**
  7871. * Gets or sets the size of the bounding box associated with the cube texture
  7872. * When defined, the cubemap will switch to local mode
  7873. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7874. * @example https://www.babylonjs-playground.com/#RNASML
  7875. */
  7876. set boundingBoxSize(value: Vector3);
  7877. /**
  7878. * Returns the bounding box size
  7879. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7880. */
  7881. get boundingBoxSize(): Vector3;
  7882. protected _rotationY: number;
  7883. /**
  7884. * Sets texture matrix rotation angle around Y axis in radians.
  7885. */
  7886. set rotationY(value: number);
  7887. /**
  7888. * Gets texture matrix rotation angle around Y axis radians.
  7889. */
  7890. get rotationY(): number;
  7891. /**
  7892. * Are mip maps generated for this texture or not.
  7893. */
  7894. get noMipmap(): boolean;
  7895. private _noMipmap;
  7896. private _files;
  7897. protected _forcedExtension: Nullable<string>;
  7898. private _extensions;
  7899. private _textureMatrix;
  7900. private _format;
  7901. private _createPolynomials;
  7902. /**
  7903. * Creates a cube texture from an array of image urls
  7904. * @param files defines an array of image urls
  7905. * @param scene defines the hosting scene
  7906. * @param noMipmap specifies if mip maps are not used
  7907. * @returns a cube texture
  7908. */
  7909. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7910. /**
  7911. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7912. * @param url defines the url of the prefiltered texture
  7913. * @param scene defines the scene the texture is attached to
  7914. * @param forcedExtension defines the extension of the file if different from the url
  7915. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7916. * @return the prefiltered texture
  7917. */
  7918. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7919. /**
  7920. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7921. * as prefiltered data.
  7922. * @param rootUrl defines the url of the texture or the root name of the six images
  7923. * @param null defines the scene or engine the texture is attached to
  7924. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7925. * @param noMipmap defines if mipmaps should be created or not
  7926. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7927. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7928. * @param onError defines a callback triggered in case of error during load
  7929. * @param format defines the internal format to use for the texture once loaded
  7930. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7931. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7932. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7933. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7934. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7935. * @return the cube texture
  7936. */
  7937. 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);
  7938. /**
  7939. * Get the current class name of the texture useful for serialization or dynamic coding.
  7940. * @returns "CubeTexture"
  7941. */
  7942. getClassName(): string;
  7943. /**
  7944. * Update the url (and optional buffer) of this texture if url was null during construction.
  7945. * @param url the url of the texture
  7946. * @param forcedExtension defines the extension to use
  7947. * @param onLoad callback called when the texture is loaded (defaults to null)
  7948. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7949. */
  7950. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7951. /**
  7952. * Delays loading of the cube texture
  7953. * @param forcedExtension defines the extension to use
  7954. */
  7955. delayLoad(forcedExtension?: string): void;
  7956. /**
  7957. * Returns the reflection texture matrix
  7958. * @returns the reflection texture matrix
  7959. */
  7960. getReflectionTextureMatrix(): Matrix;
  7961. /**
  7962. * Sets the reflection texture matrix
  7963. * @param value Reflection texture matrix
  7964. */
  7965. setReflectionTextureMatrix(value: Matrix): void;
  7966. /**
  7967. * Parses text to create a cube texture
  7968. * @param parsedTexture define the serialized text to read from
  7969. * @param scene defines the hosting scene
  7970. * @param rootUrl defines the root url of the cube texture
  7971. * @returns a cube texture
  7972. */
  7973. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7974. /**
  7975. * Makes a clone, or deep copy, of the cube texture
  7976. * @returns a new cube texture
  7977. */
  7978. clone(): CubeTexture;
  7979. }
  7980. }
  7981. declare module BABYLON {
  7982. /**
  7983. * Manages the defines for the Material
  7984. */
  7985. export class MaterialDefines {
  7986. /** @hidden */
  7987. protected _keys: string[];
  7988. private _isDirty;
  7989. /** @hidden */
  7990. _renderId: number;
  7991. /** @hidden */
  7992. _areLightsDirty: boolean;
  7993. /** @hidden */
  7994. _areLightsDisposed: boolean;
  7995. /** @hidden */
  7996. _areAttributesDirty: boolean;
  7997. /** @hidden */
  7998. _areTexturesDirty: boolean;
  7999. /** @hidden */
  8000. _areFresnelDirty: boolean;
  8001. /** @hidden */
  8002. _areMiscDirty: boolean;
  8003. /** @hidden */
  8004. _arePrePassDirty: boolean;
  8005. /** @hidden */
  8006. _areImageProcessingDirty: boolean;
  8007. /** @hidden */
  8008. _normals: boolean;
  8009. /** @hidden */
  8010. _uvs: boolean;
  8011. /** @hidden */
  8012. _needNormals: boolean;
  8013. /** @hidden */
  8014. _needUVs: boolean;
  8015. [id: string]: any;
  8016. /**
  8017. * Specifies if the material needs to be re-calculated
  8018. */
  8019. get isDirty(): boolean;
  8020. /**
  8021. * Marks the material to indicate that it has been re-calculated
  8022. */
  8023. markAsProcessed(): void;
  8024. /**
  8025. * Marks the material to indicate that it needs to be re-calculated
  8026. */
  8027. markAsUnprocessed(): void;
  8028. /**
  8029. * Marks the material to indicate all of its defines need to be re-calculated
  8030. */
  8031. markAllAsDirty(): void;
  8032. /**
  8033. * Marks the material to indicate that image processing needs to be re-calculated
  8034. */
  8035. markAsImageProcessingDirty(): void;
  8036. /**
  8037. * Marks the material to indicate the lights need to be re-calculated
  8038. * @param disposed Defines whether the light is dirty due to dispose or not
  8039. */
  8040. markAsLightDirty(disposed?: boolean): void;
  8041. /**
  8042. * Marks the attribute state as changed
  8043. */
  8044. markAsAttributesDirty(): void;
  8045. /**
  8046. * Marks the texture state as changed
  8047. */
  8048. markAsTexturesDirty(): void;
  8049. /**
  8050. * Marks the fresnel state as changed
  8051. */
  8052. markAsFresnelDirty(): void;
  8053. /**
  8054. * Marks the misc state as changed
  8055. */
  8056. markAsMiscDirty(): void;
  8057. /**
  8058. * Marks the prepass state as changed
  8059. */
  8060. markAsPrePassDirty(): void;
  8061. /**
  8062. * Rebuilds the material defines
  8063. */
  8064. rebuild(): void;
  8065. /**
  8066. * Specifies if two material defines are equal
  8067. * @param other - A material define instance to compare to
  8068. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8069. */
  8070. isEqual(other: MaterialDefines): boolean;
  8071. /**
  8072. * Clones this instance's defines to another instance
  8073. * @param other - material defines to clone values to
  8074. */
  8075. cloneTo(other: MaterialDefines): void;
  8076. /**
  8077. * Resets the material define values
  8078. */
  8079. reset(): void;
  8080. /**
  8081. * Converts the material define values to a string
  8082. * @returns - String of material define information
  8083. */
  8084. toString(): string;
  8085. }
  8086. }
  8087. declare module BABYLON {
  8088. /**
  8089. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8090. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8091. * 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;
  8092. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8093. */
  8094. export class ColorCurves {
  8095. private _dirty;
  8096. private _tempColor;
  8097. private _globalCurve;
  8098. private _highlightsCurve;
  8099. private _midtonesCurve;
  8100. private _shadowsCurve;
  8101. private _positiveCurve;
  8102. private _negativeCurve;
  8103. private _globalHue;
  8104. private _globalDensity;
  8105. private _globalSaturation;
  8106. private _globalExposure;
  8107. /**
  8108. * Gets the global Hue value.
  8109. * 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).
  8110. */
  8111. get globalHue(): number;
  8112. /**
  8113. * Sets the global Hue value.
  8114. * 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).
  8115. */
  8116. set globalHue(value: number);
  8117. /**
  8118. * Gets the global Density value.
  8119. * 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.
  8120. * Values less than zero provide a filter of opposite hue.
  8121. */
  8122. get globalDensity(): number;
  8123. /**
  8124. * Sets the global Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. set globalDensity(value: number);
  8129. /**
  8130. * Gets the global Saturation value.
  8131. * 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.
  8132. */
  8133. get globalSaturation(): number;
  8134. /**
  8135. * Sets the global Saturation value.
  8136. * 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.
  8137. */
  8138. set globalSaturation(value: number);
  8139. /**
  8140. * Gets the global Exposure value.
  8141. * 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.
  8142. */
  8143. get globalExposure(): number;
  8144. /**
  8145. * Sets the global Exposure value.
  8146. * 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.
  8147. */
  8148. set globalExposure(value: number);
  8149. private _highlightsHue;
  8150. private _highlightsDensity;
  8151. private _highlightsSaturation;
  8152. private _highlightsExposure;
  8153. /**
  8154. * Gets the highlights Hue value.
  8155. * 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).
  8156. */
  8157. get highlightsHue(): number;
  8158. /**
  8159. * Sets the highlights Hue value.
  8160. * 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).
  8161. */
  8162. set highlightsHue(value: number);
  8163. /**
  8164. * Gets the highlights Density value.
  8165. * 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.
  8166. * Values less than zero provide a filter of opposite hue.
  8167. */
  8168. get highlightsDensity(): number;
  8169. /**
  8170. * Sets the highlights Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. set highlightsDensity(value: number);
  8175. /**
  8176. * Gets the highlights Saturation value.
  8177. * 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.
  8178. */
  8179. get highlightsSaturation(): number;
  8180. /**
  8181. * Sets the highlights Saturation value.
  8182. * 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.
  8183. */
  8184. set highlightsSaturation(value: number);
  8185. /**
  8186. * Gets the highlights Exposure value.
  8187. * 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.
  8188. */
  8189. get highlightsExposure(): number;
  8190. /**
  8191. * Sets the highlights Exposure value.
  8192. * 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.
  8193. */
  8194. set highlightsExposure(value: number);
  8195. private _midtonesHue;
  8196. private _midtonesDensity;
  8197. private _midtonesSaturation;
  8198. private _midtonesExposure;
  8199. /**
  8200. * Gets the midtones Hue value.
  8201. * 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).
  8202. */
  8203. get midtonesHue(): number;
  8204. /**
  8205. * Sets the midtones Hue value.
  8206. * 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).
  8207. */
  8208. set midtonesHue(value: number);
  8209. /**
  8210. * Gets the midtones Density value.
  8211. * 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.
  8212. * Values less than zero provide a filter of opposite hue.
  8213. */
  8214. get midtonesDensity(): number;
  8215. /**
  8216. * Sets the midtones Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. set midtonesDensity(value: number);
  8221. /**
  8222. * Gets the midtones Saturation value.
  8223. * 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.
  8224. */
  8225. get midtonesSaturation(): number;
  8226. /**
  8227. * Sets the midtones Saturation value.
  8228. * 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.
  8229. */
  8230. set midtonesSaturation(value: number);
  8231. /**
  8232. * Gets the midtones Exposure value.
  8233. * 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.
  8234. */
  8235. get midtonesExposure(): number;
  8236. /**
  8237. * Sets the midtones Exposure value.
  8238. * 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.
  8239. */
  8240. set midtonesExposure(value: number);
  8241. private _shadowsHue;
  8242. private _shadowsDensity;
  8243. private _shadowsSaturation;
  8244. private _shadowsExposure;
  8245. /**
  8246. * Gets the shadows Hue value.
  8247. * 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).
  8248. */
  8249. get shadowsHue(): number;
  8250. /**
  8251. * Sets the shadows Hue value.
  8252. * 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).
  8253. */
  8254. set shadowsHue(value: number);
  8255. /**
  8256. * Gets the shadows Density value.
  8257. * 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.
  8258. * Values less than zero provide a filter of opposite hue.
  8259. */
  8260. get shadowsDensity(): number;
  8261. /**
  8262. * Sets the shadows Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. set shadowsDensity(value: number);
  8267. /**
  8268. * Gets the shadows Saturation value.
  8269. * 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.
  8270. */
  8271. get shadowsSaturation(): number;
  8272. /**
  8273. * Sets the shadows Saturation value.
  8274. * 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.
  8275. */
  8276. set shadowsSaturation(value: number);
  8277. /**
  8278. * Gets the shadows Exposure value.
  8279. * 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.
  8280. */
  8281. get shadowsExposure(): number;
  8282. /**
  8283. * Sets the shadows Exposure value.
  8284. * 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.
  8285. */
  8286. set shadowsExposure(value: number);
  8287. /**
  8288. * Returns the class name
  8289. * @returns The class name
  8290. */
  8291. getClassName(): string;
  8292. /**
  8293. * Binds the color curves to the shader.
  8294. * @param colorCurves The color curve to bind
  8295. * @param effect The effect to bind to
  8296. * @param positiveUniform The positive uniform shader parameter
  8297. * @param neutralUniform The neutral uniform shader parameter
  8298. * @param negativeUniform The negative uniform shader parameter
  8299. */
  8300. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8301. /**
  8302. * Prepare the list of uniforms associated with the ColorCurves effects.
  8303. * @param uniformsList The list of uniforms used in the effect
  8304. */
  8305. static PrepareUniforms(uniformsList: string[]): void;
  8306. /**
  8307. * Returns color grading data based on a hue, density, saturation and exposure value.
  8308. * @param filterHue The hue of the color filter.
  8309. * @param filterDensity The density of the color filter.
  8310. * @param saturation The saturation.
  8311. * @param exposure The exposure.
  8312. * @param result The result data container.
  8313. */
  8314. private getColorGradingDataToRef;
  8315. /**
  8316. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8317. * @param value The input slider value in range [-100,100].
  8318. * @returns Adjusted value.
  8319. */
  8320. private static applyColorGradingSliderNonlinear;
  8321. /**
  8322. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8323. * @param hue The hue (H) input.
  8324. * @param saturation The saturation (S) input.
  8325. * @param brightness The brightness (B) input.
  8326. * @result An RGBA color represented as Vector4.
  8327. */
  8328. private static fromHSBToRef;
  8329. /**
  8330. * Returns a value clamped between min and max
  8331. * @param value The value to clamp
  8332. * @param min The minimum of value
  8333. * @param max The maximum of value
  8334. * @returns The clamped value.
  8335. */
  8336. private static clamp;
  8337. /**
  8338. * Clones the current color curve instance.
  8339. * @return The cloned curves
  8340. */
  8341. clone(): ColorCurves;
  8342. /**
  8343. * Serializes the current color curve instance to a json representation.
  8344. * @return a JSON representation
  8345. */
  8346. serialize(): any;
  8347. /**
  8348. * Parses the color curve from a json representation.
  8349. * @param source the JSON source to parse
  8350. * @return The parsed curves
  8351. */
  8352. static Parse(source: any): ColorCurves;
  8353. }
  8354. }
  8355. declare module BABYLON {
  8356. /**
  8357. * Interface to follow in your material defines to integrate easily the
  8358. * Image proccessing functions.
  8359. * @hidden
  8360. */
  8361. export interface IImageProcessingConfigurationDefines {
  8362. IMAGEPROCESSING: boolean;
  8363. VIGNETTE: boolean;
  8364. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8365. VIGNETTEBLENDMODEOPAQUE: boolean;
  8366. TONEMAPPING: boolean;
  8367. TONEMAPPING_ACES: boolean;
  8368. CONTRAST: boolean;
  8369. EXPOSURE: boolean;
  8370. COLORCURVES: boolean;
  8371. COLORGRADING: boolean;
  8372. COLORGRADING3D: boolean;
  8373. SAMPLER3DGREENDEPTH: boolean;
  8374. SAMPLER3DBGRMAP: boolean;
  8375. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8376. }
  8377. /**
  8378. * @hidden
  8379. */
  8380. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8381. IMAGEPROCESSING: boolean;
  8382. VIGNETTE: boolean;
  8383. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8384. VIGNETTEBLENDMODEOPAQUE: boolean;
  8385. TONEMAPPING: boolean;
  8386. TONEMAPPING_ACES: boolean;
  8387. CONTRAST: boolean;
  8388. COLORCURVES: boolean;
  8389. COLORGRADING: boolean;
  8390. COLORGRADING3D: boolean;
  8391. SAMPLER3DGREENDEPTH: boolean;
  8392. SAMPLER3DBGRMAP: boolean;
  8393. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8394. EXPOSURE: boolean;
  8395. constructor();
  8396. }
  8397. /**
  8398. * This groups together the common properties used for image processing either in direct forward pass
  8399. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8400. * or not.
  8401. */
  8402. export class ImageProcessingConfiguration {
  8403. /**
  8404. * Default tone mapping applied in BabylonJS.
  8405. */
  8406. static readonly TONEMAPPING_STANDARD: number;
  8407. /**
  8408. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8409. * to other engines rendering to increase portability.
  8410. */
  8411. static readonly TONEMAPPING_ACES: number;
  8412. /**
  8413. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8414. */
  8415. colorCurves: Nullable<ColorCurves>;
  8416. private _colorCurvesEnabled;
  8417. /**
  8418. * Gets wether the color curves effect is enabled.
  8419. */
  8420. get colorCurvesEnabled(): boolean;
  8421. /**
  8422. * Sets wether the color curves effect is enabled.
  8423. */
  8424. set colorCurvesEnabled(value: boolean);
  8425. private _colorGradingTexture;
  8426. /**
  8427. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8428. */
  8429. get colorGradingTexture(): Nullable<BaseTexture>;
  8430. /**
  8431. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8432. */
  8433. set colorGradingTexture(value: Nullable<BaseTexture>);
  8434. private _colorGradingEnabled;
  8435. /**
  8436. * Gets wether the color grading effect is enabled.
  8437. */
  8438. get colorGradingEnabled(): boolean;
  8439. /**
  8440. * Sets wether the color grading effect is enabled.
  8441. */
  8442. set colorGradingEnabled(value: boolean);
  8443. private _colorGradingWithGreenDepth;
  8444. /**
  8445. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8446. */
  8447. get colorGradingWithGreenDepth(): boolean;
  8448. /**
  8449. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8450. */
  8451. set colorGradingWithGreenDepth(value: boolean);
  8452. private _colorGradingBGR;
  8453. /**
  8454. * Gets wether the color grading texture contains BGR values.
  8455. */
  8456. get colorGradingBGR(): boolean;
  8457. /**
  8458. * Sets wether the color grading texture contains BGR values.
  8459. */
  8460. set colorGradingBGR(value: boolean);
  8461. /** @hidden */
  8462. _exposure: number;
  8463. /**
  8464. * Gets the Exposure used in the effect.
  8465. */
  8466. get exposure(): number;
  8467. /**
  8468. * Sets the Exposure used in the effect.
  8469. */
  8470. set exposure(value: number);
  8471. private _toneMappingEnabled;
  8472. /**
  8473. * Gets wether the tone mapping effect is enabled.
  8474. */
  8475. get toneMappingEnabled(): boolean;
  8476. /**
  8477. * Sets wether the tone mapping effect is enabled.
  8478. */
  8479. set toneMappingEnabled(value: boolean);
  8480. private _toneMappingType;
  8481. /**
  8482. * Gets the type of tone mapping effect.
  8483. */
  8484. get toneMappingType(): number;
  8485. /**
  8486. * Sets the type of tone mapping effect used in BabylonJS.
  8487. */
  8488. set toneMappingType(value: number);
  8489. protected _contrast: number;
  8490. /**
  8491. * Gets the contrast used in the effect.
  8492. */
  8493. get contrast(): number;
  8494. /**
  8495. * Sets the contrast used in the effect.
  8496. */
  8497. set contrast(value: number);
  8498. /**
  8499. * Vignette stretch size.
  8500. */
  8501. vignetteStretch: number;
  8502. /**
  8503. * Vignette centre X Offset.
  8504. */
  8505. vignetteCentreX: number;
  8506. /**
  8507. * Vignette centre Y Offset.
  8508. */
  8509. vignetteCentreY: number;
  8510. /**
  8511. * Vignette weight or intensity of the vignette effect.
  8512. */
  8513. vignetteWeight: number;
  8514. /**
  8515. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8516. * if vignetteEnabled is set to true.
  8517. */
  8518. vignetteColor: Color4;
  8519. /**
  8520. * Camera field of view used by the Vignette effect.
  8521. */
  8522. vignetteCameraFov: number;
  8523. private _vignetteBlendMode;
  8524. /**
  8525. * Gets the vignette blend mode allowing different kind of effect.
  8526. */
  8527. get vignetteBlendMode(): number;
  8528. /**
  8529. * Sets the vignette blend mode allowing different kind of effect.
  8530. */
  8531. set vignetteBlendMode(value: number);
  8532. private _vignetteEnabled;
  8533. /**
  8534. * Gets wether the vignette effect is enabled.
  8535. */
  8536. get vignetteEnabled(): boolean;
  8537. /**
  8538. * Sets wether the vignette effect is enabled.
  8539. */
  8540. set vignetteEnabled(value: boolean);
  8541. private _applyByPostProcess;
  8542. /**
  8543. * Gets wether the image processing is applied through a post process or not.
  8544. */
  8545. get applyByPostProcess(): boolean;
  8546. /**
  8547. * Sets wether the image processing is applied through a post process or not.
  8548. */
  8549. set applyByPostProcess(value: boolean);
  8550. private _isEnabled;
  8551. /**
  8552. * Gets wether the image processing is enabled or not.
  8553. */
  8554. get isEnabled(): boolean;
  8555. /**
  8556. * Sets wether the image processing is enabled or not.
  8557. */
  8558. set isEnabled(value: boolean);
  8559. /**
  8560. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8561. */
  8562. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8563. /**
  8564. * Method called each time the image processing information changes requires to recompile the effect.
  8565. */
  8566. protected _updateParameters(): void;
  8567. /**
  8568. * Gets the current class name.
  8569. * @return "ImageProcessingConfiguration"
  8570. */
  8571. getClassName(): string;
  8572. /**
  8573. * Prepare the list of uniforms associated with the Image Processing effects.
  8574. * @param uniforms The list of uniforms used in the effect
  8575. * @param defines the list of defines currently in use
  8576. */
  8577. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8578. /**
  8579. * Prepare the list of samplers associated with the Image Processing effects.
  8580. * @param samplersList The list of uniforms used in the effect
  8581. * @param defines the list of defines currently in use
  8582. */
  8583. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8584. /**
  8585. * Prepare the list of defines associated to the shader.
  8586. * @param defines the list of defines to complete
  8587. * @param forPostProcess Define if we are currently in post process mode or not
  8588. */
  8589. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8590. /**
  8591. * Returns true if all the image processing information are ready.
  8592. * @returns True if ready, otherwise, false
  8593. */
  8594. isReady(): boolean;
  8595. /**
  8596. * Binds the image processing to the shader.
  8597. * @param effect The effect to bind to
  8598. * @param overrideAspectRatio Override the aspect ratio of the effect
  8599. */
  8600. bind(effect: Effect, overrideAspectRatio?: number): void;
  8601. /**
  8602. * Clones the current image processing instance.
  8603. * @return The cloned image processing
  8604. */
  8605. clone(): ImageProcessingConfiguration;
  8606. /**
  8607. * Serializes the current image processing instance to a json representation.
  8608. * @return a JSON representation
  8609. */
  8610. serialize(): any;
  8611. /**
  8612. * Parses the image processing from a json representation.
  8613. * @param source the JSON source to parse
  8614. * @return The parsed image processing
  8615. */
  8616. static Parse(source: any): ImageProcessingConfiguration;
  8617. private static _VIGNETTEMODE_MULTIPLY;
  8618. private static _VIGNETTEMODE_OPAQUE;
  8619. /**
  8620. * Used to apply the vignette as a mix with the pixel color.
  8621. */
  8622. static get VIGNETTEMODE_MULTIPLY(): number;
  8623. /**
  8624. * Used to apply the vignette as a replacement of the pixel color.
  8625. */
  8626. static get VIGNETTEMODE_OPAQUE(): number;
  8627. }
  8628. }
  8629. declare module BABYLON {
  8630. /** @hidden */
  8631. export var postprocessVertexShader: {
  8632. name: string;
  8633. shader: string;
  8634. };
  8635. }
  8636. declare module BABYLON {
  8637. /**
  8638. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8639. */
  8640. export type RenderTargetTextureSize = number | {
  8641. width: number;
  8642. height: number;
  8643. layers?: number;
  8644. };
  8645. interface ThinEngine {
  8646. /**
  8647. * Creates a new render target texture
  8648. * @param size defines the size of the texture
  8649. * @param options defines the options used to create the texture
  8650. * @returns a new render target texture stored in an InternalTexture
  8651. */
  8652. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8653. /**
  8654. * Creates a depth stencil texture.
  8655. * This is only available in WebGL 2 or with the depth texture extension available.
  8656. * @param size The size of face edge in the texture.
  8657. * @param options The options defining the texture.
  8658. * @returns The texture
  8659. */
  8660. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8661. /** @hidden */
  8662. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8663. }
  8664. }
  8665. declare module BABYLON {
  8666. /**
  8667. * Defines the kind of connection point for node based material
  8668. */
  8669. export enum NodeMaterialBlockConnectionPointTypes {
  8670. /** Float */
  8671. Float = 1,
  8672. /** Int */
  8673. Int = 2,
  8674. /** Vector2 */
  8675. Vector2 = 4,
  8676. /** Vector3 */
  8677. Vector3 = 8,
  8678. /** Vector4 */
  8679. Vector4 = 16,
  8680. /** Color3 */
  8681. Color3 = 32,
  8682. /** Color4 */
  8683. Color4 = 64,
  8684. /** Matrix */
  8685. Matrix = 128,
  8686. /** Custom object */
  8687. Object = 256,
  8688. /** Detect type based on connection */
  8689. AutoDetect = 1024,
  8690. /** Output type that will be defined by input type */
  8691. BasedOnInput = 2048
  8692. }
  8693. }
  8694. declare module BABYLON {
  8695. /**
  8696. * Enum used to define the target of a block
  8697. */
  8698. export enum NodeMaterialBlockTargets {
  8699. /** Vertex shader */
  8700. Vertex = 1,
  8701. /** Fragment shader */
  8702. Fragment = 2,
  8703. /** Neutral */
  8704. Neutral = 4,
  8705. /** Vertex and Fragment */
  8706. VertexAndFragment = 3
  8707. }
  8708. }
  8709. declare module BABYLON {
  8710. /**
  8711. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8712. */
  8713. export enum NodeMaterialBlockConnectionPointMode {
  8714. /** Value is an uniform */
  8715. Uniform = 0,
  8716. /** Value is a mesh attribute */
  8717. Attribute = 1,
  8718. /** Value is a varying between vertex and fragment shaders */
  8719. Varying = 2,
  8720. /** Mode is undefined */
  8721. Undefined = 3
  8722. }
  8723. }
  8724. declare module BABYLON {
  8725. /**
  8726. * Enum used to define system values e.g. values automatically provided by the system
  8727. */
  8728. export enum NodeMaterialSystemValues {
  8729. /** World */
  8730. World = 1,
  8731. /** View */
  8732. View = 2,
  8733. /** Projection */
  8734. Projection = 3,
  8735. /** ViewProjection */
  8736. ViewProjection = 4,
  8737. /** WorldView */
  8738. WorldView = 5,
  8739. /** WorldViewProjection */
  8740. WorldViewProjection = 6,
  8741. /** CameraPosition */
  8742. CameraPosition = 7,
  8743. /** Fog Color */
  8744. FogColor = 8,
  8745. /** Delta time */
  8746. DeltaTime = 9
  8747. }
  8748. }
  8749. declare module BABYLON {
  8750. /** Defines supported spaces */
  8751. export enum Space {
  8752. /** Local (object) space */
  8753. LOCAL = 0,
  8754. /** World space */
  8755. WORLD = 1,
  8756. /** Bone space */
  8757. BONE = 2
  8758. }
  8759. /** Defines the 3 main axes */
  8760. export class Axis {
  8761. /** X axis */
  8762. static X: Vector3;
  8763. /** Y axis */
  8764. static Y: Vector3;
  8765. /** Z axis */
  8766. static Z: Vector3;
  8767. }
  8768. }
  8769. declare module BABYLON {
  8770. /**
  8771. * Represents a camera frustum
  8772. */
  8773. export class Frustum {
  8774. /**
  8775. * Gets the planes representing the frustum
  8776. * @param transform matrix to be applied to the returned planes
  8777. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8778. */
  8779. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8780. /**
  8781. * Gets the near frustum plane transformed by the transform matrix
  8782. * @param transform transformation matrix to be applied to the resulting frustum plane
  8783. * @param frustumPlane the resuling frustum plane
  8784. */
  8785. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8786. /**
  8787. * Gets the far frustum plane transformed by the transform matrix
  8788. * @param transform transformation matrix to be applied to the resulting frustum plane
  8789. * @param frustumPlane the resuling frustum plane
  8790. */
  8791. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8792. /**
  8793. * Gets the left frustum plane transformed by the transform matrix
  8794. * @param transform transformation matrix to be applied to the resulting frustum plane
  8795. * @param frustumPlane the resuling frustum plane
  8796. */
  8797. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8798. /**
  8799. * Gets the right frustum plane transformed by the transform matrix
  8800. * @param transform transformation matrix to be applied to the resulting frustum plane
  8801. * @param frustumPlane the resuling frustum plane
  8802. */
  8803. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8804. /**
  8805. * Gets the top frustum plane transformed by the transform matrix
  8806. * @param transform transformation matrix to be applied to the resulting frustum plane
  8807. * @param frustumPlane the resuling frustum plane
  8808. */
  8809. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8810. /**
  8811. * Gets the bottom frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8818. * @param transform transformation matrix to be applied to the resulting frustum planes
  8819. * @param frustumPlanes the resuling frustum planes
  8820. */
  8821. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8822. }
  8823. }
  8824. declare module BABYLON {
  8825. /**
  8826. * Interface for the size containing width and height
  8827. */
  8828. export interface ISize {
  8829. /**
  8830. * Width
  8831. */
  8832. width: number;
  8833. /**
  8834. * Heighht
  8835. */
  8836. height: number;
  8837. }
  8838. /**
  8839. * Size containing widht and height
  8840. */
  8841. export class Size implements ISize {
  8842. /**
  8843. * Width
  8844. */
  8845. width: number;
  8846. /**
  8847. * Height
  8848. */
  8849. height: number;
  8850. /**
  8851. * Creates a Size object from the given width and height (floats).
  8852. * @param width width of the new size
  8853. * @param height height of the new size
  8854. */
  8855. constructor(width: number, height: number);
  8856. /**
  8857. * Returns a string with the Size width and height
  8858. * @returns a string with the Size width and height
  8859. */
  8860. toString(): string;
  8861. /**
  8862. * "Size"
  8863. * @returns the string "Size"
  8864. */
  8865. getClassName(): string;
  8866. /**
  8867. * Returns the Size hash code.
  8868. * @returns a hash code for a unique width and height
  8869. */
  8870. getHashCode(): number;
  8871. /**
  8872. * Updates the current size from the given one.
  8873. * @param src the given size
  8874. */
  8875. copyFrom(src: Size): void;
  8876. /**
  8877. * Updates in place the current Size from the given floats.
  8878. * @param width width of the new size
  8879. * @param height height of the new size
  8880. * @returns the updated Size.
  8881. */
  8882. copyFromFloats(width: number, height: number): Size;
  8883. /**
  8884. * Updates in place the current Size from the given floats.
  8885. * @param width width to set
  8886. * @param height height to set
  8887. * @returns the updated Size.
  8888. */
  8889. set(width: number, height: number): Size;
  8890. /**
  8891. * Multiplies the width and height by numbers
  8892. * @param w factor to multiple the width by
  8893. * @param h factor to multiple the height by
  8894. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8895. */
  8896. multiplyByFloats(w: number, h: number): Size;
  8897. /**
  8898. * Clones the size
  8899. * @returns a new Size copied from the given one.
  8900. */
  8901. clone(): Size;
  8902. /**
  8903. * True if the current Size and the given one width and height are strictly equal.
  8904. * @param other the other size to compare against
  8905. * @returns True if the current Size and the given one width and height are strictly equal.
  8906. */
  8907. equals(other: Size): boolean;
  8908. /**
  8909. * The surface of the Size : width * height (float).
  8910. */
  8911. get surface(): number;
  8912. /**
  8913. * Create a new size of zero
  8914. * @returns a new Size set to (0.0, 0.0)
  8915. */
  8916. static Zero(): Size;
  8917. /**
  8918. * Sums the width and height of two sizes
  8919. * @param otherSize size to add to this size
  8920. * @returns a new Size set as the addition result of the current Size and the given one.
  8921. */
  8922. add(otherSize: Size): Size;
  8923. /**
  8924. * Subtracts the width and height of two
  8925. * @param otherSize size to subtract to this size
  8926. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8927. */
  8928. subtract(otherSize: Size): Size;
  8929. /**
  8930. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8931. * @param start starting size to lerp between
  8932. * @param end end size to lerp between
  8933. * @param amount amount to lerp between the start and end values
  8934. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8935. */
  8936. static Lerp(start: Size, end: Size, amount: number): Size;
  8937. }
  8938. }
  8939. declare module BABYLON {
  8940. /**
  8941. * Contains position and normal vectors for a vertex
  8942. */
  8943. export class PositionNormalVertex {
  8944. /** the position of the vertex (defaut: 0,0,0) */
  8945. position: Vector3;
  8946. /** the normal of the vertex (defaut: 0,1,0) */
  8947. normal: Vector3;
  8948. /**
  8949. * Creates a PositionNormalVertex
  8950. * @param position the position of the vertex (defaut: 0,0,0)
  8951. * @param normal the normal of the vertex (defaut: 0,1,0)
  8952. */
  8953. constructor(
  8954. /** the position of the vertex (defaut: 0,0,0) */
  8955. position?: Vector3,
  8956. /** the normal of the vertex (defaut: 0,1,0) */
  8957. normal?: Vector3);
  8958. /**
  8959. * Clones the PositionNormalVertex
  8960. * @returns the cloned PositionNormalVertex
  8961. */
  8962. clone(): PositionNormalVertex;
  8963. }
  8964. /**
  8965. * Contains position, normal and uv vectors for a vertex
  8966. */
  8967. export class PositionNormalTextureVertex {
  8968. /** the position of the vertex (defaut: 0,0,0) */
  8969. position: Vector3;
  8970. /** the normal of the vertex (defaut: 0,1,0) */
  8971. normal: Vector3;
  8972. /** the uv of the vertex (default: 0,0) */
  8973. uv: Vector2;
  8974. /**
  8975. * Creates a PositionNormalTextureVertex
  8976. * @param position the position of the vertex (defaut: 0,0,0)
  8977. * @param normal the normal of the vertex (defaut: 0,1,0)
  8978. * @param uv the uv of the vertex (default: 0,0)
  8979. */
  8980. constructor(
  8981. /** the position of the vertex (defaut: 0,0,0) */
  8982. position?: Vector3,
  8983. /** the normal of the vertex (defaut: 0,1,0) */
  8984. normal?: Vector3,
  8985. /** the uv of the vertex (default: 0,0) */
  8986. uv?: Vector2);
  8987. /**
  8988. * Clones the PositionNormalTextureVertex
  8989. * @returns the cloned PositionNormalTextureVertex
  8990. */
  8991. clone(): PositionNormalTextureVertex;
  8992. }
  8993. }
  8994. declare module BABYLON {
  8995. /**
  8996. * Enum defining the type of animations supported by InputBlock
  8997. */
  8998. export enum AnimatedInputBlockTypes {
  8999. /** No animation */
  9000. None = 0,
  9001. /** Time based animation. Will only work for floats */
  9002. Time = 1
  9003. }
  9004. }
  9005. declare module BABYLON {
  9006. /**
  9007. * Interface describing all the common properties and methods a shadow light needs to implement.
  9008. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9009. * as well as binding the different shadow properties to the effects.
  9010. */
  9011. export interface IShadowLight extends Light {
  9012. /**
  9013. * The light id in the scene (used in scene.findLighById for instance)
  9014. */
  9015. id: string;
  9016. /**
  9017. * The position the shdow will be casted from.
  9018. */
  9019. position: Vector3;
  9020. /**
  9021. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9022. */
  9023. direction: Vector3;
  9024. /**
  9025. * The transformed position. Position of the light in world space taking parenting in account.
  9026. */
  9027. transformedPosition: Vector3;
  9028. /**
  9029. * The transformed direction. Direction of the light in world space taking parenting in account.
  9030. */
  9031. transformedDirection: Vector3;
  9032. /**
  9033. * The friendly name of the light in the scene.
  9034. */
  9035. name: string;
  9036. /**
  9037. * Defines the shadow projection clipping minimum z value.
  9038. */
  9039. shadowMinZ: number;
  9040. /**
  9041. * Defines the shadow projection clipping maximum z value.
  9042. */
  9043. shadowMaxZ: number;
  9044. /**
  9045. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9046. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9047. */
  9048. computeTransformedInformation(): boolean;
  9049. /**
  9050. * Gets the scene the light belongs to.
  9051. * @returns The scene
  9052. */
  9053. getScene(): Scene;
  9054. /**
  9055. * Callback defining a custom Projection Matrix Builder.
  9056. * This can be used to override the default projection matrix computation.
  9057. */
  9058. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9059. /**
  9060. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9061. * @param matrix The materix to updated with the projection information
  9062. * @param viewMatrix The transform matrix of the light
  9063. * @param renderList The list of mesh to render in the map
  9064. * @returns The current light
  9065. */
  9066. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9067. /**
  9068. * Gets the current depth scale used in ESM.
  9069. * @returns The scale
  9070. */
  9071. getDepthScale(): number;
  9072. /**
  9073. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9074. * @returns true if a cube texture needs to be use
  9075. */
  9076. needCube(): boolean;
  9077. /**
  9078. * Detects if the projection matrix requires to be recomputed this frame.
  9079. * @returns true if it requires to be recomputed otherwise, false.
  9080. */
  9081. needProjectionMatrixCompute(): boolean;
  9082. /**
  9083. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9084. */
  9085. forceProjectionMatrixCompute(): void;
  9086. /**
  9087. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9088. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9089. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9090. */
  9091. getShadowDirection(faceIndex?: number): Vector3;
  9092. /**
  9093. * Gets the minZ used for shadow according to both the scene and the light.
  9094. * @param activeCamera The camera we are returning the min for
  9095. * @returns the depth min z
  9096. */
  9097. getDepthMinZ(activeCamera: Camera): number;
  9098. /**
  9099. * Gets the maxZ used for shadow according to both the scene and the light.
  9100. * @param activeCamera The camera we are returning the max for
  9101. * @returns the depth max z
  9102. */
  9103. getDepthMaxZ(activeCamera: Camera): number;
  9104. }
  9105. /**
  9106. * Base implementation IShadowLight
  9107. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9108. */
  9109. export abstract class ShadowLight extends Light implements IShadowLight {
  9110. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9111. protected _position: Vector3;
  9112. protected _setPosition(value: Vector3): void;
  9113. /**
  9114. * Sets the position the shadow will be casted from. Also use as the light position for both
  9115. * point and spot lights.
  9116. */
  9117. get position(): Vector3;
  9118. /**
  9119. * Sets the position the shadow will be casted from. Also use as the light position for both
  9120. * point and spot lights.
  9121. */
  9122. set position(value: Vector3);
  9123. protected _direction: Vector3;
  9124. protected _setDirection(value: Vector3): void;
  9125. /**
  9126. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9127. * Also use as the light direction on spot and directional lights.
  9128. */
  9129. get direction(): Vector3;
  9130. /**
  9131. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9132. * Also use as the light direction on spot and directional lights.
  9133. */
  9134. set direction(value: Vector3);
  9135. protected _shadowMinZ: number;
  9136. /**
  9137. * Gets the shadow projection clipping minimum z value.
  9138. */
  9139. get shadowMinZ(): number;
  9140. /**
  9141. * Sets the shadow projection clipping minimum z value.
  9142. */
  9143. set shadowMinZ(value: number);
  9144. protected _shadowMaxZ: number;
  9145. /**
  9146. * Sets the shadow projection clipping maximum z value.
  9147. */
  9148. get shadowMaxZ(): number;
  9149. /**
  9150. * Gets the shadow projection clipping maximum z value.
  9151. */
  9152. set shadowMaxZ(value: number);
  9153. /**
  9154. * Callback defining a custom Projection Matrix Builder.
  9155. * This can be used to override the default projection matrix computation.
  9156. */
  9157. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9158. /**
  9159. * The transformed position. Position of the light in world space taking parenting in account.
  9160. */
  9161. transformedPosition: Vector3;
  9162. /**
  9163. * The transformed direction. Direction of the light in world space taking parenting in account.
  9164. */
  9165. transformedDirection: Vector3;
  9166. private _needProjectionMatrixCompute;
  9167. /**
  9168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9170. */
  9171. computeTransformedInformation(): boolean;
  9172. /**
  9173. * Return the depth scale used for the shadow map.
  9174. * @returns the depth scale.
  9175. */
  9176. getDepthScale(): number;
  9177. /**
  9178. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9179. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9180. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9181. */
  9182. getShadowDirection(faceIndex?: number): Vector3;
  9183. /**
  9184. * Returns the ShadowLight absolute position in the World.
  9185. * @returns the position vector in world space
  9186. */
  9187. getAbsolutePosition(): Vector3;
  9188. /**
  9189. * Sets the ShadowLight direction toward the passed target.
  9190. * @param target The point to target in local space
  9191. * @returns the updated ShadowLight direction
  9192. */
  9193. setDirectionToTarget(target: Vector3): Vector3;
  9194. /**
  9195. * Returns the light rotation in euler definition.
  9196. * @returns the x y z rotation in local space.
  9197. */
  9198. getRotation(): Vector3;
  9199. /**
  9200. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9201. * @returns true if a cube texture needs to be use
  9202. */
  9203. needCube(): boolean;
  9204. /**
  9205. * Detects if the projection matrix requires to be recomputed this frame.
  9206. * @returns true if it requires to be recomputed otherwise, false.
  9207. */
  9208. needProjectionMatrixCompute(): boolean;
  9209. /**
  9210. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9211. */
  9212. forceProjectionMatrixCompute(): void;
  9213. /** @hidden */
  9214. _initCache(): void;
  9215. /** @hidden */
  9216. _isSynchronized(): boolean;
  9217. /**
  9218. * Computes the world matrix of the node
  9219. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9220. * @returns the world matrix
  9221. */
  9222. computeWorldMatrix(force?: boolean): Matrix;
  9223. /**
  9224. * Gets the minZ used for shadow according to both the scene and the light.
  9225. * @param activeCamera The camera we are returning the min for
  9226. * @returns the depth min z
  9227. */
  9228. getDepthMinZ(activeCamera: Camera): number;
  9229. /**
  9230. * Gets the maxZ used for shadow according to both the scene and the light.
  9231. * @param activeCamera The camera we are returning the max for
  9232. * @returns the depth max z
  9233. */
  9234. getDepthMaxZ(activeCamera: Camera): number;
  9235. /**
  9236. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9237. * @param matrix The materix to updated with the projection information
  9238. * @param viewMatrix The transform matrix of the light
  9239. * @param renderList The list of mesh to render in the map
  9240. * @returns The current light
  9241. */
  9242. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9243. }
  9244. }
  9245. declare module BABYLON {
  9246. /** @hidden */
  9247. export var packingFunctions: {
  9248. name: string;
  9249. shader: string;
  9250. };
  9251. }
  9252. declare module BABYLON {
  9253. /** @hidden */
  9254. export var bayerDitherFunctions: {
  9255. name: string;
  9256. shader: string;
  9257. };
  9258. }
  9259. declare module BABYLON {
  9260. /** @hidden */
  9261. export var shadowMapFragmentDeclaration: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module BABYLON {
  9267. /** @hidden */
  9268. export var clipPlaneFragmentDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module BABYLON {
  9274. /** @hidden */
  9275. export var clipPlaneFragment: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module BABYLON {
  9281. /** @hidden */
  9282. export var shadowMapFragment: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module BABYLON {
  9288. /** @hidden */
  9289. export var shadowMapPixelShader: {
  9290. name: string;
  9291. shader: string;
  9292. };
  9293. }
  9294. declare module BABYLON {
  9295. /** @hidden */
  9296. export var bonesDeclaration: {
  9297. name: string;
  9298. shader: string;
  9299. };
  9300. }
  9301. declare module BABYLON {
  9302. /** @hidden */
  9303. export var morphTargetsVertexGlobalDeclaration: {
  9304. name: string;
  9305. shader: string;
  9306. };
  9307. }
  9308. declare module BABYLON {
  9309. /** @hidden */
  9310. export var morphTargetsVertexDeclaration: {
  9311. name: string;
  9312. shader: string;
  9313. };
  9314. }
  9315. declare module BABYLON {
  9316. /** @hidden */
  9317. export var instancesDeclaration: {
  9318. name: string;
  9319. shader: string;
  9320. };
  9321. }
  9322. declare module BABYLON {
  9323. /** @hidden */
  9324. export var helperFunctions: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module BABYLON {
  9330. /** @hidden */
  9331. export var shadowMapVertexDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module BABYLON {
  9337. /** @hidden */
  9338. export var clipPlaneVertexDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module BABYLON {
  9344. /** @hidden */
  9345. export var morphTargetsVertex: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module BABYLON {
  9351. /** @hidden */
  9352. export var instancesVertex: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module BABYLON {
  9358. /** @hidden */
  9359. export var bonesVertex: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module BABYLON {
  9365. /** @hidden */
  9366. export var shadowMapVertexNormalBias: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module BABYLON {
  9372. /** @hidden */
  9373. export var shadowMapVertexMetric: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module BABYLON {
  9379. /** @hidden */
  9380. export var clipPlaneVertex: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module BABYLON {
  9386. /** @hidden */
  9387. export var shadowMapVertexShader: {
  9388. name: string;
  9389. shader: string;
  9390. };
  9391. }
  9392. declare module BABYLON {
  9393. /** @hidden */
  9394. export var depthBoxBlurPixelShader: {
  9395. name: string;
  9396. shader: string;
  9397. };
  9398. }
  9399. declare module BABYLON {
  9400. /** @hidden */
  9401. export var shadowMapFragmentSoftTransparentShadow: {
  9402. name: string;
  9403. shader: string;
  9404. };
  9405. }
  9406. declare module BABYLON {
  9407. /**
  9408. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9409. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9410. */
  9411. export class EffectFallbacks implements IEffectFallbacks {
  9412. private _defines;
  9413. private _currentRank;
  9414. private _maxRank;
  9415. private _mesh;
  9416. /**
  9417. * Removes the fallback from the bound mesh.
  9418. */
  9419. unBindMesh(): void;
  9420. /**
  9421. * Adds a fallback on the specified property.
  9422. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9423. * @param define The name of the define in the shader
  9424. */
  9425. addFallback(rank: number, define: string): void;
  9426. /**
  9427. * Sets the mesh to use CPU skinning when needing to fallback.
  9428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9429. * @param mesh The mesh to use the fallbacks.
  9430. */
  9431. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9432. /**
  9433. * Checks to see if more fallbacks are still availible.
  9434. */
  9435. get hasMoreFallbacks(): boolean;
  9436. /**
  9437. * Removes the defines that should be removed when falling back.
  9438. * @param currentDefines defines the current define statements for the shader.
  9439. * @param effect defines the current effect we try to compile
  9440. * @returns The resulting defines with defines of the current rank removed.
  9441. */
  9442. reduce(currentDefines: string, effect: Effect): string;
  9443. }
  9444. }
  9445. declare module BABYLON {
  9446. /**
  9447. * Interface used to define Action
  9448. */
  9449. export interface IAction {
  9450. /**
  9451. * Trigger for the action
  9452. */
  9453. trigger: number;
  9454. /** Options of the trigger */
  9455. triggerOptions: any;
  9456. /**
  9457. * Gets the trigger parameters
  9458. * @returns the trigger parameters
  9459. */
  9460. getTriggerParameter(): any;
  9461. /**
  9462. * Internal only - executes current action event
  9463. * @hidden
  9464. */
  9465. _executeCurrent(evt?: ActionEvent): void;
  9466. /**
  9467. * Serialize placeholder for child classes
  9468. * @param parent of child
  9469. * @returns the serialized object
  9470. */
  9471. serialize(parent: any): any;
  9472. /**
  9473. * Internal only
  9474. * @hidden
  9475. */
  9476. _prepare(): void;
  9477. /**
  9478. * Internal only - manager for action
  9479. * @hidden
  9480. */
  9481. _actionManager: Nullable<AbstractActionManager>;
  9482. /**
  9483. * Adds action to chain of actions, may be a DoNothingAction
  9484. * @param action defines the next action to execute
  9485. * @returns The action passed in
  9486. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9487. */
  9488. then(action: IAction): IAction;
  9489. }
  9490. /**
  9491. * The action to be carried out following a trigger
  9492. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9493. */
  9494. export class Action implements IAction {
  9495. /** the trigger, with or without parameters, for the action */
  9496. triggerOptions: any;
  9497. /**
  9498. * Trigger for the action
  9499. */
  9500. trigger: number;
  9501. /**
  9502. * Internal only - manager for action
  9503. * @hidden
  9504. */
  9505. _actionManager: ActionManager;
  9506. private _nextActiveAction;
  9507. private _child;
  9508. private _condition?;
  9509. private _triggerParameter;
  9510. /**
  9511. * An event triggered prior to action being executed.
  9512. */
  9513. onBeforeExecuteObservable: Observable<Action>;
  9514. /**
  9515. * Creates a new Action
  9516. * @param triggerOptions the trigger, with or without parameters, for the action
  9517. * @param condition an optional determinant of action
  9518. */
  9519. constructor(
  9520. /** the trigger, with or without parameters, for the action */
  9521. triggerOptions: any, condition?: Condition);
  9522. /**
  9523. * Internal only
  9524. * @hidden
  9525. */
  9526. _prepare(): void;
  9527. /**
  9528. * Gets the trigger parameters
  9529. * @returns the trigger parameters
  9530. */
  9531. getTriggerParameter(): any;
  9532. /**
  9533. * Internal only - executes current action event
  9534. * @hidden
  9535. */
  9536. _executeCurrent(evt?: ActionEvent): void;
  9537. /**
  9538. * Execute placeholder for child classes
  9539. * @param evt optional action event
  9540. */
  9541. execute(evt?: ActionEvent): void;
  9542. /**
  9543. * Skips to next active action
  9544. */
  9545. skipToNextActiveAction(): void;
  9546. /**
  9547. * Adds action to chain of actions, may be a DoNothingAction
  9548. * @param action defines the next action to execute
  9549. * @returns The action passed in
  9550. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9551. */
  9552. then(action: Action): Action;
  9553. /**
  9554. * Internal only
  9555. * @hidden
  9556. */
  9557. _getProperty(propertyPath: string): string;
  9558. /**
  9559. * Internal only
  9560. * @hidden
  9561. */
  9562. _getEffectiveTarget(target: any, propertyPath: string): any;
  9563. /**
  9564. * Serialize placeholder for child classes
  9565. * @param parent of child
  9566. * @returns the serialized object
  9567. */
  9568. serialize(parent: any): any;
  9569. /**
  9570. * Internal only called by serialize
  9571. * @hidden
  9572. */
  9573. protected _serialize(serializedAction: any, parent?: any): any;
  9574. /**
  9575. * Internal only
  9576. * @hidden
  9577. */
  9578. static _SerializeValueAsString: (value: any) => string;
  9579. /**
  9580. * Internal only
  9581. * @hidden
  9582. */
  9583. static _GetTargetProperty: (target: Scene | Node) => {
  9584. name: string;
  9585. targetType: string;
  9586. value: string;
  9587. };
  9588. }
  9589. }
  9590. declare module BABYLON {
  9591. /**
  9592. * A Condition applied to an Action
  9593. */
  9594. export class Condition {
  9595. /**
  9596. * Internal only - manager for action
  9597. * @hidden
  9598. */
  9599. _actionManager: ActionManager;
  9600. /**
  9601. * Internal only
  9602. * @hidden
  9603. */
  9604. _evaluationId: number;
  9605. /**
  9606. * Internal only
  9607. * @hidden
  9608. */
  9609. _currentResult: boolean;
  9610. /**
  9611. * Creates a new Condition
  9612. * @param actionManager the manager of the action the condition is applied to
  9613. */
  9614. constructor(actionManager: ActionManager);
  9615. /**
  9616. * Check if the current condition is valid
  9617. * @returns a boolean
  9618. */
  9619. isValid(): boolean;
  9620. /**
  9621. * Internal only
  9622. * @hidden
  9623. */
  9624. _getProperty(propertyPath: string): string;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. _getEffectiveTarget(target: any, propertyPath: string): any;
  9630. /**
  9631. * Serialize placeholder for child classes
  9632. * @returns the serialized object
  9633. */
  9634. serialize(): any;
  9635. /**
  9636. * Internal only
  9637. * @hidden
  9638. */
  9639. protected _serialize(serializedCondition: any): any;
  9640. }
  9641. /**
  9642. * Defines specific conditional operators as extensions of Condition
  9643. */
  9644. export class ValueCondition extends Condition {
  9645. /** path to specify the property of the target the conditional operator uses */
  9646. propertyPath: string;
  9647. /** the value compared by the conditional operator against the current value of the property */
  9648. value: any;
  9649. /** the conditional operator, default ValueCondition.IsEqual */
  9650. operator: number;
  9651. /**
  9652. * Internal only
  9653. * @hidden
  9654. */
  9655. private static _IsEqual;
  9656. /**
  9657. * Internal only
  9658. * @hidden
  9659. */
  9660. private static _IsDifferent;
  9661. /**
  9662. * Internal only
  9663. * @hidden
  9664. */
  9665. private static _IsGreater;
  9666. /**
  9667. * Internal only
  9668. * @hidden
  9669. */
  9670. private static _IsLesser;
  9671. /**
  9672. * returns the number for IsEqual
  9673. */
  9674. static get IsEqual(): number;
  9675. /**
  9676. * Returns the number for IsDifferent
  9677. */
  9678. static get IsDifferent(): number;
  9679. /**
  9680. * Returns the number for IsGreater
  9681. */
  9682. static get IsGreater(): number;
  9683. /**
  9684. * Returns the number for IsLesser
  9685. */
  9686. static get IsLesser(): number;
  9687. /**
  9688. * Internal only The action manager for the condition
  9689. * @hidden
  9690. */
  9691. _actionManager: ActionManager;
  9692. /**
  9693. * Internal only
  9694. * @hidden
  9695. */
  9696. private _target;
  9697. /**
  9698. * Internal only
  9699. * @hidden
  9700. */
  9701. private _effectiveTarget;
  9702. /**
  9703. * Internal only
  9704. * @hidden
  9705. */
  9706. private _property;
  9707. /**
  9708. * Creates a new ValueCondition
  9709. * @param actionManager manager for the action the condition applies to
  9710. * @param target for the action
  9711. * @param propertyPath path to specify the property of the target the conditional operator uses
  9712. * @param value the value compared by the conditional operator against the current value of the property
  9713. * @param operator the conditional operator, default ValueCondition.IsEqual
  9714. */
  9715. constructor(actionManager: ActionManager, target: any,
  9716. /** path to specify the property of the target the conditional operator uses */
  9717. propertyPath: string,
  9718. /** the value compared by the conditional operator against the current value of the property */
  9719. value: any,
  9720. /** the conditional operator, default ValueCondition.IsEqual */
  9721. operator?: number);
  9722. /**
  9723. * Compares the given value with the property value for the specified conditional operator
  9724. * @returns the result of the comparison
  9725. */
  9726. isValid(): boolean;
  9727. /**
  9728. * Serialize the ValueCondition into a JSON compatible object
  9729. * @returns serialization object
  9730. */
  9731. serialize(): any;
  9732. /**
  9733. * Gets the name of the conditional operator for the ValueCondition
  9734. * @param operator the conditional operator
  9735. * @returns the name
  9736. */
  9737. static GetOperatorName(operator: number): string;
  9738. }
  9739. /**
  9740. * Defines a predicate condition as an extension of Condition
  9741. */
  9742. export class PredicateCondition extends Condition {
  9743. /** defines the predicate function used to validate the condition */
  9744. predicate: () => boolean;
  9745. /**
  9746. * Internal only - manager for action
  9747. * @hidden
  9748. */
  9749. _actionManager: ActionManager;
  9750. /**
  9751. * Creates a new PredicateCondition
  9752. * @param actionManager manager for the action the condition applies to
  9753. * @param predicate defines the predicate function used to validate the condition
  9754. */
  9755. constructor(actionManager: ActionManager,
  9756. /** defines the predicate function used to validate the condition */
  9757. predicate: () => boolean);
  9758. /**
  9759. * @returns the validity of the predicate condition
  9760. */
  9761. isValid(): boolean;
  9762. }
  9763. /**
  9764. * Defines a state condition as an extension of Condition
  9765. */
  9766. export class StateCondition extends Condition {
  9767. /** Value to compare with target state */
  9768. value: string;
  9769. /**
  9770. * Internal only - manager for action
  9771. * @hidden
  9772. */
  9773. _actionManager: ActionManager;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. private _target;
  9779. /**
  9780. * Creates a new StateCondition
  9781. * @param actionManager manager for the action the condition applies to
  9782. * @param target of the condition
  9783. * @param value to compare with target state
  9784. */
  9785. constructor(actionManager: ActionManager, target: any,
  9786. /** Value to compare with target state */
  9787. value: string);
  9788. /**
  9789. * Gets a boolean indicating if the current condition is met
  9790. * @returns the validity of the state
  9791. */
  9792. isValid(): boolean;
  9793. /**
  9794. * Serialize the StateCondition into a JSON compatible object
  9795. * @returns serialization object
  9796. */
  9797. serialize(): any;
  9798. }
  9799. }
  9800. declare module BABYLON {
  9801. /**
  9802. * This defines an action responsible to toggle a boolean once triggered.
  9803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9804. */
  9805. export class SwitchBooleanAction extends Action {
  9806. /**
  9807. * The path to the boolean property in the target object
  9808. */
  9809. propertyPath: string;
  9810. private _target;
  9811. private _effectiveTarget;
  9812. private _property;
  9813. /**
  9814. * Instantiate the action
  9815. * @param triggerOptions defines the trigger options
  9816. * @param target defines the object containing the boolean
  9817. * @param propertyPath defines the path to the boolean property in the target object
  9818. * @param condition defines the trigger related conditions
  9819. */
  9820. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9821. /** @hidden */
  9822. _prepare(): void;
  9823. /**
  9824. * Execute the action toggle the boolean value.
  9825. */
  9826. execute(): void;
  9827. /**
  9828. * Serializes the actions and its related information.
  9829. * @param parent defines the object to serialize in
  9830. * @returns the serialized object
  9831. */
  9832. serialize(parent: any): any;
  9833. }
  9834. /**
  9835. * This defines an action responsible to set a the state field of the target
  9836. * to a desired value once triggered.
  9837. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9838. */
  9839. export class SetStateAction extends Action {
  9840. /**
  9841. * The value to store in the state field.
  9842. */
  9843. value: string;
  9844. private _target;
  9845. /**
  9846. * Instantiate the action
  9847. * @param triggerOptions defines the trigger options
  9848. * @param target defines the object containing the state property
  9849. * @param value defines the value to store in the state field
  9850. * @param condition defines the trigger related conditions
  9851. */
  9852. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9853. /**
  9854. * Execute the action and store the value on the target state property.
  9855. */
  9856. execute(): void;
  9857. /**
  9858. * Serializes the actions and its related information.
  9859. * @param parent defines the object to serialize in
  9860. * @returns the serialized object
  9861. */
  9862. serialize(parent: any): any;
  9863. }
  9864. /**
  9865. * This defines an action responsible to set a property of the target
  9866. * to a desired value once triggered.
  9867. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9868. */
  9869. export class SetValueAction extends Action {
  9870. /**
  9871. * The path of the property to set in the target.
  9872. */
  9873. propertyPath: string;
  9874. /**
  9875. * The value to set in the property
  9876. */
  9877. value: any;
  9878. private _target;
  9879. private _effectiveTarget;
  9880. private _property;
  9881. /**
  9882. * Instantiate the action
  9883. * @param triggerOptions defines the trigger options
  9884. * @param target defines the object containing the property
  9885. * @param propertyPath defines the path of the property to set in the target
  9886. * @param value defines the value to set in the property
  9887. * @param condition defines the trigger related conditions
  9888. */
  9889. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9890. /** @hidden */
  9891. _prepare(): void;
  9892. /**
  9893. * Execute the action and set the targetted property to the desired value.
  9894. */
  9895. execute(): void;
  9896. /**
  9897. * Serializes the actions and its related information.
  9898. * @param parent defines the object to serialize in
  9899. * @returns the serialized object
  9900. */
  9901. serialize(parent: any): any;
  9902. }
  9903. /**
  9904. * This defines an action responsible to increment the target value
  9905. * to a desired value once triggered.
  9906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9907. */
  9908. export class IncrementValueAction extends Action {
  9909. /**
  9910. * The path of the property to increment in the target.
  9911. */
  9912. propertyPath: string;
  9913. /**
  9914. * The value we should increment the property by.
  9915. */
  9916. value: any;
  9917. private _target;
  9918. private _effectiveTarget;
  9919. private _property;
  9920. /**
  9921. * Instantiate the action
  9922. * @param triggerOptions defines the trigger options
  9923. * @param target defines the object containing the property
  9924. * @param propertyPath defines the path of the property to increment in the target
  9925. * @param value defines the value value we should increment the property by
  9926. * @param condition defines the trigger related conditions
  9927. */
  9928. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9929. /** @hidden */
  9930. _prepare(): void;
  9931. /**
  9932. * Execute the action and increment the target of the value amount.
  9933. */
  9934. execute(): void;
  9935. /**
  9936. * Serializes the actions and its related information.
  9937. * @param parent defines the object to serialize in
  9938. * @returns the serialized object
  9939. */
  9940. serialize(parent: any): any;
  9941. }
  9942. /**
  9943. * This defines an action responsible to start an animation once triggered.
  9944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9945. */
  9946. export class PlayAnimationAction extends Action {
  9947. /**
  9948. * Where the animation should start (animation frame)
  9949. */
  9950. from: number;
  9951. /**
  9952. * Where the animation should stop (animation frame)
  9953. */
  9954. to: number;
  9955. /**
  9956. * Define if the animation should loop or stop after the first play.
  9957. */
  9958. loop?: boolean;
  9959. private _target;
  9960. /**
  9961. * Instantiate the action
  9962. * @param triggerOptions defines the trigger options
  9963. * @param target defines the target animation or animation name
  9964. * @param from defines from where the animation should start (animation frame)
  9965. * @param end defines where the animation should stop (animation frame)
  9966. * @param loop defines if the animation should loop or stop after the first play
  9967. * @param condition defines the trigger related conditions
  9968. */
  9969. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9970. /** @hidden */
  9971. _prepare(): void;
  9972. /**
  9973. * Execute the action and play the animation.
  9974. */
  9975. execute(): void;
  9976. /**
  9977. * Serializes the actions and its related information.
  9978. * @param parent defines the object to serialize in
  9979. * @returns the serialized object
  9980. */
  9981. serialize(parent: any): any;
  9982. }
  9983. /**
  9984. * This defines an action responsible to stop an animation once triggered.
  9985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9986. */
  9987. export class StopAnimationAction extends Action {
  9988. private _target;
  9989. /**
  9990. * Instantiate the action
  9991. * @param triggerOptions defines the trigger options
  9992. * @param target defines the target animation or animation name
  9993. * @param condition defines the trigger related conditions
  9994. */
  9995. constructor(triggerOptions: any, target: any, condition?: Condition);
  9996. /** @hidden */
  9997. _prepare(): void;
  9998. /**
  9999. * Execute the action and stop the animation.
  10000. */
  10001. execute(): void;
  10002. /**
  10003. * Serializes the actions and its related information.
  10004. * @param parent defines the object to serialize in
  10005. * @returns the serialized object
  10006. */
  10007. serialize(parent: any): any;
  10008. }
  10009. /**
  10010. * This defines an action responsible that does nothing once triggered.
  10011. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10012. */
  10013. export class DoNothingAction extends Action {
  10014. /**
  10015. * Instantiate the action
  10016. * @param triggerOptions defines the trigger options
  10017. * @param condition defines the trigger related conditions
  10018. */
  10019. constructor(triggerOptions?: any, condition?: Condition);
  10020. /**
  10021. * Execute the action and do nothing.
  10022. */
  10023. execute(): void;
  10024. /**
  10025. * Serializes the actions and its related information.
  10026. * @param parent defines the object to serialize in
  10027. * @returns the serialized object
  10028. */
  10029. serialize(parent: any): any;
  10030. }
  10031. /**
  10032. * This defines an action responsible to trigger several actions once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class CombineAction extends Action {
  10036. /**
  10037. * The list of aggregated animations to run.
  10038. */
  10039. children: Action[];
  10040. /**
  10041. * Instantiate the action
  10042. * @param triggerOptions defines the trigger options
  10043. * @param children defines the list of aggregated animations to run
  10044. * @param condition defines the trigger related conditions
  10045. */
  10046. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10047. /** @hidden */
  10048. _prepare(): void;
  10049. /**
  10050. * Execute the action and executes all the aggregated actions.
  10051. */
  10052. execute(evt: ActionEvent): void;
  10053. /**
  10054. * Serializes the actions and its related information.
  10055. * @param parent defines the object to serialize in
  10056. * @returns the serialized object
  10057. */
  10058. serialize(parent: any): any;
  10059. }
  10060. /**
  10061. * This defines an action responsible to run code (external event) once triggered.
  10062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10063. */
  10064. export class ExecuteCodeAction extends Action {
  10065. /**
  10066. * The callback function to run.
  10067. */
  10068. func: (evt: ActionEvent) => void;
  10069. /**
  10070. * Instantiate the action
  10071. * @param triggerOptions defines the trigger options
  10072. * @param func defines the callback function to run
  10073. * @param condition defines the trigger related conditions
  10074. */
  10075. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10076. /**
  10077. * Execute the action and run the attached code.
  10078. */
  10079. execute(evt: ActionEvent): void;
  10080. }
  10081. /**
  10082. * This defines an action responsible to set the parent property of the target once triggered.
  10083. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10084. */
  10085. export class SetParentAction extends Action {
  10086. private _parent;
  10087. private _target;
  10088. /**
  10089. * Instantiate the action
  10090. * @param triggerOptions defines the trigger options
  10091. * @param target defines the target containing the parent property
  10092. * @param parent defines from where the animation should start (animation frame)
  10093. * @param condition defines the trigger related conditions
  10094. */
  10095. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10096. /** @hidden */
  10097. _prepare(): void;
  10098. /**
  10099. * Execute the action and set the parent property.
  10100. */
  10101. execute(): void;
  10102. /**
  10103. * Serializes the actions and its related information.
  10104. * @param parent defines the object to serialize in
  10105. * @returns the serialized object
  10106. */
  10107. serialize(parent: any): any;
  10108. }
  10109. }
  10110. declare module BABYLON {
  10111. /**
  10112. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10113. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10115. */
  10116. export class ActionManager extends AbstractActionManager {
  10117. /**
  10118. * Nothing
  10119. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10120. */
  10121. static readonly NothingTrigger: number;
  10122. /**
  10123. * On pick
  10124. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10125. */
  10126. static readonly OnPickTrigger: number;
  10127. /**
  10128. * On left pick
  10129. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10130. */
  10131. static readonly OnLeftPickTrigger: number;
  10132. /**
  10133. * On right pick
  10134. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10135. */
  10136. static readonly OnRightPickTrigger: number;
  10137. /**
  10138. * On center pick
  10139. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10140. */
  10141. static readonly OnCenterPickTrigger: number;
  10142. /**
  10143. * On pick down
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10145. */
  10146. static readonly OnPickDownTrigger: number;
  10147. /**
  10148. * On double pick
  10149. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10150. */
  10151. static readonly OnDoublePickTrigger: number;
  10152. /**
  10153. * On pick up
  10154. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10155. */
  10156. static readonly OnPickUpTrigger: number;
  10157. /**
  10158. * On pick out.
  10159. * This trigger will only be raised if you also declared a OnPickDown
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickOutTrigger: number;
  10163. /**
  10164. * On long press
  10165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10166. */
  10167. static readonly OnLongPressTrigger: number;
  10168. /**
  10169. * On pointer over
  10170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10171. */
  10172. static readonly OnPointerOverTrigger: number;
  10173. /**
  10174. * On pointer out
  10175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10176. */
  10177. static readonly OnPointerOutTrigger: number;
  10178. /**
  10179. * On every frame
  10180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10181. */
  10182. static readonly OnEveryFrameTrigger: number;
  10183. /**
  10184. * On intersection enter
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10186. */
  10187. static readonly OnIntersectionEnterTrigger: number;
  10188. /**
  10189. * On intersection exit
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10191. */
  10192. static readonly OnIntersectionExitTrigger: number;
  10193. /**
  10194. * On key down
  10195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10196. */
  10197. static readonly OnKeyDownTrigger: number;
  10198. /**
  10199. * On key up
  10200. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10201. */
  10202. static readonly OnKeyUpTrigger: number;
  10203. private _scene;
  10204. /**
  10205. * Creates a new action manager
  10206. * @param scene defines the hosting scene
  10207. */
  10208. constructor(scene: Scene);
  10209. /**
  10210. * Releases all associated resources
  10211. */
  10212. dispose(): void;
  10213. /**
  10214. * Gets hosting scene
  10215. * @returns the hosting scene
  10216. */
  10217. getScene(): Scene;
  10218. /**
  10219. * Does this action manager handles actions of any of the given triggers
  10220. * @param triggers defines the triggers to be tested
  10221. * @return a boolean indicating whether one (or more) of the triggers is handled
  10222. */
  10223. hasSpecificTriggers(triggers: number[]): boolean;
  10224. /**
  10225. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10226. * speed.
  10227. * @param triggerA defines the trigger to be tested
  10228. * @param triggerB defines the trigger to be tested
  10229. * @return a boolean indicating whether one (or more) of the triggers is handled
  10230. */
  10231. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10232. /**
  10233. * Does this action manager handles actions of a given trigger
  10234. * @param trigger defines the trigger to be tested
  10235. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10236. * @return whether the trigger is handled
  10237. */
  10238. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10239. /**
  10240. * Does this action manager has pointer triggers
  10241. */
  10242. get hasPointerTriggers(): boolean;
  10243. /**
  10244. * Does this action manager has pick triggers
  10245. */
  10246. get hasPickTriggers(): boolean;
  10247. /**
  10248. * Registers an action to this action manager
  10249. * @param action defines the action to be registered
  10250. * @return the action amended (prepared) after registration
  10251. */
  10252. registerAction(action: IAction): Nullable<IAction>;
  10253. /**
  10254. * Unregisters an action to this action manager
  10255. * @param action defines the action to be unregistered
  10256. * @return a boolean indicating whether the action has been unregistered
  10257. */
  10258. unregisterAction(action: IAction): Boolean;
  10259. /**
  10260. * Process a specific trigger
  10261. * @param trigger defines the trigger to process
  10262. * @param evt defines the event details to be processed
  10263. */
  10264. processTrigger(trigger: number, evt?: IActionEvent): void;
  10265. /** @hidden */
  10266. _getEffectiveTarget(target: any, propertyPath: string): any;
  10267. /** @hidden */
  10268. _getProperty(propertyPath: string): string;
  10269. /**
  10270. * Serialize this manager to a JSON object
  10271. * @param name defines the property name to store this manager
  10272. * @returns a JSON representation of this manager
  10273. */
  10274. serialize(name: string): any;
  10275. /**
  10276. * Creates a new ActionManager from a JSON data
  10277. * @param parsedActions defines the JSON data to read from
  10278. * @param object defines the hosting mesh
  10279. * @param scene defines the hosting scene
  10280. */
  10281. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10282. /**
  10283. * Get a trigger name by index
  10284. * @param trigger defines the trigger index
  10285. * @returns a trigger name
  10286. */
  10287. static GetTriggerName(trigger: number): string;
  10288. }
  10289. }
  10290. declare module BABYLON {
  10291. /**
  10292. * Class used to represent a sprite
  10293. * @see https://doc.babylonjs.com/babylon101/sprites
  10294. */
  10295. export class Sprite implements IAnimatable {
  10296. /** defines the name */
  10297. name: string;
  10298. /** Gets or sets the current world position */
  10299. position: Vector3;
  10300. /** Gets or sets the main color */
  10301. color: Color4;
  10302. /** Gets or sets the width */
  10303. width: number;
  10304. /** Gets or sets the height */
  10305. height: number;
  10306. /** Gets or sets rotation angle */
  10307. angle: number;
  10308. /** Gets or sets the cell index in the sprite sheet */
  10309. cellIndex: number;
  10310. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10311. cellRef: string;
  10312. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10313. invertU: boolean;
  10314. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10315. invertV: boolean;
  10316. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10317. disposeWhenFinishedAnimating: boolean;
  10318. /** Gets the list of attached animations */
  10319. animations: Nullable<Array<Animation>>;
  10320. /** Gets or sets a boolean indicating if the sprite can be picked */
  10321. isPickable: boolean;
  10322. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10323. useAlphaForPicking: boolean;
  10324. /** @hidden */
  10325. _xOffset: number;
  10326. /** @hidden */
  10327. _yOffset: number;
  10328. /** @hidden */
  10329. _xSize: number;
  10330. /** @hidden */
  10331. _ySize: number;
  10332. /**
  10333. * Gets or sets the associated action manager
  10334. */
  10335. actionManager: Nullable<ActionManager>;
  10336. /**
  10337. * An event triggered when the control has been disposed
  10338. */
  10339. onDisposeObservable: Observable<Sprite>;
  10340. private _animationStarted;
  10341. private _loopAnimation;
  10342. private _fromIndex;
  10343. private _toIndex;
  10344. private _delay;
  10345. private _direction;
  10346. private _manager;
  10347. private _time;
  10348. private _onAnimationEnd;
  10349. /**
  10350. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10351. */
  10352. isVisible: boolean;
  10353. /**
  10354. * Gets or sets the sprite size
  10355. */
  10356. get size(): number;
  10357. set size(value: number);
  10358. /**
  10359. * Returns a boolean indicating if the animation is started
  10360. */
  10361. get animationStarted(): boolean;
  10362. /**
  10363. * Gets or sets the unique id of the sprite
  10364. */
  10365. uniqueId: number;
  10366. /**
  10367. * Gets the manager of this sprite
  10368. */
  10369. get manager(): ISpriteManager;
  10370. /**
  10371. * Creates a new Sprite
  10372. * @param name defines the name
  10373. * @param manager defines the manager
  10374. */
  10375. constructor(
  10376. /** defines the name */
  10377. name: string, manager: ISpriteManager);
  10378. /**
  10379. * Returns the string "Sprite"
  10380. * @returns "Sprite"
  10381. */
  10382. getClassName(): string;
  10383. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10384. get fromIndex(): number;
  10385. set fromIndex(value: number);
  10386. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10387. get toIndex(): number;
  10388. set toIndex(value: number);
  10389. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10390. get loopAnimation(): boolean;
  10391. set loopAnimation(value: boolean);
  10392. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10393. get delay(): number;
  10394. set delay(value: number);
  10395. /**
  10396. * Starts an animation
  10397. * @param from defines the initial key
  10398. * @param to defines the end key
  10399. * @param loop defines if the animation must loop
  10400. * @param delay defines the start delay (in ms)
  10401. * @param onAnimationEnd defines a callback to call when animation ends
  10402. */
  10403. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10404. /** Stops current animation (if any) */
  10405. stopAnimation(): void;
  10406. /** @hidden */
  10407. _animate(deltaTime: number): void;
  10408. /** Release associated resources */
  10409. dispose(): void;
  10410. /**
  10411. * Serializes the sprite to a JSON object
  10412. * @returns the JSON object
  10413. */
  10414. serialize(): any;
  10415. /**
  10416. * Parses a JSON object to create a new sprite
  10417. * @param parsedSprite The JSON object to parse
  10418. * @param manager defines the hosting manager
  10419. * @returns the new sprite
  10420. */
  10421. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10422. }
  10423. }
  10424. declare module BABYLON {
  10425. /**
  10426. * Information about the result of picking within a scene
  10427. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10428. */
  10429. export class PickingInfo {
  10430. /** @hidden */
  10431. _pickingUnavailable: boolean;
  10432. /**
  10433. * If the pick collided with an object
  10434. */
  10435. hit: boolean;
  10436. /**
  10437. * Distance away where the pick collided
  10438. */
  10439. distance: number;
  10440. /**
  10441. * The location of pick collision
  10442. */
  10443. pickedPoint: Nullable<Vector3>;
  10444. /**
  10445. * The mesh corresponding the the pick collision
  10446. */
  10447. pickedMesh: Nullable<AbstractMesh>;
  10448. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10449. bu: number;
  10450. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10451. bv: number;
  10452. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10453. faceId: number;
  10454. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10455. subMeshFaceId: number;
  10456. /** Id of the the submesh that was picked */
  10457. subMeshId: number;
  10458. /** If a sprite was picked, this will be the sprite the pick collided with */
  10459. pickedSprite: Nullable<Sprite>;
  10460. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10461. thinInstanceIndex: number;
  10462. /**
  10463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10464. */
  10465. originMesh: Nullable<AbstractMesh>;
  10466. /**
  10467. * The ray that was used to perform the picking.
  10468. */
  10469. ray: Nullable<Ray>;
  10470. /**
  10471. * Gets the normal correspodning to the face the pick collided with
  10472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10474. * @returns The normal correspodning to the face the pick collided with
  10475. */
  10476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10477. /**
  10478. * Gets the texture coordinates of where the pick occured
  10479. * @returns the vector containing the coordnates of the texture
  10480. */
  10481. getTextureCoordinates(): Nullable<Vector2>;
  10482. }
  10483. }
  10484. declare module BABYLON {
  10485. /**
  10486. * Class representing a ray with position and direction
  10487. */
  10488. export class Ray {
  10489. /** origin point */
  10490. origin: Vector3;
  10491. /** direction */
  10492. direction: Vector3;
  10493. /** length of the ray */
  10494. length: number;
  10495. private static readonly _TmpVector3;
  10496. private _tmpRay;
  10497. /**
  10498. * Creates a new ray
  10499. * @param origin origin point
  10500. * @param direction direction
  10501. * @param length length of the ray
  10502. */
  10503. constructor(
  10504. /** origin point */
  10505. origin: Vector3,
  10506. /** direction */
  10507. direction: Vector3,
  10508. /** length of the ray */
  10509. length?: number);
  10510. /**
  10511. * Checks if the ray intersects a box
  10512. * This does not account for the ray lenght by design to improve perfs.
  10513. * @param minimum bound of the box
  10514. * @param maximum bound of the box
  10515. * @param intersectionTreshold extra extend to be added to the box in all direction
  10516. * @returns if the box was hit
  10517. */
  10518. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10519. /**
  10520. * Checks if the ray intersects a box
  10521. * This does not account for the ray lenght by design to improve perfs.
  10522. * @param box the bounding box to check
  10523. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10524. * @returns if the box was hit
  10525. */
  10526. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10527. /**
  10528. * If the ray hits a sphere
  10529. * @param sphere the bounding sphere to check
  10530. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10531. * @returns true if it hits the sphere
  10532. */
  10533. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10534. /**
  10535. * If the ray hits a triange
  10536. * @param vertex0 triangle vertex
  10537. * @param vertex1 triangle vertex
  10538. * @param vertex2 triangle vertex
  10539. * @returns intersection information if hit
  10540. */
  10541. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10542. /**
  10543. * Checks if ray intersects a plane
  10544. * @param plane the plane to check
  10545. * @returns the distance away it was hit
  10546. */
  10547. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10548. /**
  10549. * Calculate the intercept of a ray on a given axis
  10550. * @param axis to check 'x' | 'y' | 'z'
  10551. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10552. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10553. */
  10554. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10555. /**
  10556. * Checks if ray intersects a mesh
  10557. * @param mesh the mesh to check
  10558. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10559. * @returns picking info of the intersecton
  10560. */
  10561. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10562. /**
  10563. * Checks if ray intersects a mesh
  10564. * @param meshes the meshes to check
  10565. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10566. * @param results array to store result in
  10567. * @returns Array of picking infos
  10568. */
  10569. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10570. private _comparePickingInfo;
  10571. private static smallnum;
  10572. private static rayl;
  10573. /**
  10574. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10575. * @param sega the first point of the segment to test the intersection against
  10576. * @param segb the second point of the segment to test the intersection against
  10577. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10578. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10579. */
  10580. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10581. /**
  10582. * Update the ray from viewport position
  10583. * @param x position
  10584. * @param y y position
  10585. * @param viewportWidth viewport width
  10586. * @param viewportHeight viewport height
  10587. * @param world world matrix
  10588. * @param view view matrix
  10589. * @param projection projection matrix
  10590. * @returns this ray updated
  10591. */
  10592. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10593. /**
  10594. * Creates a ray with origin and direction of 0,0,0
  10595. * @returns the new ray
  10596. */
  10597. static Zero(): Ray;
  10598. /**
  10599. * Creates a new ray from screen space and viewport
  10600. * @param x position
  10601. * @param y y position
  10602. * @param viewportWidth viewport width
  10603. * @param viewportHeight viewport height
  10604. * @param world world matrix
  10605. * @param view view matrix
  10606. * @param projection projection matrix
  10607. * @returns new ray
  10608. */
  10609. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10610. /**
  10611. * 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
  10612. * transformed to the given world matrix.
  10613. * @param origin The origin point
  10614. * @param end The end point
  10615. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10616. * @returns the new ray
  10617. */
  10618. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10619. /**
  10620. * Transforms a ray by a matrix
  10621. * @param ray ray to transform
  10622. * @param matrix matrix to apply
  10623. * @returns the resulting new ray
  10624. */
  10625. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10626. /**
  10627. * Transforms a ray by a matrix
  10628. * @param ray ray to transform
  10629. * @param matrix matrix to apply
  10630. * @param result ray to store result in
  10631. */
  10632. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10633. /**
  10634. * Unproject a ray from screen space to object space
  10635. * @param sourceX defines the screen space x coordinate to use
  10636. * @param sourceY defines the screen space y coordinate to use
  10637. * @param viewportWidth defines the current width of the viewport
  10638. * @param viewportHeight defines the current height of the viewport
  10639. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10640. * @param view defines the view matrix to use
  10641. * @param projection defines the projection matrix to use
  10642. */
  10643. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10644. }
  10645. /**
  10646. * Type used to define predicate used to select faces when a mesh intersection is detected
  10647. */
  10648. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10649. interface Scene {
  10650. /** @hidden */
  10651. _tempPickingRay: Nullable<Ray>;
  10652. /** @hidden */
  10653. _cachedRayForTransform: Ray;
  10654. /** @hidden */
  10655. _pickWithRayInverseMatrix: Matrix;
  10656. /** @hidden */
  10657. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10658. /** @hidden */
  10659. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10660. /** @hidden */
  10661. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10662. }
  10663. }
  10664. declare module BABYLON {
  10665. /**
  10666. * Groups all the scene component constants in one place to ease maintenance.
  10667. * @hidden
  10668. */
  10669. export class SceneComponentConstants {
  10670. static readonly NAME_EFFECTLAYER: string;
  10671. static readonly NAME_LAYER: string;
  10672. static readonly NAME_LENSFLARESYSTEM: string;
  10673. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10674. static readonly NAME_PARTICLESYSTEM: string;
  10675. static readonly NAME_GAMEPAD: string;
  10676. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10677. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10678. static readonly NAME_PREPASSRENDERER: string;
  10679. static readonly NAME_DEPTHRENDERER: string;
  10680. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10681. static readonly NAME_SPRITE: string;
  10682. static readonly NAME_SUBSURFACE: string;
  10683. static readonly NAME_OUTLINERENDERER: string;
  10684. static readonly NAME_PROCEDURALTEXTURE: string;
  10685. static readonly NAME_SHADOWGENERATOR: string;
  10686. static readonly NAME_OCTREE: string;
  10687. static readonly NAME_PHYSICSENGINE: string;
  10688. static readonly NAME_AUDIO: string;
  10689. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10690. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10691. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10692. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10693. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10694. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10695. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10696. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10697. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10698. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10699. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10700. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10701. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10702. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10703. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10704. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10705. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10706. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10707. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10708. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10709. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10710. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10711. static readonly STEP_AFTERRENDER_AUDIO: number;
  10712. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10713. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10714. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10715. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10716. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10717. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10718. static readonly STEP_POINTERMOVE_SPRITE: number;
  10719. static readonly STEP_POINTERDOWN_SPRITE: number;
  10720. static readonly STEP_POINTERUP_SPRITE: number;
  10721. }
  10722. /**
  10723. * This represents a scene component.
  10724. *
  10725. * This is used to decouple the dependency the scene is having on the different workloads like
  10726. * layers, post processes...
  10727. */
  10728. export interface ISceneComponent {
  10729. /**
  10730. * The name of the component. Each component must have a unique name.
  10731. */
  10732. name: string;
  10733. /**
  10734. * The scene the component belongs to.
  10735. */
  10736. scene: Scene;
  10737. /**
  10738. * Register the component to one instance of a scene.
  10739. */
  10740. register(): void;
  10741. /**
  10742. * Rebuilds the elements related to this component in case of
  10743. * context lost for instance.
  10744. */
  10745. rebuild(): void;
  10746. /**
  10747. * Disposes the component and the associated ressources.
  10748. */
  10749. dispose(): void;
  10750. }
  10751. /**
  10752. * This represents a SERIALIZABLE scene component.
  10753. *
  10754. * This extends Scene Component to add Serialization methods on top.
  10755. */
  10756. export interface ISceneSerializableComponent extends ISceneComponent {
  10757. /**
  10758. * Adds all the elements from the container to the scene
  10759. * @param container the container holding the elements
  10760. */
  10761. addFromContainer(container: AbstractScene): void;
  10762. /**
  10763. * Removes all the elements in the container from the scene
  10764. * @param container contains the elements to remove
  10765. * @param dispose if the removed element should be disposed (default: false)
  10766. */
  10767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10768. /**
  10769. * Serializes the component data to the specified json object
  10770. * @param serializationObject The object to serialize to
  10771. */
  10772. serialize(serializationObject: any): void;
  10773. }
  10774. /**
  10775. * Strong typing of a Mesh related stage step action
  10776. */
  10777. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10778. /**
  10779. * Strong typing of a Evaluate Sub Mesh related stage step action
  10780. */
  10781. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10782. /**
  10783. * Strong typing of a Active Mesh related stage step action
  10784. */
  10785. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10786. /**
  10787. * Strong typing of a Camera related stage step action
  10788. */
  10789. export type CameraStageAction = (camera: Camera) => void;
  10790. /**
  10791. * Strong typing of a Camera Frame buffer related stage step action
  10792. */
  10793. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10794. /**
  10795. * Strong typing of a Render Target related stage step action
  10796. */
  10797. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10798. /**
  10799. * Strong typing of a RenderingGroup related stage step action
  10800. */
  10801. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10802. /**
  10803. * Strong typing of a Mesh Render related stage step action
  10804. */
  10805. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10806. /**
  10807. * Strong typing of a simple stage step action
  10808. */
  10809. export type SimpleStageAction = () => void;
  10810. /**
  10811. * Strong typing of a render target action.
  10812. */
  10813. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10814. /**
  10815. * Strong typing of a pointer move action.
  10816. */
  10817. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10818. /**
  10819. * Strong typing of a pointer up/down action.
  10820. */
  10821. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10822. /**
  10823. * Representation of a stage in the scene (Basically a list of ordered steps)
  10824. * @hidden
  10825. */
  10826. export class Stage<T extends Function> extends Array<{
  10827. index: number;
  10828. component: ISceneComponent;
  10829. action: T;
  10830. }> {
  10831. /**
  10832. * Hide ctor from the rest of the world.
  10833. * @param items The items to add.
  10834. */
  10835. private constructor();
  10836. /**
  10837. * Creates a new Stage.
  10838. * @returns A new instance of a Stage
  10839. */
  10840. static Create<T extends Function>(): Stage<T>;
  10841. /**
  10842. * Registers a step in an ordered way in the targeted stage.
  10843. * @param index Defines the position to register the step in
  10844. * @param component Defines the component attached to the step
  10845. * @param action Defines the action to launch during the step
  10846. */
  10847. registerStep(index: number, component: ISceneComponent, action: T): void;
  10848. /**
  10849. * Clears all the steps from the stage.
  10850. */
  10851. clear(): void;
  10852. }
  10853. }
  10854. declare module BABYLON {
  10855. interface Scene {
  10856. /** @hidden */
  10857. _pointerOverSprite: Nullable<Sprite>;
  10858. /** @hidden */
  10859. _pickedDownSprite: Nullable<Sprite>;
  10860. /** @hidden */
  10861. _tempSpritePickingRay: Nullable<Ray>;
  10862. /**
  10863. * All of the sprite managers added to this scene
  10864. * @see https://doc.babylonjs.com/babylon101/sprites
  10865. */
  10866. spriteManagers: Array<ISpriteManager>;
  10867. /**
  10868. * An event triggered when sprites rendering is about to start
  10869. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10870. */
  10871. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10872. /**
  10873. * An event triggered when sprites rendering is done
  10874. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10875. */
  10876. onAfterSpritesRenderingObservable: Observable<Scene>;
  10877. /** @hidden */
  10878. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10879. /** Launch a ray to try to pick a sprite in the scene
  10880. * @param x position on screen
  10881. * @param y position on screen
  10882. * @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
  10883. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10884. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10885. * @returns a PickingInfo
  10886. */
  10887. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10888. /** Use the given ray to pick a sprite in the scene
  10889. * @param ray The ray (in world space) to use to pick meshes
  10890. * @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
  10891. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10892. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10893. * @returns a PickingInfo
  10894. */
  10895. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10896. /** @hidden */
  10897. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10898. /** Launch a ray to try to pick sprites in the scene
  10899. * @param x position on screen
  10900. * @param y position on screen
  10901. * @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
  10902. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10903. * @returns a PickingInfo array
  10904. */
  10905. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10906. /** Use the given ray to pick sprites in the scene
  10907. * @param ray The ray (in world space) to use to pick meshes
  10908. * @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
  10909. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10910. * @returns a PickingInfo array
  10911. */
  10912. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10913. /**
  10914. * Force the sprite under the pointer
  10915. * @param sprite defines the sprite to use
  10916. */
  10917. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10918. /**
  10919. * Gets the sprite under the pointer
  10920. * @returns a Sprite or null if no sprite is under the pointer
  10921. */
  10922. getPointerOverSprite(): Nullable<Sprite>;
  10923. }
  10924. /**
  10925. * Defines the sprite scene component responsible to manage sprites
  10926. * in a given scene.
  10927. */
  10928. export class SpriteSceneComponent implements ISceneComponent {
  10929. /**
  10930. * The component name helpfull to identify the component in the list of scene components.
  10931. */
  10932. readonly name: string;
  10933. /**
  10934. * The scene the component belongs to.
  10935. */
  10936. scene: Scene;
  10937. /** @hidden */
  10938. private _spritePredicate;
  10939. /**
  10940. * Creates a new instance of the component for the given scene
  10941. * @param scene Defines the scene to register the component in
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Registers the component in a given scene
  10946. */
  10947. register(): void;
  10948. /**
  10949. * Rebuilds the elements related to this component in case of
  10950. * context lost for instance.
  10951. */
  10952. rebuild(): void;
  10953. /**
  10954. * Disposes the component and the associated ressources.
  10955. */
  10956. dispose(): void;
  10957. private _pickSpriteButKeepRay;
  10958. private _pointerMove;
  10959. private _pointerDown;
  10960. private _pointerUp;
  10961. }
  10962. }
  10963. declare module BABYLON {
  10964. /** @hidden */
  10965. export var fogFragmentDeclaration: {
  10966. name: string;
  10967. shader: string;
  10968. };
  10969. }
  10970. declare module BABYLON {
  10971. /** @hidden */
  10972. export var fogFragment: {
  10973. name: string;
  10974. shader: string;
  10975. };
  10976. }
  10977. declare module BABYLON {
  10978. /** @hidden */
  10979. export var spritesPixelShader: {
  10980. name: string;
  10981. shader: string;
  10982. };
  10983. }
  10984. declare module BABYLON {
  10985. /** @hidden */
  10986. export var fogVertexDeclaration: {
  10987. name: string;
  10988. shader: string;
  10989. };
  10990. }
  10991. declare module BABYLON {
  10992. /** @hidden */
  10993. export var spritesVertexShader: {
  10994. name: string;
  10995. shader: string;
  10996. };
  10997. }
  10998. declare module BABYLON {
  10999. /**
  11000. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11001. */
  11002. export interface ISpriteManager extends IDisposable {
  11003. /**
  11004. * Gets manager's name
  11005. */
  11006. name: string;
  11007. /**
  11008. * Restricts the camera to viewing objects with the same layerMask.
  11009. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11010. */
  11011. layerMask: number;
  11012. /**
  11013. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11014. */
  11015. isPickable: boolean;
  11016. /**
  11017. * Gets the hosting scene
  11018. */
  11019. scene: Scene;
  11020. /**
  11021. * Specifies the rendering group id for this mesh (0 by default)
  11022. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11023. */
  11024. renderingGroupId: number;
  11025. /**
  11026. * Defines the list of sprites managed by the manager.
  11027. */
  11028. sprites: Array<Sprite>;
  11029. /**
  11030. * Gets or sets the spritesheet texture
  11031. */
  11032. texture: Texture;
  11033. /** Defines the default width of a cell in the spritesheet */
  11034. cellWidth: number;
  11035. /** Defines the default height of a cell in the spritesheet */
  11036. cellHeight: number;
  11037. /**
  11038. * Tests the intersection of a sprite with a specific ray.
  11039. * @param ray The ray we are sending to test the collision
  11040. * @param camera The camera space we are sending rays in
  11041. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11042. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11043. * @returns picking info or null.
  11044. */
  11045. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11046. /**
  11047. * Intersects the sprites with a ray
  11048. * @param ray defines the ray to intersect with
  11049. * @param camera defines the current active camera
  11050. * @param predicate defines a predicate used to select candidate sprites
  11051. * @returns null if no hit or a PickingInfo array
  11052. */
  11053. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11054. /**
  11055. * Renders the list of sprites on screen.
  11056. */
  11057. render(): void;
  11058. }
  11059. /**
  11060. * Class used to manage multiple sprites on the same spritesheet
  11061. * @see https://doc.babylonjs.com/babylon101/sprites
  11062. */
  11063. export class SpriteManager implements ISpriteManager {
  11064. /** defines the manager's name */
  11065. name: string;
  11066. /** Define the Url to load snippets */
  11067. static SnippetUrl: string;
  11068. /** Snippet ID if the manager was created from the snippet server */
  11069. snippetId: string;
  11070. /** Gets the list of sprites */
  11071. sprites: Sprite[];
  11072. /** Gets or sets the rendering group id (0 by default) */
  11073. renderingGroupId: number;
  11074. /** Gets or sets camera layer mask */
  11075. layerMask: number;
  11076. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11077. fogEnabled: boolean;
  11078. /** Gets or sets a boolean indicating if the sprites are pickable */
  11079. isPickable: boolean;
  11080. /** Defines the default width of a cell in the spritesheet */
  11081. cellWidth: number;
  11082. /** Defines the default height of a cell in the spritesheet */
  11083. cellHeight: number;
  11084. /** Associative array from JSON sprite data file */
  11085. private _cellData;
  11086. /** Array of sprite names from JSON sprite data file */
  11087. private _spriteMap;
  11088. /** True when packed cell data from JSON file is ready*/
  11089. private _packedAndReady;
  11090. private _textureContent;
  11091. private _useInstancing;
  11092. /**
  11093. * An event triggered when the manager is disposed.
  11094. */
  11095. onDisposeObservable: Observable<SpriteManager>;
  11096. private _onDisposeObserver;
  11097. /**
  11098. * Callback called when the manager is disposed
  11099. */
  11100. set onDispose(callback: () => void);
  11101. private _capacity;
  11102. private _fromPacked;
  11103. private _spriteTexture;
  11104. private _epsilon;
  11105. private _scene;
  11106. private _vertexData;
  11107. private _buffer;
  11108. private _vertexBuffers;
  11109. private _spriteBuffer;
  11110. private _indexBuffer;
  11111. private _effectBase;
  11112. private _effectFog;
  11113. private _vertexBufferSize;
  11114. /**
  11115. * Gets or sets the unique id of the sprite
  11116. */
  11117. uniqueId: number;
  11118. /**
  11119. * Gets the array of sprites
  11120. */
  11121. get children(): Sprite[];
  11122. /**
  11123. * Gets the hosting scene
  11124. */
  11125. get scene(): Scene;
  11126. /**
  11127. * Gets the capacity of the manager
  11128. */
  11129. get capacity(): number;
  11130. /**
  11131. * Gets or sets the spritesheet texture
  11132. */
  11133. get texture(): Texture;
  11134. set texture(value: Texture);
  11135. private _blendMode;
  11136. /**
  11137. * Blend mode use to render the particle, it can be any of
  11138. * the static Constants.ALPHA_x properties provided in this class.
  11139. * Default value is Constants.ALPHA_COMBINE
  11140. */
  11141. get blendMode(): number;
  11142. set blendMode(blendMode: number);
  11143. /** Disables writing to the depth buffer when rendering the sprites.
  11144. * It can be handy to disable depth writing when using textures without alpha channel
  11145. * and setting some specific blend modes.
  11146. */
  11147. disableDepthWrite: boolean;
  11148. /**
  11149. * Creates a new sprite manager
  11150. * @param name defines the manager's name
  11151. * @param imgUrl defines the sprite sheet url
  11152. * @param capacity defines the maximum allowed number of sprites
  11153. * @param cellSize defines the size of a sprite cell
  11154. * @param scene defines the hosting scene
  11155. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11156. * @param samplingMode defines the smapling mode to use with spritesheet
  11157. * @param fromPacked set to false; do not alter
  11158. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11159. */
  11160. constructor(
  11161. /** defines the manager's name */
  11162. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11163. /**
  11164. * Returns the string "SpriteManager"
  11165. * @returns "SpriteManager"
  11166. */
  11167. getClassName(): string;
  11168. private _makePacked;
  11169. private _appendSpriteVertex;
  11170. private _checkTextureAlpha;
  11171. /**
  11172. * Intersects the sprites with a ray
  11173. * @param ray defines the ray to intersect with
  11174. * @param camera defines the current active camera
  11175. * @param predicate defines a predicate used to select candidate sprites
  11176. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11177. * @returns null if no hit or a PickingInfo
  11178. */
  11179. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11180. /**
  11181. * Intersects the sprites with a ray
  11182. * @param ray defines the ray to intersect with
  11183. * @param camera defines the current active camera
  11184. * @param predicate defines a predicate used to select candidate sprites
  11185. * @returns null if no hit or a PickingInfo array
  11186. */
  11187. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11188. /**
  11189. * Render all child sprites
  11190. */
  11191. render(): void;
  11192. /**
  11193. * Release associated resources
  11194. */
  11195. dispose(): void;
  11196. /**
  11197. * Serializes the sprite manager to a JSON object
  11198. * @param serializeTexture defines if the texture must be serialized as well
  11199. * @returns the JSON object
  11200. */
  11201. serialize(serializeTexture?: boolean): any;
  11202. /**
  11203. * Parses a JSON object to create a new sprite manager.
  11204. * @param parsedManager The JSON object to parse
  11205. * @param scene The scene to create the sprite managerin
  11206. * @param rootUrl The root url to use to load external dependencies like texture
  11207. * @returns the new sprite manager
  11208. */
  11209. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11210. /**
  11211. * Creates a sprite manager from a snippet saved in a remote file
  11212. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11213. * @param url defines the url to load from
  11214. * @param scene defines the hosting scene
  11215. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11216. * @returns a promise that will resolve to the new sprite manager
  11217. */
  11218. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11219. /**
  11220. * Creates a sprite manager from a snippet saved by the sprite editor
  11221. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11222. * @param scene defines the hosting scene
  11223. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11224. * @returns a promise that will resolve to the new sprite manager
  11225. */
  11226. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11227. }
  11228. }
  11229. declare module BABYLON {
  11230. /** Interface used by value gradients (color, factor, ...) */
  11231. export interface IValueGradient {
  11232. /**
  11233. * Gets or sets the gradient value (between 0 and 1)
  11234. */
  11235. gradient: number;
  11236. }
  11237. /** Class used to store color4 gradient */
  11238. export class ColorGradient implements IValueGradient {
  11239. /**
  11240. * Gets or sets the gradient value (between 0 and 1)
  11241. */
  11242. gradient: number;
  11243. /**
  11244. * Gets or sets first associated color
  11245. */
  11246. color1: Color4;
  11247. /**
  11248. * Gets or sets second associated color
  11249. */
  11250. color2?: Color4 | undefined;
  11251. /**
  11252. * Creates a new color4 gradient
  11253. * @param gradient gets or sets the gradient value (between 0 and 1)
  11254. * @param color1 gets or sets first associated color
  11255. * @param color2 gets or sets first second color
  11256. */
  11257. constructor(
  11258. /**
  11259. * Gets or sets the gradient value (between 0 and 1)
  11260. */
  11261. gradient: number,
  11262. /**
  11263. * Gets or sets first associated color
  11264. */
  11265. color1: Color4,
  11266. /**
  11267. * Gets or sets second associated color
  11268. */
  11269. color2?: Color4 | undefined);
  11270. /**
  11271. * Will get a color picked randomly between color1 and color2.
  11272. * If color2 is undefined then color1 will be used
  11273. * @param result defines the target Color4 to store the result in
  11274. */
  11275. getColorToRef(result: Color4): void;
  11276. }
  11277. /** Class used to store color 3 gradient */
  11278. export class Color3Gradient implements IValueGradient {
  11279. /**
  11280. * Gets or sets the gradient value (between 0 and 1)
  11281. */
  11282. gradient: number;
  11283. /**
  11284. * Gets or sets the associated color
  11285. */
  11286. color: Color3;
  11287. /**
  11288. * Creates a new color3 gradient
  11289. * @param gradient gets or sets the gradient value (between 0 and 1)
  11290. * @param color gets or sets associated color
  11291. */
  11292. constructor(
  11293. /**
  11294. * Gets or sets the gradient value (between 0 and 1)
  11295. */
  11296. gradient: number,
  11297. /**
  11298. * Gets or sets the associated color
  11299. */
  11300. color: Color3);
  11301. }
  11302. /** Class used to store factor gradient */
  11303. export class FactorGradient implements IValueGradient {
  11304. /**
  11305. * Gets or sets the gradient value (between 0 and 1)
  11306. */
  11307. gradient: number;
  11308. /**
  11309. * Gets or sets first associated factor
  11310. */
  11311. factor1: number;
  11312. /**
  11313. * Gets or sets second associated factor
  11314. */
  11315. factor2?: number | undefined;
  11316. /**
  11317. * Creates a new factor gradient
  11318. * @param gradient gets or sets the gradient value (between 0 and 1)
  11319. * @param factor1 gets or sets first associated factor
  11320. * @param factor2 gets or sets second associated factor
  11321. */
  11322. constructor(
  11323. /**
  11324. * Gets or sets the gradient value (between 0 and 1)
  11325. */
  11326. gradient: number,
  11327. /**
  11328. * Gets or sets first associated factor
  11329. */
  11330. factor1: number,
  11331. /**
  11332. * Gets or sets second associated factor
  11333. */
  11334. factor2?: number | undefined);
  11335. /**
  11336. * Will get a number picked randomly between factor1 and factor2.
  11337. * If factor2 is undefined then factor1 will be used
  11338. * @returns the picked number
  11339. */
  11340. getFactor(): number;
  11341. }
  11342. /**
  11343. * Helper used to simplify some generic gradient tasks
  11344. */
  11345. export class GradientHelper {
  11346. /**
  11347. * Gets the current gradient from an array of IValueGradient
  11348. * @param ratio defines the current ratio to get
  11349. * @param gradients defines the array of IValueGradient
  11350. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11351. */
  11352. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11353. }
  11354. }
  11355. declare module BABYLON {
  11356. interface ThinEngine {
  11357. /**
  11358. * Creates a raw texture
  11359. * @param data defines the data to store in the texture
  11360. * @param width defines the width of the texture
  11361. * @param height defines the height of the texture
  11362. * @param format defines the format of the data
  11363. * @param generateMipMaps defines if the engine should generate the mip levels
  11364. * @param invertY defines if data must be stored with Y axis inverted
  11365. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11366. * @param compression defines the compression used (null by default)
  11367. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11368. * @returns the raw texture inside an InternalTexture
  11369. */
  11370. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11371. /**
  11372. * Update a raw texture
  11373. * @param texture defines the texture to update
  11374. * @param data defines the data to store in the texture
  11375. * @param format defines the format of the data
  11376. * @param invertY defines if data must be stored with Y axis inverted
  11377. */
  11378. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11379. /**
  11380. * Update a raw texture
  11381. * @param texture defines the texture to update
  11382. * @param data defines the data to store in the texture
  11383. * @param format defines the format of the data
  11384. * @param invertY defines if data must be stored with Y axis inverted
  11385. * @param compression defines the compression used (null by default)
  11386. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11387. */
  11388. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11389. /**
  11390. * Creates a new raw cube texture
  11391. * @param data defines the array of data to use to create each face
  11392. * @param size defines the size of the textures
  11393. * @param format defines the format of the data
  11394. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11395. * @param generateMipMaps defines if the engine should generate the mip levels
  11396. * @param invertY defines if data must be stored with Y axis inverted
  11397. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11398. * @param compression defines the compression used (null by default)
  11399. * @returns the cube texture as an InternalTexture
  11400. */
  11401. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11402. /**
  11403. * Update a raw cube texture
  11404. * @param texture defines the texture to udpdate
  11405. * @param data defines the data to store
  11406. * @param format defines the data format
  11407. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11408. * @param invertY defines if data must be stored with Y axis inverted
  11409. */
  11410. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11411. /**
  11412. * Update a raw cube texture
  11413. * @param texture defines the texture to udpdate
  11414. * @param data defines the data to store
  11415. * @param format defines the data format
  11416. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11417. * @param invertY defines if data must be stored with Y axis inverted
  11418. * @param compression defines the compression used (null by default)
  11419. */
  11420. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11421. /**
  11422. * Update a raw cube texture
  11423. * @param texture defines the texture to udpdate
  11424. * @param data defines the data to store
  11425. * @param format defines the data format
  11426. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11427. * @param invertY defines if data must be stored with Y axis inverted
  11428. * @param compression defines the compression used (null by default)
  11429. * @param level defines which level of the texture to update
  11430. */
  11431. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11432. /**
  11433. * Creates a new raw cube texture from a specified url
  11434. * @param url defines the url where the data is located
  11435. * @param scene defines the current scene
  11436. * @param size defines the size of the textures
  11437. * @param format defines the format of the data
  11438. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11439. * @param noMipmap defines if the engine should avoid generating the mip levels
  11440. * @param callback defines a callback used to extract texture data from loaded data
  11441. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11442. * @param onLoad defines a callback called when texture is loaded
  11443. * @param onError defines a callback called if there is an error
  11444. * @returns the cube texture as an InternalTexture
  11445. */
  11446. 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;
  11447. /**
  11448. * Creates a new raw cube texture from a specified url
  11449. * @param url defines the url where the data is located
  11450. * @param scene defines the current scene
  11451. * @param size defines the size of the textures
  11452. * @param format defines the format of the data
  11453. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11454. * @param noMipmap defines if the engine should avoid generating the mip levels
  11455. * @param callback defines a callback used to extract texture data from loaded data
  11456. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11457. * @param onLoad defines a callback called when texture is loaded
  11458. * @param onError defines a callback called if there is an error
  11459. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11460. * @param invertY defines if data must be stored with Y axis inverted
  11461. * @returns the cube texture as an InternalTexture
  11462. */
  11463. 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;
  11464. /**
  11465. * Creates a new raw 3D texture
  11466. * @param data defines the data used to create the texture
  11467. * @param width defines the width of the texture
  11468. * @param height defines the height of the texture
  11469. * @param depth defines the depth of the texture
  11470. * @param format defines the format of the texture
  11471. * @param generateMipMaps defines if the engine must generate mip levels
  11472. * @param invertY defines if data must be stored with Y axis inverted
  11473. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11474. * @param compression defines the compressed used (can be null)
  11475. * @param textureType defines the compressed used (can be null)
  11476. * @returns a new raw 3D texture (stored in an InternalTexture)
  11477. */
  11478. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11479. /**
  11480. * Update a raw 3D texture
  11481. * @param texture defines the texture to update
  11482. * @param data defines the data to store
  11483. * @param format defines the data format
  11484. * @param invertY defines if data must be stored with Y axis inverted
  11485. */
  11486. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11487. /**
  11488. * Update a raw 3D texture
  11489. * @param texture defines the texture to update
  11490. * @param data defines the data to store
  11491. * @param format defines the data format
  11492. * @param invertY defines if data must be stored with Y axis inverted
  11493. * @param compression defines the used compression (can be null)
  11494. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11495. */
  11496. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11497. /**
  11498. * Creates a new raw 2D array texture
  11499. * @param data defines the data used to create the texture
  11500. * @param width defines the width of the texture
  11501. * @param height defines the height of the texture
  11502. * @param depth defines the number of layers of the texture
  11503. * @param format defines the format of the texture
  11504. * @param generateMipMaps defines if the engine must generate mip levels
  11505. * @param invertY defines if data must be stored with Y axis inverted
  11506. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11507. * @param compression defines the compressed used (can be null)
  11508. * @param textureType defines the compressed used (can be null)
  11509. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11510. */
  11511. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11512. /**
  11513. * Update a raw 2D array texture
  11514. * @param texture defines the texture to update
  11515. * @param data defines the data to store
  11516. * @param format defines the data format
  11517. * @param invertY defines if data must be stored with Y axis inverted
  11518. */
  11519. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11520. /**
  11521. * Update a raw 2D array texture
  11522. * @param texture defines the texture to update
  11523. * @param data defines the data to store
  11524. * @param format defines the data format
  11525. * @param invertY defines if data must be stored with Y axis inverted
  11526. * @param compression defines the used compression (can be null)
  11527. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11528. */
  11529. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11530. }
  11531. }
  11532. declare module BABYLON {
  11533. /**
  11534. * Raw texture can help creating a texture directly from an array of data.
  11535. * This can be super useful if you either get the data from an uncompressed source or
  11536. * if you wish to create your texture pixel by pixel.
  11537. */
  11538. export class RawTexture extends Texture {
  11539. /**
  11540. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11541. */
  11542. format: number;
  11543. /**
  11544. * Instantiates a new RawTexture.
  11545. * Raw texture can help creating a texture directly from an array of data.
  11546. * This can be super useful if you either get the data from an uncompressed source or
  11547. * if you wish to create your texture pixel by pixel.
  11548. * @param data define the array of data to use to create the texture
  11549. * @param width define the width of the texture
  11550. * @param height define the height of the texture
  11551. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11552. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11553. * @param generateMipMaps define whether mip maps should be generated or not
  11554. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11555. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11556. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11557. */
  11558. constructor(data: ArrayBufferView, width: number, height: number,
  11559. /**
  11560. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11561. */
  11562. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11563. /**
  11564. * Updates the texture underlying data.
  11565. * @param data Define the new data of the texture
  11566. */
  11567. update(data: ArrayBufferView): void;
  11568. /**
  11569. * Creates a luminance texture from some data.
  11570. * @param data Define the texture data
  11571. * @param width Define the width of the texture
  11572. * @param height Define the height of the texture
  11573. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11574. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11575. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11576. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11577. * @returns the luminance texture
  11578. */
  11579. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11580. /**
  11581. * Creates a luminance alpha texture from some data.
  11582. * @param data Define the texture data
  11583. * @param width Define the width of the texture
  11584. * @param height Define the height of the texture
  11585. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11586. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11587. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11588. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11589. * @returns the luminance alpha texture
  11590. */
  11591. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11592. /**
  11593. * Creates an alpha texture from some data.
  11594. * @param data Define the texture data
  11595. * @param width Define the width of the texture
  11596. * @param height Define the height of the texture
  11597. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11598. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11599. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11600. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11601. * @returns the alpha texture
  11602. */
  11603. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11604. /**
  11605. * Creates a RGB texture from some data.
  11606. * @param data Define the texture data
  11607. * @param width Define the width of the texture
  11608. * @param height Define the height of the texture
  11609. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11610. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11611. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11612. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11613. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11614. * @returns the RGB alpha texture
  11615. */
  11616. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11617. /**
  11618. * Creates a RGBA texture from some data.
  11619. * @param data Define the texture data
  11620. * @param width Define the width of the texture
  11621. * @param height Define the height of the texture
  11622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11626. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11627. * @returns the RGBA texture
  11628. */
  11629. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11630. /**
  11631. * Creates a R texture from some data.
  11632. * @param data Define the texture data
  11633. * @param width Define the width of the texture
  11634. * @param height Define the height of the texture
  11635. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11640. * @returns the R texture
  11641. */
  11642. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11643. }
  11644. }
  11645. declare module BABYLON {
  11646. interface ThinEngine {
  11647. /**
  11648. * Update a dynamic index buffer
  11649. * @param indexBuffer defines the target index buffer
  11650. * @param indices defines the data to update
  11651. * @param offset defines the offset in the target index buffer where update should start
  11652. */
  11653. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11654. /**
  11655. * Updates a dynamic vertex buffer.
  11656. * @param vertexBuffer the vertex buffer to update
  11657. * @param data the data used to update the vertex buffer
  11658. * @param byteOffset the byte offset of the data
  11659. * @param byteLength the byte length of the data
  11660. */
  11661. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11662. }
  11663. }
  11664. declare module BABYLON {
  11665. interface AbstractScene {
  11666. /**
  11667. * The list of procedural textures added to the scene
  11668. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11669. */
  11670. proceduralTextures: Array<ProceduralTexture>;
  11671. }
  11672. /**
  11673. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11674. * in a given scene.
  11675. */
  11676. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11677. /**
  11678. * The component name helpfull to identify the component in the list of scene components.
  11679. */
  11680. readonly name: string;
  11681. /**
  11682. * The scene the component belongs to.
  11683. */
  11684. scene: Scene;
  11685. /**
  11686. * Creates a new instance of the component for the given scene
  11687. * @param scene Defines the scene to register the component in
  11688. */
  11689. constructor(scene: Scene);
  11690. /**
  11691. * Registers the component in a given scene
  11692. */
  11693. register(): void;
  11694. /**
  11695. * Rebuilds the elements related to this component in case of
  11696. * context lost for instance.
  11697. */
  11698. rebuild(): void;
  11699. /**
  11700. * Disposes the component and the associated ressources.
  11701. */
  11702. dispose(): void;
  11703. private _beforeClear;
  11704. }
  11705. }
  11706. declare module BABYLON {
  11707. interface ThinEngine {
  11708. /**
  11709. * Creates a new render target cube texture
  11710. * @param size defines the size of the texture
  11711. * @param options defines the options used to create the texture
  11712. * @returns a new render target cube texture stored in an InternalTexture
  11713. */
  11714. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11715. }
  11716. }
  11717. declare module BABYLON {
  11718. /** @hidden */
  11719. export var proceduralVertexShader: {
  11720. name: string;
  11721. shader: string;
  11722. };
  11723. }
  11724. declare module BABYLON {
  11725. /**
  11726. * 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.
  11727. * This is the base class of any Procedural texture and contains most of the shareable code.
  11728. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11729. */
  11730. export class ProceduralTexture extends Texture {
  11731. /**
  11732. * Define if the texture is enabled or not (disabled texture will not render)
  11733. */
  11734. isEnabled: boolean;
  11735. /**
  11736. * Define if the texture must be cleared before rendering (default is true)
  11737. */
  11738. autoClear: boolean;
  11739. /**
  11740. * Callback called when the texture is generated
  11741. */
  11742. onGenerated: () => void;
  11743. /**
  11744. * Event raised when the texture is generated
  11745. */
  11746. onGeneratedObservable: Observable<ProceduralTexture>;
  11747. /**
  11748. * Event raised before the texture is generated
  11749. */
  11750. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11751. /**
  11752. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11753. */
  11754. nodeMaterialSource: Nullable<NodeMaterial>;
  11755. /** @hidden */
  11756. _generateMipMaps: boolean;
  11757. /** @hidden **/
  11758. _effect: Effect;
  11759. /** @hidden */
  11760. _textures: {
  11761. [key: string]: Texture;
  11762. };
  11763. /** @hidden */
  11764. protected _fallbackTexture: Nullable<Texture>;
  11765. private _size;
  11766. private _currentRefreshId;
  11767. private _frameId;
  11768. private _refreshRate;
  11769. private _vertexBuffers;
  11770. private _indexBuffer;
  11771. private _uniforms;
  11772. private _samplers;
  11773. private _fragment;
  11774. private _floats;
  11775. private _ints;
  11776. private _floatsArrays;
  11777. private _colors3;
  11778. private _colors4;
  11779. private _vectors2;
  11780. private _vectors3;
  11781. private _matrices;
  11782. private _fallbackTextureUsed;
  11783. private _fullEngine;
  11784. private _cachedDefines;
  11785. private _contentUpdateId;
  11786. private _contentData;
  11787. /**
  11788. * Instantiates a new procedural texture.
  11789. * 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.
  11790. * This is the base class of any Procedural texture and contains most of the shareable code.
  11791. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11792. * @param name Define the name of the texture
  11793. * @param size Define the size of the texture to create
  11794. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11795. * @param scene Define the scene the texture belongs to
  11796. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11797. * @param generateMipMaps Define if the texture should creates mip maps or not
  11798. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11799. * @param textureType The FBO internal texture type
  11800. */
  11801. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11802. /**
  11803. * The effect that is created when initializing the post process.
  11804. * @returns The created effect corresponding the the postprocess.
  11805. */
  11806. getEffect(): Effect;
  11807. /**
  11808. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11809. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11810. */
  11811. getContent(): Nullable<ArrayBufferView>;
  11812. private _createIndexBuffer;
  11813. /** @hidden */
  11814. _rebuild(): void;
  11815. /**
  11816. * Resets the texture in order to recreate its associated resources.
  11817. * This can be called in case of context loss
  11818. */
  11819. reset(): void;
  11820. protected _getDefines(): string;
  11821. /**
  11822. * Is the texture ready to be used ? (rendered at least once)
  11823. * @returns true if ready, otherwise, false.
  11824. */
  11825. isReady(): boolean;
  11826. /**
  11827. * Resets the refresh counter of the texture and start bak from scratch.
  11828. * Could be useful to regenerate the texture if it is setup to render only once.
  11829. */
  11830. resetRefreshCounter(): void;
  11831. /**
  11832. * Set the fragment shader to use in order to render the texture.
  11833. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11834. */
  11835. setFragment(fragment: any): void;
  11836. /**
  11837. * Define the refresh rate of the texture or the rendering frequency.
  11838. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11839. */
  11840. get refreshRate(): number;
  11841. set refreshRate(value: number);
  11842. /** @hidden */
  11843. _shouldRender(): boolean;
  11844. /**
  11845. * Get the size the texture is rendering at.
  11846. * @returns the size (on cube texture it is always squared)
  11847. */
  11848. getRenderSize(): RenderTargetTextureSize;
  11849. /**
  11850. * Resize the texture to new value.
  11851. * @param size Define the new size the texture should have
  11852. * @param generateMipMaps Define whether the new texture should create mip maps
  11853. */
  11854. resize(size: number, generateMipMaps: boolean): void;
  11855. private _checkUniform;
  11856. /**
  11857. * Set a texture in the shader program used to render.
  11858. * @param name Define the name of the uniform samplers as defined in the shader
  11859. * @param texture Define the texture to bind to this sampler
  11860. * @return the texture itself allowing "fluent" like uniform updates
  11861. */
  11862. setTexture(name: string, texture: Texture): ProceduralTexture;
  11863. /**
  11864. * Set a float in the shader.
  11865. * @param name Define the name of the uniform as defined in the shader
  11866. * @param value Define the value to give to the uniform
  11867. * @return the texture itself allowing "fluent" like uniform updates
  11868. */
  11869. setFloat(name: string, value: number): ProceduralTexture;
  11870. /**
  11871. * Set a int in the shader.
  11872. * @param name Define the name of the uniform as defined in the shader
  11873. * @param value Define the value to give to the uniform
  11874. * @return the texture itself allowing "fluent" like uniform updates
  11875. */
  11876. setInt(name: string, value: number): ProceduralTexture;
  11877. /**
  11878. * Set an array of floats in the shader.
  11879. * @param name Define the name of the uniform as defined in the shader
  11880. * @param value Define the value to give to the uniform
  11881. * @return the texture itself allowing "fluent" like uniform updates
  11882. */
  11883. setFloats(name: string, value: number[]): ProceduralTexture;
  11884. /**
  11885. * Set a vec3 in the shader from a Color3.
  11886. * @param name Define the name of the uniform as defined in the shader
  11887. * @param value Define the value to give to the uniform
  11888. * @return the texture itself allowing "fluent" like uniform updates
  11889. */
  11890. setColor3(name: string, value: Color3): ProceduralTexture;
  11891. /**
  11892. * Set a vec4 in the shader from a Color4.
  11893. * @param name Define the name of the uniform as defined in the shader
  11894. * @param value Define the value to give to the uniform
  11895. * @return the texture itself allowing "fluent" like uniform updates
  11896. */
  11897. setColor4(name: string, value: Color4): ProceduralTexture;
  11898. /**
  11899. * Set a vec2 in the shader from a Vector2.
  11900. * @param name Define the name of the uniform as defined in the shader
  11901. * @param value Define the value to give to the uniform
  11902. * @return the texture itself allowing "fluent" like uniform updates
  11903. */
  11904. setVector2(name: string, value: Vector2): ProceduralTexture;
  11905. /**
  11906. * Set a vec3 in the shader from a Vector3.
  11907. * @param name Define the name of the uniform as defined in the shader
  11908. * @param value Define the value to give to the uniform
  11909. * @return the texture itself allowing "fluent" like uniform updates
  11910. */
  11911. setVector3(name: string, value: Vector3): ProceduralTexture;
  11912. /**
  11913. * Set a mat4 in the shader from a MAtrix.
  11914. * @param name Define the name of the uniform as defined in the shader
  11915. * @param value Define the value to give to the uniform
  11916. * @return the texture itself allowing "fluent" like uniform updates
  11917. */
  11918. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11919. /**
  11920. * Render the texture to its associated render target.
  11921. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11922. */
  11923. render(useCameraPostProcess?: boolean): void;
  11924. /**
  11925. * Clone the texture.
  11926. * @returns the cloned texture
  11927. */
  11928. clone(): ProceduralTexture;
  11929. /**
  11930. * Dispose the texture and release its asoociated resources.
  11931. */
  11932. dispose(): void;
  11933. }
  11934. }
  11935. declare module BABYLON {
  11936. /**
  11937. * This represents the base class for particle system in Babylon.
  11938. * 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.
  11939. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11940. * @example https://doc.babylonjs.com/babylon101/particles
  11941. */
  11942. export class BaseParticleSystem {
  11943. /**
  11944. * Source color is added to the destination color without alpha affecting the result
  11945. */
  11946. static BLENDMODE_ONEONE: number;
  11947. /**
  11948. * Blend current color and particle color using particle’s alpha
  11949. */
  11950. static BLENDMODE_STANDARD: number;
  11951. /**
  11952. * Add current color and particle color multiplied by particle’s alpha
  11953. */
  11954. static BLENDMODE_ADD: number;
  11955. /**
  11956. * Multiply current color with particle color
  11957. */
  11958. static BLENDMODE_MULTIPLY: number;
  11959. /**
  11960. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11961. */
  11962. static BLENDMODE_MULTIPLYADD: number;
  11963. /**
  11964. * List of animations used by the particle system.
  11965. */
  11966. animations: Animation[];
  11967. /**
  11968. * Gets or sets the unique id of the particle system
  11969. */
  11970. uniqueId: number;
  11971. /**
  11972. * The id of the Particle system.
  11973. */
  11974. id: string;
  11975. /**
  11976. * The friendly name of the Particle system.
  11977. */
  11978. name: string;
  11979. /**
  11980. * Snippet ID if the particle system was created from the snippet server
  11981. */
  11982. snippetId: string;
  11983. /**
  11984. * The rendering group used by the Particle system to chose when to render.
  11985. */
  11986. renderingGroupId: number;
  11987. /**
  11988. * The emitter represents the Mesh or position we are attaching the particle system to.
  11989. */
  11990. emitter: Nullable<AbstractMesh | Vector3>;
  11991. /**
  11992. * The maximum number of particles to emit per frame
  11993. */
  11994. emitRate: number;
  11995. /**
  11996. * If you want to launch only a few particles at once, that can be done, as well.
  11997. */
  11998. manualEmitCount: number;
  11999. /**
  12000. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12001. */
  12002. updateSpeed: number;
  12003. /**
  12004. * The amount of time the particle system is running (depends of the overall update speed).
  12005. */
  12006. targetStopDuration: number;
  12007. /**
  12008. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12009. */
  12010. disposeOnStop: boolean;
  12011. /**
  12012. * Minimum power of emitting particles.
  12013. */
  12014. minEmitPower: number;
  12015. /**
  12016. * Maximum power of emitting particles.
  12017. */
  12018. maxEmitPower: number;
  12019. /**
  12020. * Minimum life time of emitting particles.
  12021. */
  12022. minLifeTime: number;
  12023. /**
  12024. * Maximum life time of emitting particles.
  12025. */
  12026. maxLifeTime: number;
  12027. /**
  12028. * Minimum Size of emitting particles.
  12029. */
  12030. minSize: number;
  12031. /**
  12032. * Maximum Size of emitting particles.
  12033. */
  12034. maxSize: number;
  12035. /**
  12036. * Minimum scale of emitting particles on X axis.
  12037. */
  12038. minScaleX: number;
  12039. /**
  12040. * Maximum scale of emitting particles on X axis.
  12041. */
  12042. maxScaleX: number;
  12043. /**
  12044. * Minimum scale of emitting particles on Y axis.
  12045. */
  12046. minScaleY: number;
  12047. /**
  12048. * Maximum scale of emitting particles on Y axis.
  12049. */
  12050. maxScaleY: number;
  12051. /**
  12052. * Gets or sets the minimal initial rotation in radians.
  12053. */
  12054. minInitialRotation: number;
  12055. /**
  12056. * Gets or sets the maximal initial rotation in radians.
  12057. */
  12058. maxInitialRotation: number;
  12059. /**
  12060. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12061. */
  12062. minAngularSpeed: number;
  12063. /**
  12064. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12065. */
  12066. maxAngularSpeed: number;
  12067. /**
  12068. * The texture used to render each particle. (this can be a spritesheet)
  12069. */
  12070. particleTexture: Nullable<BaseTexture>;
  12071. /**
  12072. * The layer mask we are rendering the particles through.
  12073. */
  12074. layerMask: number;
  12075. /**
  12076. * This can help using your own shader to render the particle system.
  12077. * The according effect will be created
  12078. */
  12079. customShader: any;
  12080. /**
  12081. * By default particle system starts as soon as they are created. This prevents the
  12082. * automatic start to happen and let you decide when to start emitting particles.
  12083. */
  12084. preventAutoStart: boolean;
  12085. private _noiseTexture;
  12086. /**
  12087. * Gets or sets a texture used to add random noise to particle positions
  12088. */
  12089. get noiseTexture(): Nullable<ProceduralTexture>;
  12090. set noiseTexture(value: Nullable<ProceduralTexture>);
  12091. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12092. noiseStrength: Vector3;
  12093. /**
  12094. * Callback triggered when the particle animation is ending.
  12095. */
  12096. onAnimationEnd: Nullable<() => void>;
  12097. /**
  12098. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12099. */
  12100. blendMode: number;
  12101. /**
  12102. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12103. * to override the particles.
  12104. */
  12105. forceDepthWrite: boolean;
  12106. /** 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 */
  12107. preWarmCycles: number;
  12108. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12109. preWarmStepOffset: number;
  12110. /**
  12111. * 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)
  12112. */
  12113. spriteCellChangeSpeed: number;
  12114. /**
  12115. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12116. */
  12117. startSpriteCellID: number;
  12118. /**
  12119. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12120. */
  12121. endSpriteCellID: number;
  12122. /**
  12123. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12124. */
  12125. spriteCellWidth: number;
  12126. /**
  12127. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12128. */
  12129. spriteCellHeight: number;
  12130. /**
  12131. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12132. */
  12133. spriteRandomStartCell: boolean;
  12134. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12135. translationPivot: Vector2;
  12136. /** @hidden */
  12137. protected _isAnimationSheetEnabled: boolean;
  12138. /**
  12139. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12140. */
  12141. beginAnimationOnStart: boolean;
  12142. /**
  12143. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12144. */
  12145. beginAnimationFrom: number;
  12146. /**
  12147. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12148. */
  12149. beginAnimationTo: number;
  12150. /**
  12151. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12152. */
  12153. beginAnimationLoop: boolean;
  12154. /**
  12155. * Gets or sets a world offset applied to all particles
  12156. */
  12157. worldOffset: Vector3;
  12158. /**
  12159. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12160. */
  12161. get isAnimationSheetEnabled(): boolean;
  12162. set isAnimationSheetEnabled(value: boolean);
  12163. /**
  12164. * Get hosting scene
  12165. * @returns the scene
  12166. */
  12167. getScene(): Nullable<Scene>;
  12168. /**
  12169. * You can use gravity if you want to give an orientation to your particles.
  12170. */
  12171. gravity: Vector3;
  12172. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12173. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12174. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12175. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12176. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12177. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12178. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12179. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12180. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12181. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12182. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12183. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12184. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12185. /**
  12186. * Defines the delay in milliseconds before starting the system (0 by default)
  12187. */
  12188. startDelay: number;
  12189. /**
  12190. * Gets the current list of drag gradients.
  12191. * You must use addDragGradient and removeDragGradient to udpate this list
  12192. * @returns the list of drag gradients
  12193. */
  12194. getDragGradients(): Nullable<Array<FactorGradient>>;
  12195. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12196. limitVelocityDamping: number;
  12197. /**
  12198. * Gets the current list of limit velocity gradients.
  12199. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12200. * @returns the list of limit velocity gradients
  12201. */
  12202. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12203. /**
  12204. * Gets the current list of color gradients.
  12205. * You must use addColorGradient and removeColorGradient to udpate this list
  12206. * @returns the list of color gradients
  12207. */
  12208. getColorGradients(): Nullable<Array<ColorGradient>>;
  12209. /**
  12210. * Gets the current list of size gradients.
  12211. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12212. * @returns the list of size gradients
  12213. */
  12214. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12215. /**
  12216. * Gets the current list of color remap gradients.
  12217. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12218. * @returns the list of color remap gradients
  12219. */
  12220. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12221. /**
  12222. * Gets the current list of alpha remap gradients.
  12223. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12224. * @returns the list of alpha remap gradients
  12225. */
  12226. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12227. /**
  12228. * Gets the current list of life time gradients.
  12229. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12230. * @returns the list of life time gradients
  12231. */
  12232. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12233. /**
  12234. * Gets the current list of angular speed gradients.
  12235. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12236. * @returns the list of angular speed gradients
  12237. */
  12238. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12239. /**
  12240. * Gets the current list of velocity gradients.
  12241. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12242. * @returns the list of velocity gradients
  12243. */
  12244. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12245. /**
  12246. * Gets the current list of start size gradients.
  12247. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12248. * @returns the list of start size gradients
  12249. */
  12250. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12251. /**
  12252. * Gets the current list of emit rate gradients.
  12253. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12254. * @returns the list of emit rate gradients
  12255. */
  12256. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12257. /**
  12258. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12259. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12260. */
  12261. get direction1(): Vector3;
  12262. set direction1(value: Vector3);
  12263. /**
  12264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12265. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12266. */
  12267. get direction2(): Vector3;
  12268. set direction2(value: Vector3);
  12269. /**
  12270. * 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.
  12271. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12272. */
  12273. get minEmitBox(): Vector3;
  12274. set minEmitBox(value: Vector3);
  12275. /**
  12276. * 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.
  12277. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12278. */
  12279. get maxEmitBox(): Vector3;
  12280. set maxEmitBox(value: Vector3);
  12281. /**
  12282. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12283. */
  12284. color1: Color4;
  12285. /**
  12286. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12287. */
  12288. color2: Color4;
  12289. /**
  12290. * Color the particle will have at the end of its lifetime
  12291. */
  12292. colorDead: Color4;
  12293. /**
  12294. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12295. */
  12296. textureMask: Color4;
  12297. /**
  12298. * The particle emitter type defines the emitter used by the particle system.
  12299. * It can be for example box, sphere, or cone...
  12300. */
  12301. particleEmitterType: IParticleEmitterType;
  12302. /** @hidden */
  12303. _isSubEmitter: boolean;
  12304. /**
  12305. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12306. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12307. */
  12308. billboardMode: number;
  12309. protected _isBillboardBased: boolean;
  12310. /**
  12311. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12312. */
  12313. get isBillboardBased(): boolean;
  12314. set isBillboardBased(value: boolean);
  12315. /**
  12316. * The scene the particle system belongs to.
  12317. */
  12318. protected _scene: Nullable<Scene>;
  12319. /**
  12320. * The engine the particle system belongs to.
  12321. */
  12322. protected _engine: ThinEngine;
  12323. /**
  12324. * Local cache of defines for image processing.
  12325. */
  12326. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12327. /**
  12328. * Default configuration related to image processing available in the standard Material.
  12329. */
  12330. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12331. /**
  12332. * Gets the image processing configuration used either in this material.
  12333. */
  12334. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12335. /**
  12336. * Sets the Default image processing configuration used either in the this material.
  12337. *
  12338. * If sets to null, the scene one is in use.
  12339. */
  12340. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12341. /**
  12342. * Attaches a new image processing configuration to the Standard Material.
  12343. * @param configuration
  12344. */
  12345. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12346. /** @hidden */
  12347. protected _reset(): void;
  12348. /** @hidden */
  12349. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12350. /**
  12351. * Instantiates a particle system.
  12352. * 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.
  12353. * @param name The name of the particle system
  12354. */
  12355. constructor(name: string);
  12356. /**
  12357. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12360. * @returns the emitter
  12361. */
  12362. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12363. /**
  12364. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12365. * @param radius The radius of the hemisphere to emit from
  12366. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12367. * @returns the emitter
  12368. */
  12369. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12370. /**
  12371. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12372. * @param radius The radius of the sphere to emit from
  12373. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12374. * @returns the emitter
  12375. */
  12376. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12377. /**
  12378. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12379. * @param radius The radius of the sphere to emit from
  12380. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12381. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12382. * @returns the emitter
  12383. */
  12384. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12385. /**
  12386. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12387. * @param radius The radius of the emission cylinder
  12388. * @param height The height of the emission cylinder
  12389. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12390. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12391. * @returns the emitter
  12392. */
  12393. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12394. /**
  12395. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12396. * @param radius The radius of the cylinder to emit from
  12397. * @param height The height of the emission cylinder
  12398. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12399. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12400. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12401. * @returns the emitter
  12402. */
  12403. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12404. /**
  12405. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12406. * @param radius The radius of the cone to emit from
  12407. * @param angle The base angle of the cone
  12408. * @returns the emitter
  12409. */
  12410. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12411. /**
  12412. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12413. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12414. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12415. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12416. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12417. * @returns the emitter
  12418. */
  12419. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12420. }
  12421. }
  12422. declare module BABYLON {
  12423. /**
  12424. * Type of sub emitter
  12425. */
  12426. export enum SubEmitterType {
  12427. /**
  12428. * Attached to the particle over it's lifetime
  12429. */
  12430. ATTACHED = 0,
  12431. /**
  12432. * Created when the particle dies
  12433. */
  12434. END = 1
  12435. }
  12436. /**
  12437. * Sub emitter class used to emit particles from an existing particle
  12438. */
  12439. export class SubEmitter {
  12440. /**
  12441. * the particle system to be used by the sub emitter
  12442. */
  12443. particleSystem: ParticleSystem;
  12444. /**
  12445. * Type of the submitter (Default: END)
  12446. */
  12447. type: SubEmitterType;
  12448. /**
  12449. * 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)
  12450. * Note: This only is supported when using an emitter of type Mesh
  12451. */
  12452. inheritDirection: boolean;
  12453. /**
  12454. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12455. */
  12456. inheritedVelocityAmount: number;
  12457. /**
  12458. * Creates a sub emitter
  12459. * @param particleSystem the particle system to be used by the sub emitter
  12460. */
  12461. constructor(
  12462. /**
  12463. * the particle system to be used by the sub emitter
  12464. */
  12465. particleSystem: ParticleSystem);
  12466. /**
  12467. * Clones the sub emitter
  12468. * @returns the cloned sub emitter
  12469. */
  12470. clone(): SubEmitter;
  12471. /**
  12472. * Serialize current object to a JSON object
  12473. * @returns the serialized object
  12474. */
  12475. serialize(): any;
  12476. /** @hidden */
  12477. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12478. /**
  12479. * Creates a new SubEmitter from a serialized JSON version
  12480. * @param serializationObject defines the JSON object to read from
  12481. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12482. * @param rootUrl defines the rootUrl for data loading
  12483. * @returns a new SubEmitter
  12484. */
  12485. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12486. /** Release associated resources */
  12487. dispose(): void;
  12488. }
  12489. }
  12490. declare module BABYLON {
  12491. /** @hidden */
  12492. export var imageProcessingDeclaration: {
  12493. name: string;
  12494. shader: string;
  12495. };
  12496. }
  12497. declare module BABYLON {
  12498. /** @hidden */
  12499. export var imageProcessingFunctions: {
  12500. name: string;
  12501. shader: string;
  12502. };
  12503. }
  12504. declare module BABYLON {
  12505. /** @hidden */
  12506. export var particlesPixelShader: {
  12507. name: string;
  12508. shader: string;
  12509. };
  12510. }
  12511. declare module BABYLON {
  12512. /** @hidden */
  12513. export var particlesVertexShader: {
  12514. name: string;
  12515. shader: string;
  12516. };
  12517. }
  12518. declare module BABYLON {
  12519. /**
  12520. * Interface used to define entities containing multiple clip planes
  12521. */
  12522. export interface IClipPlanesHolder {
  12523. /**
  12524. * Gets or sets the active clipplane 1
  12525. */
  12526. clipPlane: Nullable<Plane>;
  12527. /**
  12528. * Gets or sets the active clipplane 2
  12529. */
  12530. clipPlane2: Nullable<Plane>;
  12531. /**
  12532. * Gets or sets the active clipplane 3
  12533. */
  12534. clipPlane3: Nullable<Plane>;
  12535. /**
  12536. * Gets or sets the active clipplane 4
  12537. */
  12538. clipPlane4: Nullable<Plane>;
  12539. /**
  12540. * Gets or sets the active clipplane 5
  12541. */
  12542. clipPlane5: Nullable<Plane>;
  12543. /**
  12544. * Gets or sets the active clipplane 6
  12545. */
  12546. clipPlane6: Nullable<Plane>;
  12547. }
  12548. }
  12549. declare module BABYLON {
  12550. /**
  12551. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12552. *
  12553. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12554. *
  12555. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12556. */
  12557. export class ThinMaterialHelper {
  12558. /**
  12559. * Binds the clip plane information from the holder to the effect.
  12560. * @param effect The effect we are binding the data to
  12561. * @param holder The entity containing the clip plane information
  12562. */
  12563. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12564. }
  12565. }
  12566. declare module BABYLON {
  12567. interface ThinEngine {
  12568. /**
  12569. * Sets alpha constants used by some alpha blending modes
  12570. * @param r defines the red component
  12571. * @param g defines the green component
  12572. * @param b defines the blue component
  12573. * @param a defines the alpha component
  12574. */
  12575. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12576. /**
  12577. * Sets the current alpha mode
  12578. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12579. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12580. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12581. */
  12582. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12583. /**
  12584. * Gets the current alpha mode
  12585. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12586. * @returns the current alpha mode
  12587. */
  12588. getAlphaMode(): number;
  12589. /**
  12590. * Sets the current alpha equation
  12591. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12592. */
  12593. setAlphaEquation(equation: number): void;
  12594. /**
  12595. * Gets the current alpha equation.
  12596. * @returns the current alpha equation
  12597. */
  12598. getAlphaEquation(): number;
  12599. }
  12600. }
  12601. declare module BABYLON {
  12602. /**
  12603. * This represents a particle system in Babylon.
  12604. * 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.
  12605. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12606. * @example https://doc.babylonjs.com/babylon101/particles
  12607. */
  12608. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12609. /**
  12610. * Billboard mode will only apply to Y axis
  12611. */
  12612. static readonly BILLBOARDMODE_Y: number;
  12613. /**
  12614. * Billboard mode will apply to all axes
  12615. */
  12616. static readonly BILLBOARDMODE_ALL: number;
  12617. /**
  12618. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12619. */
  12620. static readonly BILLBOARDMODE_STRETCHED: number;
  12621. /**
  12622. * This function can be defined to provide custom update for active particles.
  12623. * This function will be called instead of regular update (age, position, color, etc.).
  12624. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12625. */
  12626. updateFunction: (particles: Particle[]) => void;
  12627. private _emitterWorldMatrix;
  12628. /**
  12629. * This function can be defined to specify initial direction for every new particle.
  12630. * It by default use the emitterType defined function
  12631. */
  12632. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12633. /**
  12634. * This function can be defined to specify initial position for every new particle.
  12635. * It by default use the emitterType defined function
  12636. */
  12637. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12638. /**
  12639. * @hidden
  12640. */
  12641. _inheritedVelocityOffset: Vector3;
  12642. /**
  12643. * An event triggered when the system is disposed
  12644. */
  12645. onDisposeObservable: Observable<IParticleSystem>;
  12646. private _onDisposeObserver;
  12647. /**
  12648. * Sets a callback that will be triggered when the system is disposed
  12649. */
  12650. set onDispose(callback: () => void);
  12651. private _particles;
  12652. private _epsilon;
  12653. private _capacity;
  12654. private _stockParticles;
  12655. private _newPartsExcess;
  12656. private _vertexData;
  12657. private _vertexBuffer;
  12658. private _vertexBuffers;
  12659. private _spriteBuffer;
  12660. private _indexBuffer;
  12661. private _effect;
  12662. private _customEffect;
  12663. private _cachedDefines;
  12664. private _scaledColorStep;
  12665. private _colorDiff;
  12666. private _scaledDirection;
  12667. private _scaledGravity;
  12668. private _currentRenderId;
  12669. private _alive;
  12670. private _useInstancing;
  12671. private _started;
  12672. private _stopped;
  12673. private _actualFrame;
  12674. private _scaledUpdateSpeed;
  12675. private _vertexBufferSize;
  12676. /** @hidden */
  12677. _currentEmitRateGradient: Nullable<FactorGradient>;
  12678. /** @hidden */
  12679. _currentEmitRate1: number;
  12680. /** @hidden */
  12681. _currentEmitRate2: number;
  12682. /** @hidden */
  12683. _currentStartSizeGradient: Nullable<FactorGradient>;
  12684. /** @hidden */
  12685. _currentStartSize1: number;
  12686. /** @hidden */
  12687. _currentStartSize2: number;
  12688. private readonly _rawTextureWidth;
  12689. private _rampGradientsTexture;
  12690. private _useRampGradients;
  12691. /** Gets or sets a matrix to use to compute projection */
  12692. defaultProjectionMatrix: Matrix;
  12693. /** Gets or sets a matrix to use to compute view */
  12694. defaultViewMatrix: Matrix;
  12695. /** Gets or sets a boolean indicating that ramp gradients must be used
  12696. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12697. */
  12698. get useRampGradients(): boolean;
  12699. set useRampGradients(value: boolean);
  12700. /**
  12701. * 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.
  12702. * 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: [])
  12703. */
  12704. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12705. private _subEmitters;
  12706. /**
  12707. * @hidden
  12708. * If the particle systems emitter should be disposed when the particle system is disposed
  12709. */
  12710. _disposeEmitterOnDispose: boolean;
  12711. /**
  12712. * The current active Sub-systems, this property is used by the root particle system only.
  12713. */
  12714. activeSubSystems: Array<ParticleSystem>;
  12715. /**
  12716. * Specifies if the particles are updated in emitter local space or world space
  12717. */
  12718. isLocal: boolean;
  12719. private _rootParticleSystem;
  12720. /**
  12721. * Gets the current list of active particles
  12722. */
  12723. get particles(): Particle[];
  12724. /**
  12725. * Gets the number of particles active at the same time.
  12726. * @returns The number of active particles.
  12727. */
  12728. getActiveCount(): number;
  12729. /**
  12730. * Returns the string "ParticleSystem"
  12731. * @returns a string containing the class name
  12732. */
  12733. getClassName(): string;
  12734. /**
  12735. * Gets a boolean indicating that the system is stopping
  12736. * @returns true if the system is currently stopping
  12737. */
  12738. isStopping(): boolean;
  12739. /**
  12740. * Gets the custom effect used to render the particles
  12741. * @param blendMode Blend mode for which the effect should be retrieved
  12742. * @returns The effect
  12743. */
  12744. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12745. /**
  12746. * Sets the custom effect used to render the particles
  12747. * @param effect The effect to set
  12748. * @param blendMode Blend mode for which the effect should be set
  12749. */
  12750. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12751. /** @hidden */
  12752. private _onBeforeDrawParticlesObservable;
  12753. /**
  12754. * Observable that will be called just before the particles are drawn
  12755. */
  12756. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12757. /**
  12758. * Gets the name of the particle vertex shader
  12759. */
  12760. get vertexShaderName(): string;
  12761. /**
  12762. * Instantiates a particle system.
  12763. * 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.
  12764. * @param name The name of the particle system
  12765. * @param capacity The max number of particles alive at the same time
  12766. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12767. * @param customEffect a custom effect used to change the way particles are rendered by default
  12768. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12769. * @param epsilon Offset used to render the particles
  12770. */
  12771. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12772. private _addFactorGradient;
  12773. private _removeFactorGradient;
  12774. /**
  12775. * Adds a new life time gradient
  12776. * @param gradient defines the gradient to use (between 0 and 1)
  12777. * @param factor defines the life time factor to affect to the specified gradient
  12778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12779. * @returns the current particle system
  12780. */
  12781. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12782. /**
  12783. * Remove a specific life time gradient
  12784. * @param gradient defines the gradient to remove
  12785. * @returns the current particle system
  12786. */
  12787. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12788. /**
  12789. * Adds a new size gradient
  12790. * @param gradient defines the gradient to use (between 0 and 1)
  12791. * @param factor defines the size factor to affect to the specified gradient
  12792. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12793. * @returns the current particle system
  12794. */
  12795. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12796. /**
  12797. * Remove a specific size gradient
  12798. * @param gradient defines the gradient to remove
  12799. * @returns the current particle system
  12800. */
  12801. removeSizeGradient(gradient: number): IParticleSystem;
  12802. /**
  12803. * Adds a new color remap gradient
  12804. * @param gradient defines the gradient to use (between 0 and 1)
  12805. * @param min defines the color remap minimal range
  12806. * @param max defines the color remap maximal range
  12807. * @returns the current particle system
  12808. */
  12809. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12810. /**
  12811. * Remove a specific color remap gradient
  12812. * @param gradient defines the gradient to remove
  12813. * @returns the current particle system
  12814. */
  12815. removeColorRemapGradient(gradient: number): IParticleSystem;
  12816. /**
  12817. * Adds a new alpha remap gradient
  12818. * @param gradient defines the gradient to use (between 0 and 1)
  12819. * @param min defines the alpha remap minimal range
  12820. * @param max defines the alpha remap maximal range
  12821. * @returns the current particle system
  12822. */
  12823. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12824. /**
  12825. * Remove a specific alpha remap gradient
  12826. * @param gradient defines the gradient to remove
  12827. * @returns the current particle system
  12828. */
  12829. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12830. /**
  12831. * Adds a new angular speed gradient
  12832. * @param gradient defines the gradient to use (between 0 and 1)
  12833. * @param factor defines the angular speed to affect to the specified gradient
  12834. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12835. * @returns the current particle system
  12836. */
  12837. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12838. /**
  12839. * Remove a specific angular speed gradient
  12840. * @param gradient defines the gradient to remove
  12841. * @returns the current particle system
  12842. */
  12843. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12844. /**
  12845. * Adds a new velocity gradient
  12846. * @param gradient defines the gradient to use (between 0 and 1)
  12847. * @param factor defines the velocity to affect to the specified gradient
  12848. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12849. * @returns the current particle system
  12850. */
  12851. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12852. /**
  12853. * Remove a specific velocity gradient
  12854. * @param gradient defines the gradient to remove
  12855. * @returns the current particle system
  12856. */
  12857. removeVelocityGradient(gradient: number): IParticleSystem;
  12858. /**
  12859. * Adds a new limit velocity gradient
  12860. * @param gradient defines the gradient to use (between 0 and 1)
  12861. * @param factor defines the limit velocity value to affect to the specified gradient
  12862. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12863. * @returns the current particle system
  12864. */
  12865. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12866. /**
  12867. * Remove a specific limit velocity gradient
  12868. * @param gradient defines the gradient to remove
  12869. * @returns the current particle system
  12870. */
  12871. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12872. /**
  12873. * Adds a new drag gradient
  12874. * @param gradient defines the gradient to use (between 0 and 1)
  12875. * @param factor defines the drag value to affect to the specified gradient
  12876. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12877. * @returns the current particle system
  12878. */
  12879. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12880. /**
  12881. * Remove a specific drag gradient
  12882. * @param gradient defines the gradient to remove
  12883. * @returns the current particle system
  12884. */
  12885. removeDragGradient(gradient: number): IParticleSystem;
  12886. /**
  12887. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12888. * @param gradient defines the gradient to use (between 0 and 1)
  12889. * @param factor defines the emit rate value to affect to the specified gradient
  12890. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12891. * @returns the current particle system
  12892. */
  12893. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12894. /**
  12895. * Remove a specific emit rate gradient
  12896. * @param gradient defines the gradient to remove
  12897. * @returns the current particle system
  12898. */
  12899. removeEmitRateGradient(gradient: number): IParticleSystem;
  12900. /**
  12901. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12902. * @param gradient defines the gradient to use (between 0 and 1)
  12903. * @param factor defines the start size value to affect to the specified gradient
  12904. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12905. * @returns the current particle system
  12906. */
  12907. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12908. /**
  12909. * Remove a specific start size gradient
  12910. * @param gradient defines the gradient to remove
  12911. * @returns the current particle system
  12912. */
  12913. removeStartSizeGradient(gradient: number): IParticleSystem;
  12914. private _createRampGradientTexture;
  12915. /**
  12916. * Gets the current list of ramp gradients.
  12917. * You must use addRampGradient and removeRampGradient to udpate this list
  12918. * @returns the list of ramp gradients
  12919. */
  12920. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12921. /** Force the system to rebuild all gradients that need to be resync */
  12922. forceRefreshGradients(): void;
  12923. private _syncRampGradientTexture;
  12924. /**
  12925. * Adds a new ramp gradient used to remap particle colors
  12926. * @param gradient defines the gradient to use (between 0 and 1)
  12927. * @param color defines the color to affect to the specified gradient
  12928. * @returns the current particle system
  12929. */
  12930. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12931. /**
  12932. * Remove a specific ramp gradient
  12933. * @param gradient defines the gradient to remove
  12934. * @returns the current particle system
  12935. */
  12936. removeRampGradient(gradient: number): ParticleSystem;
  12937. /**
  12938. * Adds a new color gradient
  12939. * @param gradient defines the gradient to use (between 0 and 1)
  12940. * @param color1 defines the color to affect to the specified gradient
  12941. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12942. * @returns this particle system
  12943. */
  12944. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12945. /**
  12946. * Remove a specific color gradient
  12947. * @param gradient defines the gradient to remove
  12948. * @returns this particle system
  12949. */
  12950. removeColorGradient(gradient: number): IParticleSystem;
  12951. private _fetchR;
  12952. protected _reset(): void;
  12953. private _resetEffect;
  12954. private _createVertexBuffers;
  12955. private _createIndexBuffer;
  12956. /**
  12957. * Gets the maximum number of particles active at the same time.
  12958. * @returns The max number of active particles.
  12959. */
  12960. getCapacity(): number;
  12961. /**
  12962. * Gets whether there are still active particles in the system.
  12963. * @returns True if it is alive, otherwise false.
  12964. */
  12965. isAlive(): boolean;
  12966. /**
  12967. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12968. * @returns True if it has been started, otherwise false.
  12969. */
  12970. isStarted(): boolean;
  12971. private _prepareSubEmitterInternalArray;
  12972. /**
  12973. * Starts the particle system and begins to emit
  12974. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12975. */
  12976. start(delay?: number): void;
  12977. /**
  12978. * Stops the particle system.
  12979. * @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.
  12980. */
  12981. stop(stopSubEmitters?: boolean): void;
  12982. /**
  12983. * Remove all active particles
  12984. */
  12985. reset(): void;
  12986. /**
  12987. * @hidden (for internal use only)
  12988. */
  12989. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12990. /**
  12991. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12992. * Its lifetime will start back at 0.
  12993. */
  12994. recycleParticle: (particle: Particle) => void;
  12995. private _stopSubEmitters;
  12996. private _createParticle;
  12997. private _removeFromRoot;
  12998. private _emitFromParticle;
  12999. private _update;
  13000. /** @hidden */
  13001. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13002. /** @hidden */
  13003. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13004. /**
  13005. * Fill the defines array according to the current settings of the particle system
  13006. * @param defines Array to be updated
  13007. * @param blendMode blend mode to take into account when updating the array
  13008. */
  13009. fillDefines(defines: Array<string>, blendMode: number): void;
  13010. /**
  13011. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13012. * @param uniforms Uniforms array to fill
  13013. * @param attributes Attributes array to fill
  13014. * @param samplers Samplers array to fill
  13015. */
  13016. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13017. /** @hidden */
  13018. private _getEffect;
  13019. /**
  13020. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13021. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13022. */
  13023. animate(preWarmOnly?: boolean): void;
  13024. private _appendParticleVertices;
  13025. /**
  13026. * Rebuilds the particle system.
  13027. */
  13028. rebuild(): void;
  13029. /**
  13030. * Is this system ready to be used/rendered
  13031. * @return true if the system is ready
  13032. */
  13033. isReady(): boolean;
  13034. private _render;
  13035. /**
  13036. * Renders the particle system in its current state.
  13037. * @returns the current number of particles
  13038. */
  13039. render(): number;
  13040. /**
  13041. * Disposes the particle system and free the associated resources
  13042. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13043. */
  13044. dispose(disposeTexture?: boolean): void;
  13045. /**
  13046. * Clones the particle system.
  13047. * @param name The name of the cloned object
  13048. * @param newEmitter The new emitter to use
  13049. * @returns the cloned particle system
  13050. */
  13051. clone(name: string, newEmitter: any): ParticleSystem;
  13052. /**
  13053. * Serializes the particle system to a JSON object
  13054. * @param serializeTexture defines if the texture must be serialized as well
  13055. * @returns the JSON object
  13056. */
  13057. serialize(serializeTexture?: boolean): any;
  13058. /** @hidden */
  13059. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13060. /** @hidden */
  13061. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13062. /**
  13063. * Parses a JSON object to create a particle system.
  13064. * @param parsedParticleSystem The JSON object to parse
  13065. * @param sceneOrEngine The scene or the engine to create the particle system in
  13066. * @param rootUrl The root url to use to load external dependencies like texture
  13067. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13068. * @returns the Parsed particle system
  13069. */
  13070. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13071. }
  13072. }
  13073. declare module BABYLON {
  13074. /**
  13075. * A particle represents one of the element emitted by a particle system.
  13076. * This is mainly define by its coordinates, direction, velocity and age.
  13077. */
  13078. export class Particle {
  13079. /**
  13080. * The particle system the particle belongs to.
  13081. */
  13082. particleSystem: ParticleSystem;
  13083. private static _Count;
  13084. /**
  13085. * Unique ID of the particle
  13086. */
  13087. id: number;
  13088. /**
  13089. * The world position of the particle in the scene.
  13090. */
  13091. position: Vector3;
  13092. /**
  13093. * The world direction of the particle in the scene.
  13094. */
  13095. direction: Vector3;
  13096. /**
  13097. * The color of the particle.
  13098. */
  13099. color: Color4;
  13100. /**
  13101. * The color change of the particle per step.
  13102. */
  13103. colorStep: Color4;
  13104. /**
  13105. * Defines how long will the life of the particle be.
  13106. */
  13107. lifeTime: number;
  13108. /**
  13109. * The current age of the particle.
  13110. */
  13111. age: number;
  13112. /**
  13113. * The current size of the particle.
  13114. */
  13115. size: number;
  13116. /**
  13117. * The current scale of the particle.
  13118. */
  13119. scale: Vector2;
  13120. /**
  13121. * The current angle of the particle.
  13122. */
  13123. angle: number;
  13124. /**
  13125. * Defines how fast is the angle changing.
  13126. */
  13127. angularSpeed: number;
  13128. /**
  13129. * Defines the cell index used by the particle to be rendered from a sprite.
  13130. */
  13131. cellIndex: number;
  13132. /**
  13133. * The information required to support color remapping
  13134. */
  13135. remapData: Vector4;
  13136. /** @hidden */
  13137. _randomCellOffset?: number;
  13138. /** @hidden */
  13139. _initialDirection: Nullable<Vector3>;
  13140. /** @hidden */
  13141. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13142. /** @hidden */
  13143. _initialStartSpriteCellID: number;
  13144. /** @hidden */
  13145. _initialEndSpriteCellID: number;
  13146. /** @hidden */
  13147. _currentColorGradient: Nullable<ColorGradient>;
  13148. /** @hidden */
  13149. _currentColor1: Color4;
  13150. /** @hidden */
  13151. _currentColor2: Color4;
  13152. /** @hidden */
  13153. _currentSizeGradient: Nullable<FactorGradient>;
  13154. /** @hidden */
  13155. _currentSize1: number;
  13156. /** @hidden */
  13157. _currentSize2: number;
  13158. /** @hidden */
  13159. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13160. /** @hidden */
  13161. _currentAngularSpeed1: number;
  13162. /** @hidden */
  13163. _currentAngularSpeed2: number;
  13164. /** @hidden */
  13165. _currentVelocityGradient: Nullable<FactorGradient>;
  13166. /** @hidden */
  13167. _currentVelocity1: number;
  13168. /** @hidden */
  13169. _currentVelocity2: number;
  13170. /** @hidden */
  13171. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13172. /** @hidden */
  13173. _currentLimitVelocity1: number;
  13174. /** @hidden */
  13175. _currentLimitVelocity2: number;
  13176. /** @hidden */
  13177. _currentDragGradient: Nullable<FactorGradient>;
  13178. /** @hidden */
  13179. _currentDrag1: number;
  13180. /** @hidden */
  13181. _currentDrag2: number;
  13182. /** @hidden */
  13183. _randomNoiseCoordinates1: Vector3;
  13184. /** @hidden */
  13185. _randomNoiseCoordinates2: Vector3;
  13186. /** @hidden */
  13187. _localPosition?: Vector3;
  13188. /**
  13189. * Creates a new instance Particle
  13190. * @param particleSystem the particle system the particle belongs to
  13191. */
  13192. constructor(
  13193. /**
  13194. * The particle system the particle belongs to.
  13195. */
  13196. particleSystem: ParticleSystem);
  13197. private updateCellInfoFromSystem;
  13198. /**
  13199. * Defines how the sprite cell index is updated for the particle
  13200. */
  13201. updateCellIndex(): void;
  13202. /** @hidden */
  13203. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13204. /** @hidden */
  13205. _inheritParticleInfoToSubEmitters(): void;
  13206. /** @hidden */
  13207. _reset(): void;
  13208. /**
  13209. * Copy the properties of particle to another one.
  13210. * @param other the particle to copy the information to.
  13211. */
  13212. copyTo(other: Particle): void;
  13213. }
  13214. }
  13215. declare module BABYLON {
  13216. /**
  13217. * Particle emitter represents a volume emitting particles.
  13218. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13219. */
  13220. export interface IParticleEmitterType {
  13221. /**
  13222. * Called by the particle System when the direction is computed for the created particle.
  13223. * @param worldMatrix is the world matrix of the particle system
  13224. * @param directionToUpdate is the direction vector to update with the result
  13225. * @param particle is the particle we are computed the direction for
  13226. * @param isLocal defines if the direction should be set in local space
  13227. */
  13228. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13229. /**
  13230. * Called by the particle System when the position is computed for the created particle.
  13231. * @param worldMatrix is the world matrix of the particle system
  13232. * @param positionToUpdate is the position vector to update with the result
  13233. * @param particle is the particle we are computed the position for
  13234. * @param isLocal defines if the position should be set in local space
  13235. */
  13236. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13237. /**
  13238. * Clones the current emitter and returns a copy of it
  13239. * @returns the new emitter
  13240. */
  13241. clone(): IParticleEmitterType;
  13242. /**
  13243. * Called by the GPUParticleSystem to setup the update shader
  13244. * @param effect defines the update shader
  13245. */
  13246. applyToShader(effect: Effect): void;
  13247. /**
  13248. * Returns a string to use to update the GPU particles update shader
  13249. * @returns the effect defines string
  13250. */
  13251. getEffectDefines(): string;
  13252. /**
  13253. * Returns a string representing the class name
  13254. * @returns a string containing the class name
  13255. */
  13256. getClassName(): string;
  13257. /**
  13258. * Serializes the particle system to a JSON object.
  13259. * @returns the JSON object
  13260. */
  13261. serialize(): any;
  13262. /**
  13263. * Parse properties from a JSON object
  13264. * @param serializationObject defines the JSON object
  13265. * @param scene defines the hosting scene
  13266. */
  13267. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13268. }
  13269. }
  13270. declare module BABYLON {
  13271. /**
  13272. * Particle emitter emitting particles from the inside of a box.
  13273. * It emits the particles randomly between 2 given directions.
  13274. */
  13275. export class BoxParticleEmitter implements IParticleEmitterType {
  13276. /**
  13277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13278. */
  13279. direction1: Vector3;
  13280. /**
  13281. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13282. */
  13283. direction2: Vector3;
  13284. /**
  13285. * 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.
  13286. */
  13287. minEmitBox: Vector3;
  13288. /**
  13289. * 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.
  13290. */
  13291. maxEmitBox: Vector3;
  13292. /**
  13293. * Creates a new instance BoxParticleEmitter
  13294. */
  13295. constructor();
  13296. /**
  13297. * Called by the particle System when the direction is computed for the created particle.
  13298. * @param worldMatrix is the world matrix of the particle system
  13299. * @param directionToUpdate is the direction vector to update with the result
  13300. * @param particle is the particle we are computed the direction for
  13301. * @param isLocal defines if the direction should be set in local space
  13302. */
  13303. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13304. /**
  13305. * Called by the particle System when the position is computed for the created particle.
  13306. * @param worldMatrix is the world matrix of the particle system
  13307. * @param positionToUpdate is the position vector to update with the result
  13308. * @param particle is the particle we are computed the position for
  13309. * @param isLocal defines if the position should be set in local space
  13310. */
  13311. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13312. /**
  13313. * Clones the current emitter and returns a copy of it
  13314. * @returns the new emitter
  13315. */
  13316. clone(): BoxParticleEmitter;
  13317. /**
  13318. * Called by the GPUParticleSystem to setup the update shader
  13319. * @param effect defines the update shader
  13320. */
  13321. applyToShader(effect: Effect): void;
  13322. /**
  13323. * Returns a string to use to update the GPU particles update shader
  13324. * @returns a string containng the defines string
  13325. */
  13326. getEffectDefines(): string;
  13327. /**
  13328. * Returns the string "BoxParticleEmitter"
  13329. * @returns a string containing the class name
  13330. */
  13331. getClassName(): string;
  13332. /**
  13333. * Serializes the particle system to a JSON object.
  13334. * @returns the JSON object
  13335. */
  13336. serialize(): any;
  13337. /**
  13338. * Parse properties from a JSON object
  13339. * @param serializationObject defines the JSON object
  13340. */
  13341. parse(serializationObject: any): void;
  13342. }
  13343. }
  13344. declare module BABYLON {
  13345. /**
  13346. * Particle emitter emitting particles from the inside of a cone.
  13347. * It emits the particles alongside the cone volume from the base to the particle.
  13348. * The emission direction might be randomized.
  13349. */
  13350. export class ConeParticleEmitter implements IParticleEmitterType {
  13351. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13352. directionRandomizer: number;
  13353. private _radius;
  13354. private _angle;
  13355. private _height;
  13356. /**
  13357. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13358. */
  13359. radiusRange: number;
  13360. /**
  13361. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13362. */
  13363. heightRange: number;
  13364. /**
  13365. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13366. */
  13367. emitFromSpawnPointOnly: boolean;
  13368. /**
  13369. * Gets or sets the radius of the emission cone
  13370. */
  13371. get radius(): number;
  13372. set radius(value: number);
  13373. /**
  13374. * Gets or sets the angle of the emission cone
  13375. */
  13376. get angle(): number;
  13377. set angle(value: number);
  13378. private _buildHeight;
  13379. /**
  13380. * Creates a new instance ConeParticleEmitter
  13381. * @param radius the radius of the emission cone (1 by default)
  13382. * @param angle the cone base angle (PI by default)
  13383. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13384. */
  13385. constructor(radius?: number, angle?: number,
  13386. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13387. directionRandomizer?: number);
  13388. /**
  13389. * Called by the particle System when the direction is computed for the created particle.
  13390. * @param worldMatrix is the world matrix of the particle system
  13391. * @param directionToUpdate is the direction vector to update with the result
  13392. * @param particle is the particle we are computed the direction for
  13393. * @param isLocal defines if the direction should be set in local space
  13394. */
  13395. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13396. /**
  13397. * Called by the particle System when the position is computed for the created particle.
  13398. * @param worldMatrix is the world matrix of the particle system
  13399. * @param positionToUpdate is the position vector to update with the result
  13400. * @param particle is the particle we are computed the position for
  13401. * @param isLocal defines if the position should be set in local space
  13402. */
  13403. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13404. /**
  13405. * Clones the current emitter and returns a copy of it
  13406. * @returns the new emitter
  13407. */
  13408. clone(): ConeParticleEmitter;
  13409. /**
  13410. * Called by the GPUParticleSystem to setup the update shader
  13411. * @param effect defines the update shader
  13412. */
  13413. applyToShader(effect: Effect): void;
  13414. /**
  13415. * Returns a string to use to update the GPU particles update shader
  13416. * @returns a string containng the defines string
  13417. */
  13418. getEffectDefines(): string;
  13419. /**
  13420. * Returns the string "ConeParticleEmitter"
  13421. * @returns a string containing the class name
  13422. */
  13423. getClassName(): string;
  13424. /**
  13425. * Serializes the particle system to a JSON object.
  13426. * @returns the JSON object
  13427. */
  13428. serialize(): any;
  13429. /**
  13430. * Parse properties from a JSON object
  13431. * @param serializationObject defines the JSON object
  13432. */
  13433. parse(serializationObject: any): void;
  13434. }
  13435. }
  13436. declare module BABYLON {
  13437. /**
  13438. * Particle emitter emitting particles from the inside of a cylinder.
  13439. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13440. */
  13441. export class CylinderParticleEmitter implements IParticleEmitterType {
  13442. /**
  13443. * The radius of the emission cylinder.
  13444. */
  13445. radius: number;
  13446. /**
  13447. * The height of the emission cylinder.
  13448. */
  13449. height: number;
  13450. /**
  13451. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13452. */
  13453. radiusRange: number;
  13454. /**
  13455. * How much to randomize the particle direction [0-1].
  13456. */
  13457. directionRandomizer: number;
  13458. /**
  13459. * Creates a new instance CylinderParticleEmitter
  13460. * @param radius the radius of the emission cylinder (1 by default)
  13461. * @param height the height of the emission cylinder (1 by default)
  13462. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13463. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13464. */
  13465. constructor(
  13466. /**
  13467. * The radius of the emission cylinder.
  13468. */
  13469. radius?: number,
  13470. /**
  13471. * The height of the emission cylinder.
  13472. */
  13473. height?: number,
  13474. /**
  13475. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13476. */
  13477. radiusRange?: number,
  13478. /**
  13479. * How much to randomize the particle direction [0-1].
  13480. */
  13481. directionRandomizer?: number);
  13482. /**
  13483. * Called by the particle System when the direction is computed for the created particle.
  13484. * @param worldMatrix is the world matrix of the particle system
  13485. * @param directionToUpdate is the direction vector to update with the result
  13486. * @param particle is the particle we are computed the direction for
  13487. * @param isLocal defines if the direction should be set in local space
  13488. */
  13489. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13490. /**
  13491. * Called by the particle System when the position is computed for the created particle.
  13492. * @param worldMatrix is the world matrix of the particle system
  13493. * @param positionToUpdate is the position vector to update with the result
  13494. * @param particle is the particle we are computed the position for
  13495. * @param isLocal defines if the position should be set in local space
  13496. */
  13497. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13498. /**
  13499. * Clones the current emitter and returns a copy of it
  13500. * @returns the new emitter
  13501. */
  13502. clone(): CylinderParticleEmitter;
  13503. /**
  13504. * Called by the GPUParticleSystem to setup the update shader
  13505. * @param effect defines the update shader
  13506. */
  13507. applyToShader(effect: Effect): void;
  13508. /**
  13509. * Returns a string to use to update the GPU particles update shader
  13510. * @returns a string containng the defines string
  13511. */
  13512. getEffectDefines(): string;
  13513. /**
  13514. * Returns the string "CylinderParticleEmitter"
  13515. * @returns a string containing the class name
  13516. */
  13517. getClassName(): string;
  13518. /**
  13519. * Serializes the particle system to a JSON object.
  13520. * @returns the JSON object
  13521. */
  13522. serialize(): any;
  13523. /**
  13524. * Parse properties from a JSON object
  13525. * @param serializationObject defines the JSON object
  13526. */
  13527. parse(serializationObject: any): void;
  13528. }
  13529. /**
  13530. * Particle emitter emitting particles from the inside of a cylinder.
  13531. * It emits the particles randomly between two vectors.
  13532. */
  13533. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13534. /**
  13535. * The min limit of the emission direction.
  13536. */
  13537. direction1: Vector3;
  13538. /**
  13539. * The max limit of the emission direction.
  13540. */
  13541. direction2: Vector3;
  13542. /**
  13543. * Creates a new instance CylinderDirectedParticleEmitter
  13544. * @param radius the radius of the emission cylinder (1 by default)
  13545. * @param height the height of the emission cylinder (1 by default)
  13546. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13547. * @param direction1 the min limit of the emission direction (up vector by default)
  13548. * @param direction2 the max limit of the emission direction (up vector by default)
  13549. */
  13550. constructor(radius?: number, height?: number, radiusRange?: number,
  13551. /**
  13552. * The min limit of the emission direction.
  13553. */
  13554. direction1?: Vector3,
  13555. /**
  13556. * The max limit of the emission direction.
  13557. */
  13558. direction2?: Vector3);
  13559. /**
  13560. * Called by the particle System when the direction is computed for the created particle.
  13561. * @param worldMatrix is the world matrix of the particle system
  13562. * @param directionToUpdate is the direction vector to update with the result
  13563. * @param particle is the particle we are computed the direction for
  13564. */
  13565. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13566. /**
  13567. * Clones the current emitter and returns a copy of it
  13568. * @returns the new emitter
  13569. */
  13570. clone(): CylinderDirectedParticleEmitter;
  13571. /**
  13572. * Called by the GPUParticleSystem to setup the update shader
  13573. * @param effect defines the update shader
  13574. */
  13575. applyToShader(effect: Effect): void;
  13576. /**
  13577. * Returns a string to use to update the GPU particles update shader
  13578. * @returns a string containng the defines string
  13579. */
  13580. getEffectDefines(): string;
  13581. /**
  13582. * Returns the string "CylinderDirectedParticleEmitter"
  13583. * @returns a string containing the class name
  13584. */
  13585. getClassName(): string;
  13586. /**
  13587. * Serializes the particle system to a JSON object.
  13588. * @returns the JSON object
  13589. */
  13590. serialize(): any;
  13591. /**
  13592. * Parse properties from a JSON object
  13593. * @param serializationObject defines the JSON object
  13594. */
  13595. parse(serializationObject: any): void;
  13596. }
  13597. }
  13598. declare module BABYLON {
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a hemisphere.
  13601. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13602. */
  13603. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13604. /**
  13605. * The radius of the emission hemisphere.
  13606. */
  13607. radius: number;
  13608. /**
  13609. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13610. */
  13611. radiusRange: number;
  13612. /**
  13613. * How much to randomize the particle direction [0-1].
  13614. */
  13615. directionRandomizer: number;
  13616. /**
  13617. * Creates a new instance HemisphericParticleEmitter
  13618. * @param radius the radius of the emission hemisphere (1 by default)
  13619. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13620. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13621. */
  13622. constructor(
  13623. /**
  13624. * The radius of the emission hemisphere.
  13625. */
  13626. radius?: number,
  13627. /**
  13628. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13629. */
  13630. radiusRange?: number,
  13631. /**
  13632. * How much to randomize the particle direction [0-1].
  13633. */
  13634. directionRandomizer?: number);
  13635. /**
  13636. * Called by the particle System when the direction is computed for the created particle.
  13637. * @param worldMatrix is the world matrix of the particle system
  13638. * @param directionToUpdate is the direction vector to update with the result
  13639. * @param particle is the particle we are computed the direction for
  13640. * @param isLocal defines if the direction should be set in local space
  13641. */
  13642. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13643. /**
  13644. * Called by the particle System when the position is computed for the created particle.
  13645. * @param worldMatrix is the world matrix of the particle system
  13646. * @param positionToUpdate is the position vector to update with the result
  13647. * @param particle is the particle we are computed the position for
  13648. * @param isLocal defines if the position should be set in local space
  13649. */
  13650. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13651. /**
  13652. * Clones the current emitter and returns a copy of it
  13653. * @returns the new emitter
  13654. */
  13655. clone(): HemisphericParticleEmitter;
  13656. /**
  13657. * Called by the GPUParticleSystem to setup the update shader
  13658. * @param effect defines the update shader
  13659. */
  13660. applyToShader(effect: Effect): void;
  13661. /**
  13662. * Returns a string to use to update the GPU particles update shader
  13663. * @returns a string containng the defines string
  13664. */
  13665. getEffectDefines(): string;
  13666. /**
  13667. * Returns the string "HemisphericParticleEmitter"
  13668. * @returns a string containing the class name
  13669. */
  13670. getClassName(): string;
  13671. /**
  13672. * Serializes the particle system to a JSON object.
  13673. * @returns the JSON object
  13674. */
  13675. serialize(): any;
  13676. /**
  13677. * Parse properties from a JSON object
  13678. * @param serializationObject defines the JSON object
  13679. */
  13680. parse(serializationObject: any): void;
  13681. }
  13682. }
  13683. declare module BABYLON {
  13684. /**
  13685. * Particle emitter emitting particles from a point.
  13686. * It emits the particles randomly between 2 given directions.
  13687. */
  13688. export class PointParticleEmitter implements IParticleEmitterType {
  13689. /**
  13690. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13691. */
  13692. direction1: Vector3;
  13693. /**
  13694. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13695. */
  13696. direction2: Vector3;
  13697. /**
  13698. * Creates a new instance PointParticleEmitter
  13699. */
  13700. constructor();
  13701. /**
  13702. * Called by the particle System when the direction is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param directionToUpdate is the direction vector to update with the result
  13705. * @param particle is the particle we are computed the direction for
  13706. * @param isLocal defines if the direction should be set in local space
  13707. */
  13708. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13709. /**
  13710. * Called by the particle System when the position is computed for the created particle.
  13711. * @param worldMatrix is the world matrix of the particle system
  13712. * @param positionToUpdate is the position vector to update with the result
  13713. * @param particle is the particle we are computed the position for
  13714. * @param isLocal defines if the position should be set in local space
  13715. */
  13716. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13717. /**
  13718. * Clones the current emitter and returns a copy of it
  13719. * @returns the new emitter
  13720. */
  13721. clone(): PointParticleEmitter;
  13722. /**
  13723. * Called by the GPUParticleSystem to setup the update shader
  13724. * @param effect defines the update shader
  13725. */
  13726. applyToShader(effect: Effect): void;
  13727. /**
  13728. * Returns a string to use to update the GPU particles update shader
  13729. * @returns a string containng the defines string
  13730. */
  13731. getEffectDefines(): string;
  13732. /**
  13733. * Returns the string "PointParticleEmitter"
  13734. * @returns a string containing the class name
  13735. */
  13736. getClassName(): string;
  13737. /**
  13738. * Serializes the particle system to a JSON object.
  13739. * @returns the JSON object
  13740. */
  13741. serialize(): any;
  13742. /**
  13743. * Parse properties from a JSON object
  13744. * @param serializationObject defines the JSON object
  13745. */
  13746. parse(serializationObject: any): void;
  13747. }
  13748. }
  13749. declare module BABYLON {
  13750. /**
  13751. * Particle emitter emitting particles from the inside of a sphere.
  13752. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13753. */
  13754. export class SphereParticleEmitter implements IParticleEmitterType {
  13755. /**
  13756. * The radius of the emission sphere.
  13757. */
  13758. radius: number;
  13759. /**
  13760. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13761. */
  13762. radiusRange: number;
  13763. /**
  13764. * How much to randomize the particle direction [0-1].
  13765. */
  13766. directionRandomizer: number;
  13767. /**
  13768. * Creates a new instance SphereParticleEmitter
  13769. * @param radius the radius of the emission sphere (1 by default)
  13770. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13771. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13772. */
  13773. constructor(
  13774. /**
  13775. * The radius of the emission sphere.
  13776. */
  13777. radius?: number,
  13778. /**
  13779. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13780. */
  13781. radiusRange?: number,
  13782. /**
  13783. * How much to randomize the particle direction [0-1].
  13784. */
  13785. directionRandomizer?: number);
  13786. /**
  13787. * Called by the particle System when the direction is computed for the created particle.
  13788. * @param worldMatrix is the world matrix of the particle system
  13789. * @param directionToUpdate is the direction vector to update with the result
  13790. * @param particle is the particle we are computed the direction for
  13791. * @param isLocal defines if the direction should be set in local space
  13792. */
  13793. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13794. /**
  13795. * Called by the particle System when the position is computed for the created particle.
  13796. * @param worldMatrix is the world matrix of the particle system
  13797. * @param positionToUpdate is the position vector to update with the result
  13798. * @param particle is the particle we are computed the position for
  13799. * @param isLocal defines if the position should be set in local space
  13800. */
  13801. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13802. /**
  13803. * Clones the current emitter and returns a copy of it
  13804. * @returns the new emitter
  13805. */
  13806. clone(): SphereParticleEmitter;
  13807. /**
  13808. * Called by the GPUParticleSystem to setup the update shader
  13809. * @param effect defines the update shader
  13810. */
  13811. applyToShader(effect: Effect): void;
  13812. /**
  13813. * Returns a string to use to update the GPU particles update shader
  13814. * @returns a string containng the defines string
  13815. */
  13816. getEffectDefines(): string;
  13817. /**
  13818. * Returns the string "SphereParticleEmitter"
  13819. * @returns a string containing the class name
  13820. */
  13821. getClassName(): string;
  13822. /**
  13823. * Serializes the particle system to a JSON object.
  13824. * @returns the JSON object
  13825. */
  13826. serialize(): any;
  13827. /**
  13828. * Parse properties from a JSON object
  13829. * @param serializationObject defines the JSON object
  13830. */
  13831. parse(serializationObject: any): void;
  13832. }
  13833. /**
  13834. * Particle emitter emitting particles from the inside of a sphere.
  13835. * It emits the particles randomly between two vectors.
  13836. */
  13837. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13838. /**
  13839. * The min limit of the emission direction.
  13840. */
  13841. direction1: Vector3;
  13842. /**
  13843. * The max limit of the emission direction.
  13844. */
  13845. direction2: Vector3;
  13846. /**
  13847. * Creates a new instance SphereDirectedParticleEmitter
  13848. * @param radius the radius of the emission sphere (1 by default)
  13849. * @param direction1 the min limit of the emission direction (up vector by default)
  13850. * @param direction2 the max limit of the emission direction (up vector by default)
  13851. */
  13852. constructor(radius?: number,
  13853. /**
  13854. * The min limit of the emission direction.
  13855. */
  13856. direction1?: Vector3,
  13857. /**
  13858. * The max limit of the emission direction.
  13859. */
  13860. direction2?: Vector3);
  13861. /**
  13862. * Called by the particle System when the direction is computed for the created particle.
  13863. * @param worldMatrix is the world matrix of the particle system
  13864. * @param directionToUpdate is the direction vector to update with the result
  13865. * @param particle is the particle we are computed the direction for
  13866. */
  13867. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13868. /**
  13869. * Clones the current emitter and returns a copy of it
  13870. * @returns the new emitter
  13871. */
  13872. clone(): SphereDirectedParticleEmitter;
  13873. /**
  13874. * Called by the GPUParticleSystem to setup the update shader
  13875. * @param effect defines the update shader
  13876. */
  13877. applyToShader(effect: Effect): void;
  13878. /**
  13879. * Returns a string to use to update the GPU particles update shader
  13880. * @returns a string containng the defines string
  13881. */
  13882. getEffectDefines(): string;
  13883. /**
  13884. * Returns the string "SphereDirectedParticleEmitter"
  13885. * @returns a string containing the class name
  13886. */
  13887. getClassName(): string;
  13888. /**
  13889. * Serializes the particle system to a JSON object.
  13890. * @returns the JSON object
  13891. */
  13892. serialize(): any;
  13893. /**
  13894. * Parse properties from a JSON object
  13895. * @param serializationObject defines the JSON object
  13896. */
  13897. parse(serializationObject: any): void;
  13898. }
  13899. }
  13900. declare module BABYLON {
  13901. /**
  13902. * Particle emitter emitting particles from a custom list of positions.
  13903. */
  13904. export class CustomParticleEmitter implements IParticleEmitterType {
  13905. /**
  13906. * Gets or sets the position generator that will create the inital position of each particle.
  13907. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13908. */
  13909. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13910. /**
  13911. * Gets or sets the destination generator that will create the final destination of each particle.
  13912. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13913. */
  13914. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13915. /**
  13916. * Creates a new instance CustomParticleEmitter
  13917. */
  13918. constructor();
  13919. /**
  13920. * Called by the particle System when the direction is computed for the created particle.
  13921. * @param worldMatrix is the world matrix of the particle system
  13922. * @param directionToUpdate is the direction vector to update with the result
  13923. * @param particle is the particle we are computed the direction for
  13924. * @param isLocal defines if the direction should be set in local space
  13925. */
  13926. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13927. /**
  13928. * Called by the particle System when the position is computed for the created particle.
  13929. * @param worldMatrix is the world matrix of the particle system
  13930. * @param positionToUpdate is the position vector to update with the result
  13931. * @param particle is the particle we are computed the position for
  13932. * @param isLocal defines if the position should be set in local space
  13933. */
  13934. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13935. /**
  13936. * Clones the current emitter and returns a copy of it
  13937. * @returns the new emitter
  13938. */
  13939. clone(): CustomParticleEmitter;
  13940. /**
  13941. * Called by the GPUParticleSystem to setup the update shader
  13942. * @param effect defines the update shader
  13943. */
  13944. applyToShader(effect: Effect): void;
  13945. /**
  13946. * Returns a string to use to update the GPU particles update shader
  13947. * @returns a string containng the defines string
  13948. */
  13949. getEffectDefines(): string;
  13950. /**
  13951. * Returns the string "PointParticleEmitter"
  13952. * @returns a string containing the class name
  13953. */
  13954. getClassName(): string;
  13955. /**
  13956. * Serializes the particle system to a JSON object.
  13957. * @returns the JSON object
  13958. */
  13959. serialize(): any;
  13960. /**
  13961. * Parse properties from a JSON object
  13962. * @param serializationObject defines the JSON object
  13963. */
  13964. parse(serializationObject: any): void;
  13965. }
  13966. }
  13967. declare module BABYLON {
  13968. /**
  13969. * Particle emitter emitting particles from the inside of a box.
  13970. * It emits the particles randomly between 2 given directions.
  13971. */
  13972. export class MeshParticleEmitter implements IParticleEmitterType {
  13973. private _indices;
  13974. private _positions;
  13975. private _normals;
  13976. private _storedNormal;
  13977. private _mesh;
  13978. /**
  13979. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13980. */
  13981. direction1: Vector3;
  13982. /**
  13983. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13984. */
  13985. direction2: Vector3;
  13986. /**
  13987. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13988. */
  13989. useMeshNormalsForDirection: boolean;
  13990. /** Defines the mesh to use as source */
  13991. get mesh(): Nullable<AbstractMesh>;
  13992. set mesh(value: Nullable<AbstractMesh>);
  13993. /**
  13994. * Creates a new instance MeshParticleEmitter
  13995. * @param mesh defines the mesh to use as source
  13996. */
  13997. constructor(mesh?: Nullable<AbstractMesh>);
  13998. /**
  13999. * Called by the particle System when the direction is computed for the created particle.
  14000. * @param worldMatrix is the world matrix of the particle system
  14001. * @param directionToUpdate is the direction vector to update with the result
  14002. * @param particle is the particle we are computed the direction for
  14003. * @param isLocal defines if the direction should be set in local space
  14004. */
  14005. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14006. /**
  14007. * Called by the particle System when the position is computed for the created particle.
  14008. * @param worldMatrix is the world matrix of the particle system
  14009. * @param positionToUpdate is the position vector to update with the result
  14010. * @param particle is the particle we are computed the position for
  14011. * @param isLocal defines if the position should be set in local space
  14012. */
  14013. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14014. /**
  14015. * Clones the current emitter and returns a copy of it
  14016. * @returns the new emitter
  14017. */
  14018. clone(): MeshParticleEmitter;
  14019. /**
  14020. * Called by the GPUParticleSystem to setup the update shader
  14021. * @param effect defines the update shader
  14022. */
  14023. applyToShader(effect: Effect): void;
  14024. /**
  14025. * Returns a string to use to update the GPU particles update shader
  14026. * @returns a string containng the defines string
  14027. */
  14028. getEffectDefines(): string;
  14029. /**
  14030. * Returns the string "BoxParticleEmitter"
  14031. * @returns a string containing the class name
  14032. */
  14033. getClassName(): string;
  14034. /**
  14035. * Serializes the particle system to a JSON object.
  14036. * @returns the JSON object
  14037. */
  14038. serialize(): any;
  14039. /**
  14040. * Parse properties from a JSON object
  14041. * @param serializationObject defines the JSON object
  14042. * @param scene defines the hosting scene
  14043. */
  14044. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14045. }
  14046. }
  14047. declare module BABYLON {
  14048. /**
  14049. * Interface representing a particle system in Babylon.js.
  14050. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14051. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14052. */
  14053. export interface IParticleSystem {
  14054. /**
  14055. * List of animations used by the particle system.
  14056. */
  14057. animations: Animation[];
  14058. /**
  14059. * The id of the Particle system.
  14060. */
  14061. id: string;
  14062. /**
  14063. * The name of the Particle system.
  14064. */
  14065. name: string;
  14066. /**
  14067. * The emitter represents the Mesh or position we are attaching the particle system to.
  14068. */
  14069. emitter: Nullable<AbstractMesh | Vector3>;
  14070. /**
  14071. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14072. */
  14073. isBillboardBased: boolean;
  14074. /**
  14075. * The rendering group used by the Particle system to chose when to render.
  14076. */
  14077. renderingGroupId: number;
  14078. /**
  14079. * The layer mask we are rendering the particles through.
  14080. */
  14081. layerMask: number;
  14082. /**
  14083. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14084. */
  14085. updateSpeed: number;
  14086. /**
  14087. * The amount of time the particle system is running (depends of the overall update speed).
  14088. */
  14089. targetStopDuration: number;
  14090. /**
  14091. * The texture used to render each particle. (this can be a spritesheet)
  14092. */
  14093. particleTexture: Nullable<BaseTexture>;
  14094. /**
  14095. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14096. */
  14097. blendMode: number;
  14098. /**
  14099. * Minimum life time of emitting particles.
  14100. */
  14101. minLifeTime: number;
  14102. /**
  14103. * Maximum life time of emitting particles.
  14104. */
  14105. maxLifeTime: number;
  14106. /**
  14107. * Minimum Size of emitting particles.
  14108. */
  14109. minSize: number;
  14110. /**
  14111. * Maximum Size of emitting particles.
  14112. */
  14113. maxSize: number;
  14114. /**
  14115. * Minimum scale of emitting particles on X axis.
  14116. */
  14117. minScaleX: number;
  14118. /**
  14119. * Maximum scale of emitting particles on X axis.
  14120. */
  14121. maxScaleX: number;
  14122. /**
  14123. * Minimum scale of emitting particles on Y axis.
  14124. */
  14125. minScaleY: number;
  14126. /**
  14127. * Maximum scale of emitting particles on Y axis.
  14128. */
  14129. maxScaleY: number;
  14130. /**
  14131. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14132. */
  14133. color1: Color4;
  14134. /**
  14135. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14136. */
  14137. color2: Color4;
  14138. /**
  14139. * Color the particle will have at the end of its lifetime.
  14140. */
  14141. colorDead: Color4;
  14142. /**
  14143. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14144. */
  14145. emitRate: number;
  14146. /**
  14147. * You can use gravity if you want to give an orientation to your particles.
  14148. */
  14149. gravity: Vector3;
  14150. /**
  14151. * Minimum power of emitting particles.
  14152. */
  14153. minEmitPower: number;
  14154. /**
  14155. * Maximum power of emitting particles.
  14156. */
  14157. maxEmitPower: number;
  14158. /**
  14159. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14160. */
  14161. minAngularSpeed: number;
  14162. /**
  14163. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14164. */
  14165. maxAngularSpeed: number;
  14166. /**
  14167. * Gets or sets the minimal initial rotation in radians.
  14168. */
  14169. minInitialRotation: number;
  14170. /**
  14171. * Gets or sets the maximal initial rotation in radians.
  14172. */
  14173. maxInitialRotation: number;
  14174. /**
  14175. * The particle emitter type defines the emitter used by the particle system.
  14176. * It can be for example box, sphere, or cone...
  14177. */
  14178. particleEmitterType: Nullable<IParticleEmitterType>;
  14179. /**
  14180. * Defines the delay in milliseconds before starting the system (0 by default)
  14181. */
  14182. startDelay: number;
  14183. /**
  14184. * 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
  14185. */
  14186. preWarmCycles: number;
  14187. /**
  14188. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14189. */
  14190. preWarmStepOffset: number;
  14191. /**
  14192. * 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)
  14193. */
  14194. spriteCellChangeSpeed: number;
  14195. /**
  14196. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14197. */
  14198. startSpriteCellID: number;
  14199. /**
  14200. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14201. */
  14202. endSpriteCellID: number;
  14203. /**
  14204. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14205. */
  14206. spriteCellWidth: number;
  14207. /**
  14208. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14209. */
  14210. spriteCellHeight: number;
  14211. /**
  14212. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14213. */
  14214. spriteRandomStartCell: boolean;
  14215. /**
  14216. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14217. */
  14218. isAnimationSheetEnabled: boolean;
  14219. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14220. translationPivot: Vector2;
  14221. /**
  14222. * Gets or sets a texture used to add random noise to particle positions
  14223. */
  14224. noiseTexture: Nullable<BaseTexture>;
  14225. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14226. noiseStrength: Vector3;
  14227. /**
  14228. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14229. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14230. */
  14231. billboardMode: number;
  14232. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14233. limitVelocityDamping: number;
  14234. /**
  14235. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14236. */
  14237. beginAnimationOnStart: boolean;
  14238. /**
  14239. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14240. */
  14241. beginAnimationFrom: number;
  14242. /**
  14243. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14244. */
  14245. beginAnimationTo: number;
  14246. /**
  14247. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14248. */
  14249. beginAnimationLoop: boolean;
  14250. /**
  14251. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14252. */
  14253. disposeOnStop: boolean;
  14254. /**
  14255. * Specifies if the particles are updated in emitter local space or world space
  14256. */
  14257. isLocal: boolean;
  14258. /** Snippet ID if the particle system was created from the snippet server */
  14259. snippetId: string;
  14260. /** Gets or sets a matrix to use to compute projection */
  14261. defaultProjectionMatrix: Matrix;
  14262. /**
  14263. * Gets the maximum number of particles active at the same time.
  14264. * @returns The max number of active particles.
  14265. */
  14266. getCapacity(): number;
  14267. /**
  14268. * Gets the number of particles active at the same time.
  14269. * @returns The number of active particles.
  14270. */
  14271. getActiveCount(): number;
  14272. /**
  14273. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14274. * @returns True if it has been started, otherwise false.
  14275. */
  14276. isStarted(): boolean;
  14277. /**
  14278. * Animates the particle system for this frame.
  14279. */
  14280. animate(): void;
  14281. /**
  14282. * Renders the particle system in its current state.
  14283. * @returns the current number of particles
  14284. */
  14285. render(): number;
  14286. /**
  14287. * Dispose the particle system and frees its associated resources.
  14288. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14289. */
  14290. dispose(disposeTexture?: boolean): void;
  14291. /**
  14292. * An event triggered when the system is disposed
  14293. */
  14294. onDisposeObservable: Observable<IParticleSystem>;
  14295. /**
  14296. * Clones the particle system.
  14297. * @param name The name of the cloned object
  14298. * @param newEmitter The new emitter to use
  14299. * @returns the cloned particle system
  14300. */
  14301. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14302. /**
  14303. * Serializes the particle system to a JSON object
  14304. * @param serializeTexture defines if the texture must be serialized as well
  14305. * @returns the JSON object
  14306. */
  14307. serialize(serializeTexture: boolean): any;
  14308. /**
  14309. * Rebuild the particle system
  14310. */
  14311. rebuild(): void;
  14312. /** Force the system to rebuild all gradients that need to be resync */
  14313. forceRefreshGradients(): void;
  14314. /**
  14315. * Starts the particle system and begins to emit
  14316. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14317. */
  14318. start(delay?: number): void;
  14319. /**
  14320. * Stops the particle system.
  14321. */
  14322. stop(): void;
  14323. /**
  14324. * Remove all active particles
  14325. */
  14326. reset(): void;
  14327. /**
  14328. * Gets a boolean indicating that the system is stopping
  14329. * @returns true if the system is currently stopping
  14330. */
  14331. isStopping(): boolean;
  14332. /**
  14333. * Is this system ready to be used/rendered
  14334. * @return true if the system is ready
  14335. */
  14336. isReady(): boolean;
  14337. /**
  14338. * Returns the string "ParticleSystem"
  14339. * @returns a string containing the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Gets the custom effect used to render the particles
  14344. * @param blendMode Blend mode for which the effect should be retrieved
  14345. * @returns The effect
  14346. */
  14347. getCustomEffect(blendMode: number): Nullable<Effect>;
  14348. /**
  14349. * Sets the custom effect used to render the particles
  14350. * @param effect The effect to set
  14351. * @param blendMode Blend mode for which the effect should be set
  14352. */
  14353. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14354. /**
  14355. * Fill the defines array according to the current settings of the particle system
  14356. * @param defines Array to be updated
  14357. * @param blendMode blend mode to take into account when updating the array
  14358. */
  14359. fillDefines(defines: Array<string>, blendMode: number): void;
  14360. /**
  14361. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14362. * @param uniforms Uniforms array to fill
  14363. * @param attributes Attributes array to fill
  14364. * @param samplers Samplers array to fill
  14365. */
  14366. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14367. /**
  14368. * Observable that will be called just before the particles are drawn
  14369. */
  14370. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14371. /**
  14372. * Gets the name of the particle vertex shader
  14373. */
  14374. vertexShaderName: string;
  14375. /**
  14376. * Adds a new color gradient
  14377. * @param gradient defines the gradient to use (between 0 and 1)
  14378. * @param color1 defines the color to affect to the specified gradient
  14379. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14380. * @returns the current particle system
  14381. */
  14382. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14383. /**
  14384. * Remove a specific color gradient
  14385. * @param gradient defines the gradient to remove
  14386. * @returns the current particle system
  14387. */
  14388. removeColorGradient(gradient: number): IParticleSystem;
  14389. /**
  14390. * Adds a new size gradient
  14391. * @param gradient defines the gradient to use (between 0 and 1)
  14392. * @param factor defines the size factor to affect to the specified gradient
  14393. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14394. * @returns the current particle system
  14395. */
  14396. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14397. /**
  14398. * Remove a specific size gradient
  14399. * @param gradient defines the gradient to remove
  14400. * @returns the current particle system
  14401. */
  14402. removeSizeGradient(gradient: number): IParticleSystem;
  14403. /**
  14404. * Gets the current list of color gradients.
  14405. * You must use addColorGradient and removeColorGradient to udpate this list
  14406. * @returns the list of color gradients
  14407. */
  14408. getColorGradients(): Nullable<Array<ColorGradient>>;
  14409. /**
  14410. * Gets the current list of size gradients.
  14411. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14412. * @returns the list of size gradients
  14413. */
  14414. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14415. /**
  14416. * Gets the current list of angular speed gradients.
  14417. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14418. * @returns the list of angular speed gradients
  14419. */
  14420. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14421. /**
  14422. * Adds a new angular speed gradient
  14423. * @param gradient defines the gradient to use (between 0 and 1)
  14424. * @param factor defines the angular speed to affect to the specified gradient
  14425. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14426. * @returns the current particle system
  14427. */
  14428. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14429. /**
  14430. * Remove a specific angular speed gradient
  14431. * @param gradient defines the gradient to remove
  14432. * @returns the current particle system
  14433. */
  14434. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14435. /**
  14436. * Gets the current list of velocity gradients.
  14437. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14438. * @returns the list of velocity gradients
  14439. */
  14440. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14441. /**
  14442. * Adds a new velocity gradient
  14443. * @param gradient defines the gradient to use (between 0 and 1)
  14444. * @param factor defines the velocity to affect to the specified gradient
  14445. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14446. * @returns the current particle system
  14447. */
  14448. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14449. /**
  14450. * Remove a specific velocity gradient
  14451. * @param gradient defines the gradient to remove
  14452. * @returns the current particle system
  14453. */
  14454. removeVelocityGradient(gradient: number): IParticleSystem;
  14455. /**
  14456. * Gets the current list of limit velocity gradients.
  14457. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14458. * @returns the list of limit velocity gradients
  14459. */
  14460. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14461. /**
  14462. * Adds a new limit velocity gradient
  14463. * @param gradient defines the gradient to use (between 0 and 1)
  14464. * @param factor defines the limit velocity to affect to the specified gradient
  14465. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14466. * @returns the current particle system
  14467. */
  14468. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14469. /**
  14470. * Remove a specific limit velocity gradient
  14471. * @param gradient defines the gradient to remove
  14472. * @returns the current particle system
  14473. */
  14474. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14475. /**
  14476. * Adds a new drag gradient
  14477. * @param gradient defines the gradient to use (between 0 and 1)
  14478. * @param factor defines the drag to affect to the specified gradient
  14479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14480. * @returns the current particle system
  14481. */
  14482. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14483. /**
  14484. * Remove a specific drag gradient
  14485. * @param gradient defines the gradient to remove
  14486. * @returns the current particle system
  14487. */
  14488. removeDragGradient(gradient: number): IParticleSystem;
  14489. /**
  14490. * Gets the current list of drag gradients.
  14491. * You must use addDragGradient and removeDragGradient to udpate this list
  14492. * @returns the list of drag gradients
  14493. */
  14494. getDragGradients(): Nullable<Array<FactorGradient>>;
  14495. /**
  14496. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14497. * @param gradient defines the gradient to use (between 0 and 1)
  14498. * @param factor defines the emit rate to affect to the specified gradient
  14499. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14500. * @returns the current particle system
  14501. */
  14502. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14503. /**
  14504. * Remove a specific emit rate gradient
  14505. * @param gradient defines the gradient to remove
  14506. * @returns the current particle system
  14507. */
  14508. removeEmitRateGradient(gradient: number): IParticleSystem;
  14509. /**
  14510. * Gets the current list of emit rate gradients.
  14511. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14512. * @returns the list of emit rate gradients
  14513. */
  14514. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14515. /**
  14516. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14517. * @param gradient defines the gradient to use (between 0 and 1)
  14518. * @param factor defines the start size to affect to the specified gradient
  14519. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14520. * @returns the current particle system
  14521. */
  14522. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14523. /**
  14524. * Remove a specific start size gradient
  14525. * @param gradient defines the gradient to remove
  14526. * @returns the current particle system
  14527. */
  14528. removeStartSizeGradient(gradient: number): IParticleSystem;
  14529. /**
  14530. * Gets the current list of start size gradients.
  14531. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14532. * @returns the list of start size gradients
  14533. */
  14534. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14535. /**
  14536. * Adds a new life time gradient
  14537. * @param gradient defines the gradient to use (between 0 and 1)
  14538. * @param factor defines the life time factor to affect to the specified gradient
  14539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14540. * @returns the current particle system
  14541. */
  14542. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14543. /**
  14544. * Remove a specific life time gradient
  14545. * @param gradient defines the gradient to remove
  14546. * @returns the current particle system
  14547. */
  14548. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14549. /**
  14550. * Gets the current list of life time gradients.
  14551. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14552. * @returns the list of life time gradients
  14553. */
  14554. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14555. /**
  14556. * Gets the current list of color gradients.
  14557. * You must use addColorGradient and removeColorGradient to udpate this list
  14558. * @returns the list of color gradients
  14559. */
  14560. getColorGradients(): Nullable<Array<ColorGradient>>;
  14561. /**
  14562. * Adds a new ramp gradient used to remap particle colors
  14563. * @param gradient defines the gradient to use (between 0 and 1)
  14564. * @param color defines the color to affect to the specified gradient
  14565. * @returns the current particle system
  14566. */
  14567. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14568. /**
  14569. * Gets the current list of ramp gradients.
  14570. * You must use addRampGradient and removeRampGradient to udpate this list
  14571. * @returns the list of ramp gradients
  14572. */
  14573. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14574. /** Gets or sets a boolean indicating that ramp gradients must be used
  14575. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14576. */
  14577. useRampGradients: boolean;
  14578. /**
  14579. * Adds a new color remap gradient
  14580. * @param gradient defines the gradient to use (between 0 and 1)
  14581. * @param min defines the color remap minimal range
  14582. * @param max defines the color remap maximal range
  14583. * @returns the current particle system
  14584. */
  14585. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14586. /**
  14587. * Gets the current list of color remap gradients.
  14588. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14589. * @returns the list of color remap gradients
  14590. */
  14591. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14592. /**
  14593. * Adds a new alpha remap gradient
  14594. * @param gradient defines the gradient to use (between 0 and 1)
  14595. * @param min defines the alpha remap minimal range
  14596. * @param max defines the alpha remap maximal range
  14597. * @returns the current particle system
  14598. */
  14599. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14600. /**
  14601. * Gets the current list of alpha remap gradients.
  14602. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14603. * @returns the list of alpha remap gradients
  14604. */
  14605. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14606. /**
  14607. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14610. * @returns the emitter
  14611. */
  14612. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14613. /**
  14614. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14615. * @param radius The radius of the hemisphere to emit from
  14616. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14617. * @returns the emitter
  14618. */
  14619. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14620. /**
  14621. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14622. * @param radius The radius of the sphere to emit from
  14623. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14624. * @returns the emitter
  14625. */
  14626. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14627. /**
  14628. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14629. * @param radius The radius of the sphere to emit from
  14630. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14631. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14632. * @returns the emitter
  14633. */
  14634. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14635. /**
  14636. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14637. * @param radius The radius of the emission cylinder
  14638. * @param height The height of the emission cylinder
  14639. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14640. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14641. * @returns the emitter
  14642. */
  14643. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14644. /**
  14645. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14646. * @param radius The radius of the cylinder to emit from
  14647. * @param height The height of the emission cylinder
  14648. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14649. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14650. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14651. * @returns the emitter
  14652. */
  14653. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14654. /**
  14655. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14656. * @param radius The radius of the cone to emit from
  14657. * @param angle The base angle of the cone
  14658. * @returns the emitter
  14659. */
  14660. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14661. /**
  14662. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14663. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14664. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14665. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14666. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14667. * @returns the emitter
  14668. */
  14669. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14670. /**
  14671. * Get hosting scene
  14672. * @returns the scene
  14673. */
  14674. getScene(): Nullable<Scene>;
  14675. }
  14676. }
  14677. declare module BABYLON {
  14678. /**
  14679. * 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.
  14680. * @see https://doc.babylonjs.com/how_to/transformnode
  14681. */
  14682. export class TransformNode extends Node {
  14683. /**
  14684. * Object will not rotate to face the camera
  14685. */
  14686. static BILLBOARDMODE_NONE: number;
  14687. /**
  14688. * Object will rotate to face the camera but only on the x axis
  14689. */
  14690. static BILLBOARDMODE_X: number;
  14691. /**
  14692. * Object will rotate to face the camera but only on the y axis
  14693. */
  14694. static BILLBOARDMODE_Y: number;
  14695. /**
  14696. * Object will rotate to face the camera but only on the z axis
  14697. */
  14698. static BILLBOARDMODE_Z: number;
  14699. /**
  14700. * Object will rotate to face the camera
  14701. */
  14702. static BILLBOARDMODE_ALL: number;
  14703. /**
  14704. * Object will rotate to face the camera's position instead of orientation
  14705. */
  14706. static BILLBOARDMODE_USE_POSITION: number;
  14707. private static _TmpRotation;
  14708. private static _TmpScaling;
  14709. private static _TmpTranslation;
  14710. private _forward;
  14711. private _forwardInverted;
  14712. private _up;
  14713. private _right;
  14714. private _rightInverted;
  14715. private _position;
  14716. private _rotation;
  14717. private _rotationQuaternion;
  14718. protected _scaling: Vector3;
  14719. protected _isDirty: boolean;
  14720. private _transformToBoneReferal;
  14721. private _isAbsoluteSynced;
  14722. private _billboardMode;
  14723. /**
  14724. * Gets or sets the billboard mode. Default is 0.
  14725. *
  14726. * | Value | Type | Description |
  14727. * | --- | --- | --- |
  14728. * | 0 | BILLBOARDMODE_NONE | |
  14729. * | 1 | BILLBOARDMODE_X | |
  14730. * | 2 | BILLBOARDMODE_Y | |
  14731. * | 4 | BILLBOARDMODE_Z | |
  14732. * | 7 | BILLBOARDMODE_ALL | |
  14733. *
  14734. */
  14735. get billboardMode(): number;
  14736. set billboardMode(value: number);
  14737. private _preserveParentRotationForBillboard;
  14738. /**
  14739. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14740. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14741. */
  14742. get preserveParentRotationForBillboard(): boolean;
  14743. set preserveParentRotationForBillboard(value: boolean);
  14744. /**
  14745. * 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
  14746. */
  14747. scalingDeterminant: number;
  14748. private _infiniteDistance;
  14749. /**
  14750. * Gets or sets the distance of the object to max, often used by skybox
  14751. */
  14752. get infiniteDistance(): boolean;
  14753. set infiniteDistance(value: boolean);
  14754. /**
  14755. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14756. * By default the system will update normals to compensate
  14757. */
  14758. ignoreNonUniformScaling: boolean;
  14759. /**
  14760. * 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
  14761. */
  14762. reIntegrateRotationIntoRotationQuaternion: boolean;
  14763. /** @hidden */
  14764. _poseMatrix: Nullable<Matrix>;
  14765. /** @hidden */
  14766. _localMatrix: Matrix;
  14767. private _usePivotMatrix;
  14768. private _absolutePosition;
  14769. private _absoluteScaling;
  14770. private _absoluteRotationQuaternion;
  14771. private _pivotMatrix;
  14772. private _pivotMatrixInverse;
  14773. /** @hidden */
  14774. _postMultiplyPivotMatrix: boolean;
  14775. protected _isWorldMatrixFrozen: boolean;
  14776. /** @hidden */
  14777. _indexInSceneTransformNodesArray: number;
  14778. /**
  14779. * An event triggered after the world matrix is updated
  14780. */
  14781. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14782. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14783. /**
  14784. * Gets a string identifying the name of the class
  14785. * @returns "TransformNode" string
  14786. */
  14787. getClassName(): string;
  14788. /**
  14789. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14790. */
  14791. get position(): Vector3;
  14792. set position(newPosition: Vector3);
  14793. /**
  14794. * 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)).
  14795. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14796. */
  14797. get rotation(): Vector3;
  14798. set rotation(newRotation: Vector3);
  14799. /**
  14800. * 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)).
  14801. */
  14802. get scaling(): Vector3;
  14803. set scaling(newScaling: Vector3);
  14804. /**
  14805. * 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).
  14806. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14807. */
  14808. get rotationQuaternion(): Nullable<Quaternion>;
  14809. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14810. /**
  14811. * The forward direction of that transform in world space.
  14812. */
  14813. get forward(): Vector3;
  14814. /**
  14815. * The up direction of that transform in world space.
  14816. */
  14817. get up(): Vector3;
  14818. /**
  14819. * The right direction of that transform in world space.
  14820. */
  14821. get right(): Vector3;
  14822. /**
  14823. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14824. * @param matrix the matrix to copy the pose from
  14825. * @returns this TransformNode.
  14826. */
  14827. updatePoseMatrix(matrix: Matrix): TransformNode;
  14828. /**
  14829. * Returns the mesh Pose matrix.
  14830. * @returns the pose matrix
  14831. */
  14832. getPoseMatrix(): Matrix;
  14833. /** @hidden */
  14834. _isSynchronized(): boolean;
  14835. /** @hidden */
  14836. _initCache(): void;
  14837. /**
  14838. * Flag the transform node as dirty (Forcing it to update everything)
  14839. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14840. * @returns this transform node
  14841. */
  14842. markAsDirty(property: string): TransformNode;
  14843. /**
  14844. * Returns the current mesh absolute position.
  14845. * Returns a Vector3.
  14846. */
  14847. get absolutePosition(): Vector3;
  14848. /**
  14849. * Returns the current mesh absolute scaling.
  14850. * Returns a Vector3.
  14851. */
  14852. get absoluteScaling(): Vector3;
  14853. /**
  14854. * Returns the current mesh absolute rotation.
  14855. * Returns a Quaternion.
  14856. */
  14857. get absoluteRotationQuaternion(): Quaternion;
  14858. /**
  14859. * Sets a new matrix to apply before all other transformation
  14860. * @param matrix defines the transform matrix
  14861. * @returns the current TransformNode
  14862. */
  14863. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14864. /**
  14865. * Sets a new pivot matrix to the current node
  14866. * @param matrix defines the new pivot matrix to use
  14867. * @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
  14868. * @returns the current TransformNode
  14869. */
  14870. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14871. /**
  14872. * Returns the mesh pivot matrix.
  14873. * Default : Identity.
  14874. * @returns the matrix
  14875. */
  14876. getPivotMatrix(): Matrix;
  14877. /**
  14878. * Instantiate (when possible) or clone that node with its hierarchy
  14879. * @param newParent defines the new parent to use for the instance (or clone)
  14880. * @param options defines options to configure how copy is done
  14881. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14882. * @returns an instance (or a clone) of the current node with its hiearchy
  14883. */
  14884. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14885. doNotInstantiate: boolean;
  14886. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14887. /**
  14888. * Prevents the World matrix to be computed any longer
  14889. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14890. * @returns the TransformNode.
  14891. */
  14892. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14893. /**
  14894. * Allows back the World matrix computation.
  14895. * @returns the TransformNode.
  14896. */
  14897. unfreezeWorldMatrix(): this;
  14898. /**
  14899. * True if the World matrix has been frozen.
  14900. */
  14901. get isWorldMatrixFrozen(): boolean;
  14902. /**
  14903. * Retuns the mesh absolute position in the World.
  14904. * @returns a Vector3.
  14905. */
  14906. getAbsolutePosition(): Vector3;
  14907. /**
  14908. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14909. * @param absolutePosition the absolute position to set
  14910. * @returns the TransformNode.
  14911. */
  14912. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14913. /**
  14914. * Sets the mesh position in its local space.
  14915. * @param vector3 the position to set in localspace
  14916. * @returns the TransformNode.
  14917. */
  14918. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14919. /**
  14920. * Returns the mesh position in the local space from the current World matrix values.
  14921. * @returns a new Vector3.
  14922. */
  14923. getPositionExpressedInLocalSpace(): Vector3;
  14924. /**
  14925. * Translates the mesh along the passed Vector3 in its local space.
  14926. * @param vector3 the distance to translate in localspace
  14927. * @returns the TransformNode.
  14928. */
  14929. locallyTranslate(vector3: Vector3): TransformNode;
  14930. private static _lookAtVectorCache;
  14931. /**
  14932. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14933. * @param targetPoint the position (must be in same space as current mesh) to look at
  14934. * @param yawCor optional yaw (y-axis) correction in radians
  14935. * @param pitchCor optional pitch (x-axis) correction in radians
  14936. * @param rollCor optional roll (z-axis) correction in radians
  14937. * @param space the choosen space of the target
  14938. * @returns the TransformNode.
  14939. */
  14940. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14941. /**
  14942. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14943. * This Vector3 is expressed in the World space.
  14944. * @param localAxis axis to rotate
  14945. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14946. */
  14947. getDirection(localAxis: Vector3): Vector3;
  14948. /**
  14949. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14950. * localAxis is expressed in the mesh local space.
  14951. * result is computed in the Wordl space from the mesh World matrix.
  14952. * @param localAxis axis to rotate
  14953. * @param result the resulting transformnode
  14954. * @returns this TransformNode.
  14955. */
  14956. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14957. /**
  14958. * Sets this transform node rotation to the given local axis.
  14959. * @param localAxis the axis in local space
  14960. * @param yawCor optional yaw (y-axis) correction in radians
  14961. * @param pitchCor optional pitch (x-axis) correction in radians
  14962. * @param rollCor optional roll (z-axis) correction in radians
  14963. * @returns this TransformNode
  14964. */
  14965. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14966. /**
  14967. * Sets a new pivot point to the current node
  14968. * @param point defines the new pivot point to use
  14969. * @param space defines if the point is in world or local space (local by default)
  14970. * @returns the current TransformNode
  14971. */
  14972. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14973. /**
  14974. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14975. * @returns the pivot point
  14976. */
  14977. getPivotPoint(): Vector3;
  14978. /**
  14979. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14980. * @param result the vector3 to store the result
  14981. * @returns this TransformNode.
  14982. */
  14983. getPivotPointToRef(result: Vector3): TransformNode;
  14984. /**
  14985. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14986. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14987. */
  14988. getAbsolutePivotPoint(): Vector3;
  14989. /**
  14990. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14991. * @param result vector3 to store the result
  14992. * @returns this TransformNode.
  14993. */
  14994. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14995. /**
  14996. * Defines the passed node as the parent of the current node.
  14997. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14998. * @see https://doc.babylonjs.com/how_to/parenting
  14999. * @param node the node ot set as the parent
  15000. * @returns this TransformNode.
  15001. */
  15002. setParent(node: Nullable<Node>): TransformNode;
  15003. private _nonUniformScaling;
  15004. /**
  15005. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15006. */
  15007. get nonUniformScaling(): boolean;
  15008. /** @hidden */
  15009. _updateNonUniformScalingState(value: boolean): boolean;
  15010. /**
  15011. * Attach the current TransformNode to another TransformNode associated with a bone
  15012. * @param bone Bone affecting the TransformNode
  15013. * @param affectedTransformNode TransformNode associated with the bone
  15014. * @returns this object
  15015. */
  15016. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15017. /**
  15018. * Detach the transform node if its associated with a bone
  15019. * @returns this object
  15020. */
  15021. detachFromBone(): TransformNode;
  15022. private static _rotationAxisCache;
  15023. /**
  15024. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15025. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15026. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15027. * The passed axis is also normalized.
  15028. * @param axis the axis to rotate around
  15029. * @param amount the amount to rotate in radians
  15030. * @param space Space to rotate in (Default: local)
  15031. * @returns the TransformNode.
  15032. */
  15033. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15034. /**
  15035. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15036. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15037. * The passed axis is also normalized. .
  15038. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15039. * @param point the point to rotate around
  15040. * @param axis the axis to rotate around
  15041. * @param amount the amount to rotate in radians
  15042. * @returns the TransformNode
  15043. */
  15044. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15045. /**
  15046. * Translates the mesh along the axis vector for the passed distance in the given space.
  15047. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15048. * @param axis the axis to translate in
  15049. * @param distance the distance to translate
  15050. * @param space Space to rotate in (Default: local)
  15051. * @returns the TransformNode.
  15052. */
  15053. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15054. /**
  15055. * Adds a rotation step to the mesh current rotation.
  15056. * x, y, z are Euler angles expressed in radians.
  15057. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15058. * This means this rotation is made in the mesh local space only.
  15059. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15060. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15061. * ```javascript
  15062. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15063. * ```
  15064. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15065. * 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.
  15066. * @param x Rotation to add
  15067. * @param y Rotation to add
  15068. * @param z Rotation to add
  15069. * @returns the TransformNode.
  15070. */
  15071. addRotation(x: number, y: number, z: number): TransformNode;
  15072. /**
  15073. * @hidden
  15074. */
  15075. protected _getEffectiveParent(): Nullable<Node>;
  15076. /**
  15077. * Computes the world matrix of the node
  15078. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15079. * @returns the world matrix
  15080. */
  15081. computeWorldMatrix(force?: boolean): Matrix;
  15082. /**
  15083. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15084. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15085. */
  15086. resetLocalMatrix(independentOfChildren?: boolean): void;
  15087. protected _afterComputeWorldMatrix(): void;
  15088. /**
  15089. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15090. * @param func callback function to add
  15091. *
  15092. * @returns the TransformNode.
  15093. */
  15094. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15095. /**
  15096. * Removes a registered callback function.
  15097. * @param func callback function to remove
  15098. * @returns the TransformNode.
  15099. */
  15100. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15101. /**
  15102. * Gets the position of the current mesh in camera space
  15103. * @param camera defines the camera to use
  15104. * @returns a position
  15105. */
  15106. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15107. /**
  15108. * Returns the distance from the mesh to the active camera
  15109. * @param camera defines the camera to use
  15110. * @returns the distance
  15111. */
  15112. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15113. /**
  15114. * Clone the current transform node
  15115. * @param name Name of the new clone
  15116. * @param newParent New parent for the clone
  15117. * @param doNotCloneChildren Do not clone children hierarchy
  15118. * @returns the new transform node
  15119. */
  15120. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15121. /**
  15122. * Serializes the objects information.
  15123. * @param currentSerializationObject defines the object to serialize in
  15124. * @returns the serialized object
  15125. */
  15126. serialize(currentSerializationObject?: any): any;
  15127. /**
  15128. * Returns a new TransformNode object parsed from the source provided.
  15129. * @param parsedTransformNode is the source.
  15130. * @param scene the scne the object belongs to
  15131. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15132. * @returns a new TransformNode object parsed from the source provided.
  15133. */
  15134. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15135. /**
  15136. * Get all child-transformNodes of this node
  15137. * @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
  15138. * @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
  15139. * @returns an array of TransformNode
  15140. */
  15141. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15142. /**
  15143. * Releases resources associated with this transform node.
  15144. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15145. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15146. */
  15147. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15148. /**
  15149. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15150. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15151. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15152. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15153. * @returns the current mesh
  15154. */
  15155. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15156. private _syncAbsoluteScalingAndRotation;
  15157. }
  15158. }
  15159. declare module BABYLON {
  15160. /**
  15161. * Class used to override all child animations of a given target
  15162. */
  15163. export class AnimationPropertiesOverride {
  15164. /**
  15165. * Gets or sets a value indicating if animation blending must be used
  15166. */
  15167. enableBlending: boolean;
  15168. /**
  15169. * Gets or sets the blending speed to use when enableBlending is true
  15170. */
  15171. blendingSpeed: number;
  15172. /**
  15173. * Gets or sets the default loop mode to use
  15174. */
  15175. loopMode: number;
  15176. }
  15177. }
  15178. declare module BABYLON {
  15179. /**
  15180. * Class used to store bone information
  15181. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15182. */
  15183. export class Bone extends Node {
  15184. /**
  15185. * defines the bone name
  15186. */
  15187. name: string;
  15188. private static _tmpVecs;
  15189. private static _tmpQuat;
  15190. private static _tmpMats;
  15191. /**
  15192. * Gets the list of child bones
  15193. */
  15194. children: Bone[];
  15195. /** Gets the animations associated with this bone */
  15196. animations: Animation[];
  15197. /**
  15198. * Gets or sets bone length
  15199. */
  15200. length: number;
  15201. /**
  15202. * @hidden Internal only
  15203. * Set this value to map this bone to a different index in the transform matrices
  15204. * Set this value to -1 to exclude the bone from the transform matrices
  15205. */
  15206. _index: Nullable<number>;
  15207. private _skeleton;
  15208. private _localMatrix;
  15209. private _restPose;
  15210. private _bindPose;
  15211. private _baseMatrix;
  15212. private _absoluteTransform;
  15213. private _invertedAbsoluteTransform;
  15214. private _parent;
  15215. private _scalingDeterminant;
  15216. private _worldTransform;
  15217. private _localScaling;
  15218. private _localRotation;
  15219. private _localPosition;
  15220. private _needToDecompose;
  15221. private _needToCompose;
  15222. /** @hidden */
  15223. _linkedTransformNode: Nullable<TransformNode>;
  15224. /** @hidden */
  15225. _waitingTransformNodeId: Nullable<string>;
  15226. /** @hidden */
  15227. get _matrix(): Matrix;
  15228. /** @hidden */
  15229. set _matrix(value: Matrix);
  15230. /**
  15231. * Create a new bone
  15232. * @param name defines the bone name
  15233. * @param skeleton defines the parent skeleton
  15234. * @param parentBone defines the parent (can be null if the bone is the root)
  15235. * @param localMatrix defines the local matrix
  15236. * @param restPose defines the rest pose matrix
  15237. * @param baseMatrix defines the base matrix
  15238. * @param index defines index of the bone in the hiearchy
  15239. */
  15240. constructor(
  15241. /**
  15242. * defines the bone name
  15243. */
  15244. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15245. /**
  15246. * Gets the current object class name.
  15247. * @return the class name
  15248. */
  15249. getClassName(): string;
  15250. /**
  15251. * Gets the parent skeleton
  15252. * @returns a skeleton
  15253. */
  15254. getSkeleton(): Skeleton;
  15255. /**
  15256. * Gets parent bone
  15257. * @returns a bone or null if the bone is the root of the bone hierarchy
  15258. */
  15259. getParent(): Nullable<Bone>;
  15260. /**
  15261. * Returns an array containing the root bones
  15262. * @returns an array containing the root bones
  15263. */
  15264. getChildren(): Array<Bone>;
  15265. /**
  15266. * Gets the node index in matrix array generated for rendering
  15267. * @returns the node index
  15268. */
  15269. getIndex(): number;
  15270. /**
  15271. * Sets the parent bone
  15272. * @param parent defines the parent (can be null if the bone is the root)
  15273. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15274. */
  15275. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15276. /**
  15277. * Gets the local matrix
  15278. * @returns a matrix
  15279. */
  15280. getLocalMatrix(): Matrix;
  15281. /**
  15282. * Gets the base matrix (initial matrix which remains unchanged)
  15283. * @returns a matrix
  15284. */
  15285. getBaseMatrix(): Matrix;
  15286. /**
  15287. * Gets the rest pose matrix
  15288. * @returns a matrix
  15289. */
  15290. getRestPose(): Matrix;
  15291. /**
  15292. * Sets the rest pose matrix
  15293. * @param matrix the local-space rest pose to set for this bone
  15294. */
  15295. setRestPose(matrix: Matrix): void;
  15296. /**
  15297. * Gets the bind pose matrix
  15298. * @returns the bind pose matrix
  15299. */
  15300. getBindPose(): Matrix;
  15301. /**
  15302. * Sets the bind pose matrix
  15303. * @param matrix the local-space bind pose to set for this bone
  15304. */
  15305. setBindPose(matrix: Matrix): void;
  15306. /**
  15307. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15308. */
  15309. getWorldMatrix(): Matrix;
  15310. /**
  15311. * Sets the local matrix to rest pose matrix
  15312. */
  15313. returnToRest(): void;
  15314. /**
  15315. * Gets the inverse of the absolute transform matrix.
  15316. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15317. * @returns a matrix
  15318. */
  15319. getInvertedAbsoluteTransform(): Matrix;
  15320. /**
  15321. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15322. * @returns a matrix
  15323. */
  15324. getAbsoluteTransform(): Matrix;
  15325. /**
  15326. * Links with the given transform node.
  15327. * The local matrix of this bone is copied from the transform node every frame.
  15328. * @param transformNode defines the transform node to link to
  15329. */
  15330. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15331. /**
  15332. * Gets the node used to drive the bone's transformation
  15333. * @returns a transform node or null
  15334. */
  15335. getTransformNode(): Nullable<TransformNode>;
  15336. /** Gets or sets current position (in local space) */
  15337. get position(): Vector3;
  15338. set position(newPosition: Vector3);
  15339. /** Gets or sets current rotation (in local space) */
  15340. get rotation(): Vector3;
  15341. set rotation(newRotation: Vector3);
  15342. /** Gets or sets current rotation quaternion (in local space) */
  15343. get rotationQuaternion(): Quaternion;
  15344. set rotationQuaternion(newRotation: Quaternion);
  15345. /** Gets or sets current scaling (in local space) */
  15346. get scaling(): Vector3;
  15347. set scaling(newScaling: Vector3);
  15348. /**
  15349. * Gets the animation properties override
  15350. */
  15351. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15352. private _decompose;
  15353. private _compose;
  15354. /**
  15355. * Update the base and local matrices
  15356. * @param matrix defines the new base or local matrix
  15357. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15358. * @param updateLocalMatrix defines if the local matrix should be updated
  15359. */
  15360. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15361. /** @hidden */
  15362. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15363. /**
  15364. * Flag the bone as dirty (Forcing it to update everything)
  15365. */
  15366. markAsDirty(): void;
  15367. /** @hidden */
  15368. _markAsDirtyAndCompose(): void;
  15369. private _markAsDirtyAndDecompose;
  15370. /**
  15371. * Translate the bone in local or world space
  15372. * @param vec The amount to translate the bone
  15373. * @param space The space that the translation is in
  15374. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15375. */
  15376. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15377. /**
  15378. * Set the postion of the bone in local or world space
  15379. * @param position The position to set the bone
  15380. * @param space The space that the position is in
  15381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15382. */
  15383. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15384. /**
  15385. * Set the absolute position of the bone (world space)
  15386. * @param position The position to set the bone
  15387. * @param mesh The mesh that this bone is attached to
  15388. */
  15389. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15390. /**
  15391. * Scale the bone on the x, y and z axes (in local space)
  15392. * @param x The amount to scale the bone on the x axis
  15393. * @param y The amount to scale the bone on the y axis
  15394. * @param z The amount to scale the bone on the z axis
  15395. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15396. */
  15397. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15398. /**
  15399. * Set the bone scaling in local space
  15400. * @param scale defines the scaling vector
  15401. */
  15402. setScale(scale: Vector3): void;
  15403. /**
  15404. * Gets the current scaling in local space
  15405. * @returns the current scaling vector
  15406. */
  15407. getScale(): Vector3;
  15408. /**
  15409. * Gets the current scaling in local space and stores it in a target vector
  15410. * @param result defines the target vector
  15411. */
  15412. getScaleToRef(result: Vector3): void;
  15413. /**
  15414. * Set the yaw, pitch, and roll of the bone in local or world space
  15415. * @param yaw The rotation of the bone on the y axis
  15416. * @param pitch The rotation of the bone on the x axis
  15417. * @param roll The rotation of the bone on the z axis
  15418. * @param space The space that the axes of rotation are in
  15419. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15420. */
  15421. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15422. /**
  15423. * Add a rotation to the bone on an axis in local or world space
  15424. * @param axis The axis to rotate the bone on
  15425. * @param amount The amount to rotate the bone
  15426. * @param space The space that the axis is in
  15427. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15428. */
  15429. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15430. /**
  15431. * Set the rotation of the bone to a particular axis angle in local or world space
  15432. * @param axis The axis to rotate the bone on
  15433. * @param angle The angle that the bone should be rotated to
  15434. * @param space The space that the axis is in
  15435. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15436. */
  15437. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15438. /**
  15439. * Set the euler rotation of the bone in local or world space
  15440. * @param rotation The euler rotation that the bone should be set to
  15441. * @param space The space that the rotation is in
  15442. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15443. */
  15444. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15445. /**
  15446. * Set the quaternion rotation of the bone in local or world space
  15447. * @param quat The quaternion rotation that the bone should be set to
  15448. * @param space The space that the rotation is in
  15449. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15450. */
  15451. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15452. /**
  15453. * Set the rotation matrix of the bone in local or world space
  15454. * @param rotMat The rotation matrix that the bone should be set to
  15455. * @param space The space that the rotation is in
  15456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15457. */
  15458. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15459. private _rotateWithMatrix;
  15460. private _getNegativeRotationToRef;
  15461. /**
  15462. * Get the position of the bone in local or world space
  15463. * @param space The space that the returned position is in
  15464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15465. * @returns The position of the bone
  15466. */
  15467. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15468. /**
  15469. * Copy the position of the bone to a vector3 in local or world space
  15470. * @param space The space that the returned position is in
  15471. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15472. * @param result The vector3 to copy the position to
  15473. */
  15474. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15475. /**
  15476. * Get the absolute position of the bone (world space)
  15477. * @param mesh The mesh that this bone is attached to
  15478. * @returns The absolute position of the bone
  15479. */
  15480. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15481. /**
  15482. * Copy the absolute position of the bone (world space) to the result param
  15483. * @param mesh The mesh that this bone is attached to
  15484. * @param result The vector3 to copy the absolute position to
  15485. */
  15486. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15487. /**
  15488. * Compute the absolute transforms of this bone and its children
  15489. */
  15490. computeAbsoluteTransforms(): void;
  15491. /**
  15492. * Get the world direction from an axis that is in the local space of the bone
  15493. * @param localAxis The local direction that is used to compute the world direction
  15494. * @param mesh The mesh that this bone is attached to
  15495. * @returns The world direction
  15496. */
  15497. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15498. /**
  15499. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15500. * @param localAxis The local direction that is used to compute the world direction
  15501. * @param mesh The mesh that this bone is attached to
  15502. * @param result The vector3 that the world direction will be copied to
  15503. */
  15504. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15505. /**
  15506. * Get the euler rotation of the bone in local or world space
  15507. * @param space The space that the rotation should be in
  15508. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15509. * @returns The euler rotation
  15510. */
  15511. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15512. /**
  15513. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15514. * @param space The space that the rotation should be in
  15515. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15516. * @param result The vector3 that the rotation should be copied to
  15517. */
  15518. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15519. /**
  15520. * Get the quaternion rotation of the bone in either local or world space
  15521. * @param space The space that the rotation should be in
  15522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15523. * @returns The quaternion rotation
  15524. */
  15525. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15526. /**
  15527. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15528. * @param space The space that the rotation should be in
  15529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15530. * @param result The quaternion that the rotation should be copied to
  15531. */
  15532. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15533. /**
  15534. * Get the rotation matrix of the bone in local or world space
  15535. * @param space The space that the rotation should be in
  15536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15537. * @returns The rotation matrix
  15538. */
  15539. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15540. /**
  15541. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15542. * @param space The space that the rotation should be in
  15543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15544. * @param result The quaternion that the rotation should be copied to
  15545. */
  15546. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15547. /**
  15548. * Get the world position of a point that is in the local space of the bone
  15549. * @param position The local position
  15550. * @param mesh The mesh that this bone is attached to
  15551. * @returns The world position
  15552. */
  15553. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15554. /**
  15555. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15556. * @param position The local position
  15557. * @param mesh The mesh that this bone is attached to
  15558. * @param result The vector3 that the world position should be copied to
  15559. */
  15560. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15561. /**
  15562. * Get the local position of a point that is in world space
  15563. * @param position The world position
  15564. * @param mesh The mesh that this bone is attached to
  15565. * @returns The local position
  15566. */
  15567. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15568. /**
  15569. * Get the local position of a point that is in world space and copy it to the result param
  15570. * @param position The world position
  15571. * @param mesh The mesh that this bone is attached to
  15572. * @param result The vector3 that the local position should be copied to
  15573. */
  15574. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15575. /**
  15576. * Set the current local matrix as the restPose for this bone.
  15577. */
  15578. setCurrentPoseAsRest(): void;
  15579. }
  15580. }
  15581. declare module BABYLON {
  15582. /**
  15583. * Defines a runtime animation
  15584. */
  15585. export class RuntimeAnimation {
  15586. private _events;
  15587. /**
  15588. * The current frame of the runtime animation
  15589. */
  15590. private _currentFrame;
  15591. /**
  15592. * The animation used by the runtime animation
  15593. */
  15594. private _animation;
  15595. /**
  15596. * The target of the runtime animation
  15597. */
  15598. private _target;
  15599. /**
  15600. * The initiating animatable
  15601. */
  15602. private _host;
  15603. /**
  15604. * The original value of the runtime animation
  15605. */
  15606. private _originalValue;
  15607. /**
  15608. * The original blend value of the runtime animation
  15609. */
  15610. private _originalBlendValue;
  15611. /**
  15612. * The offsets cache of the runtime animation
  15613. */
  15614. private _offsetsCache;
  15615. /**
  15616. * The high limits cache of the runtime animation
  15617. */
  15618. private _highLimitsCache;
  15619. /**
  15620. * Specifies if the runtime animation has been stopped
  15621. */
  15622. private _stopped;
  15623. /**
  15624. * The blending factor of the runtime animation
  15625. */
  15626. private _blendingFactor;
  15627. /**
  15628. * The BabylonJS scene
  15629. */
  15630. private _scene;
  15631. /**
  15632. * The current value of the runtime animation
  15633. */
  15634. private _currentValue;
  15635. /** @hidden */
  15636. _animationState: _IAnimationState;
  15637. /**
  15638. * The active target of the runtime animation
  15639. */
  15640. private _activeTargets;
  15641. private _currentActiveTarget;
  15642. private _directTarget;
  15643. /**
  15644. * The target path of the runtime animation
  15645. */
  15646. private _targetPath;
  15647. /**
  15648. * The weight of the runtime animation
  15649. */
  15650. private _weight;
  15651. /**
  15652. * The ratio offset of the runtime animation
  15653. */
  15654. private _ratioOffset;
  15655. /**
  15656. * The previous delay of the runtime animation
  15657. */
  15658. private _previousDelay;
  15659. /**
  15660. * The previous ratio of the runtime animation
  15661. */
  15662. private _previousRatio;
  15663. private _enableBlending;
  15664. private _keys;
  15665. private _minFrame;
  15666. private _maxFrame;
  15667. private _minValue;
  15668. private _maxValue;
  15669. private _targetIsArray;
  15670. /**
  15671. * Gets the current frame of the runtime animation
  15672. */
  15673. get currentFrame(): number;
  15674. /**
  15675. * Gets the weight of the runtime animation
  15676. */
  15677. get weight(): number;
  15678. /**
  15679. * Gets the current value of the runtime animation
  15680. */
  15681. get currentValue(): any;
  15682. /**
  15683. * Gets the target path of the runtime animation
  15684. */
  15685. get targetPath(): string;
  15686. /**
  15687. * Gets the actual target of the runtime animation
  15688. */
  15689. get target(): any;
  15690. /**
  15691. * Gets the additive state of the runtime animation
  15692. */
  15693. get isAdditive(): boolean;
  15694. /** @hidden */
  15695. _onLoop: () => void;
  15696. /**
  15697. * Create a new RuntimeAnimation object
  15698. * @param target defines the target of the animation
  15699. * @param animation defines the source animation object
  15700. * @param scene defines the hosting scene
  15701. * @param host defines the initiating Animatable
  15702. */
  15703. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15704. private _preparePath;
  15705. /**
  15706. * Gets the animation from the runtime animation
  15707. */
  15708. get animation(): Animation;
  15709. /**
  15710. * Resets the runtime animation to the beginning
  15711. * @param restoreOriginal defines whether to restore the target property to the original value
  15712. */
  15713. reset(restoreOriginal?: boolean): void;
  15714. /**
  15715. * Specifies if the runtime animation is stopped
  15716. * @returns Boolean specifying if the runtime animation is stopped
  15717. */
  15718. isStopped(): boolean;
  15719. /**
  15720. * Disposes of the runtime animation
  15721. */
  15722. dispose(): void;
  15723. /**
  15724. * Apply the interpolated value to the target
  15725. * @param currentValue defines the value computed by the animation
  15726. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15727. */
  15728. setValue(currentValue: any, weight: number): void;
  15729. private _getOriginalValues;
  15730. private _setValue;
  15731. /**
  15732. * Gets the loop pmode of the runtime animation
  15733. * @returns Loop Mode
  15734. */
  15735. private _getCorrectLoopMode;
  15736. /**
  15737. * Move the current animation to a given frame
  15738. * @param frame defines the frame to move to
  15739. */
  15740. goToFrame(frame: number): void;
  15741. /**
  15742. * @hidden Internal use only
  15743. */
  15744. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15745. /**
  15746. * Execute the current animation
  15747. * @param delay defines the delay to add to the current frame
  15748. * @param from defines the lower bound of the animation range
  15749. * @param to defines the upper bound of the animation range
  15750. * @param loop defines if the current animation must loop
  15751. * @param speedRatio defines the current speed ratio
  15752. * @param weight defines the weight of the animation (default is -1 so no weight)
  15753. * @param onLoop optional callback called when animation loops
  15754. * @returns a boolean indicating if the animation is running
  15755. */
  15756. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15757. }
  15758. }
  15759. declare module BABYLON {
  15760. /**
  15761. * Class used to store an actual running animation
  15762. */
  15763. export class Animatable {
  15764. /** defines the target object */
  15765. target: any;
  15766. /** defines the starting frame number (default is 0) */
  15767. fromFrame: number;
  15768. /** defines the ending frame number (default is 100) */
  15769. toFrame: number;
  15770. /** defines if the animation must loop (default is false) */
  15771. loopAnimation: boolean;
  15772. /** defines a callback to call when animation ends if it is not looping */
  15773. onAnimationEnd?: (() => void) | null | undefined;
  15774. /** defines a callback to call when animation loops */
  15775. onAnimationLoop?: (() => void) | null | undefined;
  15776. /** defines whether the animation should be evaluated additively */
  15777. isAdditive: boolean;
  15778. private _localDelayOffset;
  15779. private _pausedDelay;
  15780. private _runtimeAnimations;
  15781. private _paused;
  15782. private _scene;
  15783. private _speedRatio;
  15784. private _weight;
  15785. private _syncRoot;
  15786. /**
  15787. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15788. * This will only apply for non looping animation (default is true)
  15789. */
  15790. disposeOnEnd: boolean;
  15791. /**
  15792. * Gets a boolean indicating if the animation has started
  15793. */
  15794. animationStarted: boolean;
  15795. /**
  15796. * Observer raised when the animation ends
  15797. */
  15798. onAnimationEndObservable: Observable<Animatable>;
  15799. /**
  15800. * Observer raised when the animation loops
  15801. */
  15802. onAnimationLoopObservable: Observable<Animatable>;
  15803. /**
  15804. * Gets the root Animatable used to synchronize and normalize animations
  15805. */
  15806. get syncRoot(): Nullable<Animatable>;
  15807. /**
  15808. * Gets the current frame of the first RuntimeAnimation
  15809. * Used to synchronize Animatables
  15810. */
  15811. get masterFrame(): number;
  15812. /**
  15813. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15814. */
  15815. get weight(): number;
  15816. set weight(value: number);
  15817. /**
  15818. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15819. */
  15820. get speedRatio(): number;
  15821. set speedRatio(value: number);
  15822. /**
  15823. * Creates a new Animatable
  15824. * @param scene defines the hosting scene
  15825. * @param target defines the target object
  15826. * @param fromFrame defines the starting frame number (default is 0)
  15827. * @param toFrame defines the ending frame number (default is 100)
  15828. * @param loopAnimation defines if the animation must loop (default is false)
  15829. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15830. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15831. * @param animations defines a group of animation to add to the new Animatable
  15832. * @param onAnimationLoop defines a callback to call when animation loops
  15833. * @param isAdditive defines whether the animation should be evaluated additively
  15834. */
  15835. constructor(scene: Scene,
  15836. /** defines the target object */
  15837. target: any,
  15838. /** defines the starting frame number (default is 0) */
  15839. fromFrame?: number,
  15840. /** defines the ending frame number (default is 100) */
  15841. toFrame?: number,
  15842. /** defines if the animation must loop (default is false) */
  15843. loopAnimation?: boolean, speedRatio?: number,
  15844. /** defines a callback to call when animation ends if it is not looping */
  15845. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15846. /** defines a callback to call when animation loops */
  15847. onAnimationLoop?: (() => void) | null | undefined,
  15848. /** defines whether the animation should be evaluated additively */
  15849. isAdditive?: boolean);
  15850. /**
  15851. * Synchronize and normalize current Animatable with a source Animatable
  15852. * This is useful when using animation weights and when animations are not of the same length
  15853. * @param root defines the root Animatable to synchronize with
  15854. * @returns the current Animatable
  15855. */
  15856. syncWith(root: Animatable): Animatable;
  15857. /**
  15858. * Gets the list of runtime animations
  15859. * @returns an array of RuntimeAnimation
  15860. */
  15861. getAnimations(): RuntimeAnimation[];
  15862. /**
  15863. * Adds more animations to the current animatable
  15864. * @param target defines the target of the animations
  15865. * @param animations defines the new animations to add
  15866. */
  15867. appendAnimations(target: any, animations: Animation[]): void;
  15868. /**
  15869. * Gets the source animation for a specific property
  15870. * @param property defines the propertyu to look for
  15871. * @returns null or the source animation for the given property
  15872. */
  15873. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15874. /**
  15875. * Gets the runtime animation for a specific property
  15876. * @param property defines the propertyu to look for
  15877. * @returns null or the runtime animation for the given property
  15878. */
  15879. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15880. /**
  15881. * Resets the animatable to its original state
  15882. */
  15883. reset(): void;
  15884. /**
  15885. * Allows the animatable to blend with current running animations
  15886. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15887. * @param blendingSpeed defines the blending speed to use
  15888. */
  15889. enableBlending(blendingSpeed: number): void;
  15890. /**
  15891. * Disable animation blending
  15892. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15893. */
  15894. disableBlending(): void;
  15895. /**
  15896. * Jump directly to a given frame
  15897. * @param frame defines the frame to jump to
  15898. */
  15899. goToFrame(frame: number): void;
  15900. /**
  15901. * Pause the animation
  15902. */
  15903. pause(): void;
  15904. /**
  15905. * Restart the animation
  15906. */
  15907. restart(): void;
  15908. private _raiseOnAnimationEnd;
  15909. /**
  15910. * Stop and delete the current animation
  15911. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15912. * @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)
  15913. */
  15914. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15915. /**
  15916. * Wait asynchronously for the animation to end
  15917. * @returns a promise which will be fullfilled when the animation ends
  15918. */
  15919. waitAsync(): Promise<Animatable>;
  15920. /** @hidden */
  15921. _animate(delay: number): boolean;
  15922. }
  15923. interface Scene {
  15924. /** @hidden */
  15925. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15926. /** @hidden */
  15927. _processLateAnimationBindingsForMatrices(holder: {
  15928. totalWeight: number;
  15929. totalAdditiveWeight: number;
  15930. animations: RuntimeAnimation[];
  15931. additiveAnimations: RuntimeAnimation[];
  15932. originalValue: Matrix;
  15933. }): any;
  15934. /** @hidden */
  15935. _processLateAnimationBindingsForQuaternions(holder: {
  15936. totalWeight: number;
  15937. totalAdditiveWeight: number;
  15938. animations: RuntimeAnimation[];
  15939. additiveAnimations: RuntimeAnimation[];
  15940. originalValue: Quaternion;
  15941. }, refQuaternion: Quaternion): Quaternion;
  15942. /** @hidden */
  15943. _processLateAnimationBindings(): void;
  15944. /**
  15945. * Will start the animation sequence of a given target
  15946. * @param target defines the target
  15947. * @param from defines from which frame should animation start
  15948. * @param to defines until which frame should animation run.
  15949. * @param weight defines the weight to apply to the animation (1.0 by default)
  15950. * @param loop defines if the animation loops
  15951. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15952. * @param onAnimationEnd defines the function to be executed when the animation ends
  15953. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15954. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15955. * @param onAnimationLoop defines the callback to call when an animation loops
  15956. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15957. * @returns the animatable object created for this animation
  15958. */
  15959. 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;
  15960. /**
  15961. * Will start the animation sequence of a given target
  15962. * @param target defines the target
  15963. * @param from defines from which frame should animation start
  15964. * @param to defines until which frame should animation run.
  15965. * @param loop defines if the animation loops
  15966. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15967. * @param onAnimationEnd defines the function to be executed when the animation ends
  15968. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15969. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15970. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15971. * @param onAnimationLoop defines the callback to call when an animation loops
  15972. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15973. * @returns the animatable object created for this animation
  15974. */
  15975. 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;
  15976. /**
  15977. * Will start the animation sequence of a given target and its hierarchy
  15978. * @param target defines the target
  15979. * @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.
  15980. * @param from defines from which frame should animation start
  15981. * @param to defines until which frame should animation run.
  15982. * @param loop defines if the animation loops
  15983. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15984. * @param onAnimationEnd defines the function to be executed when the animation ends
  15985. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15986. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15987. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15988. * @param onAnimationLoop defines the callback to call when an animation loops
  15989. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15990. * @returns the list of created animatables
  15991. */
  15992. 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[];
  15993. /**
  15994. * Begin a new animation on a given node
  15995. * @param target defines the target where the animation will take place
  15996. * @param animations defines the list of animations to start
  15997. * @param from defines the initial value
  15998. * @param to defines the final value
  15999. * @param loop defines if you want animation to loop (off by default)
  16000. * @param speedRatio defines the speed ratio to apply to all animations
  16001. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16002. * @param onAnimationLoop defines the callback to call when an animation loops
  16003. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16004. * @returns the list of created animatables
  16005. */
  16006. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16007. /**
  16008. * Begin a new animation on a given node and its hierarchy
  16009. * @param target defines the root node where the animation will take place
  16010. * @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.
  16011. * @param animations defines the list of animations to start
  16012. * @param from defines the initial value
  16013. * @param to defines the final value
  16014. * @param loop defines if you want animation to loop (off by default)
  16015. * @param speedRatio defines the speed ratio to apply to all animations
  16016. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16017. * @param onAnimationLoop defines the callback to call when an animation loops
  16018. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16019. * @returns the list of animatables created for all nodes
  16020. */
  16021. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16022. /**
  16023. * Gets the animatable associated with a specific target
  16024. * @param target defines the target of the animatable
  16025. * @returns the required animatable if found
  16026. */
  16027. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16028. /**
  16029. * Gets all animatables associated with a given target
  16030. * @param target defines the target to look animatables for
  16031. * @returns an array of Animatables
  16032. */
  16033. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16034. /**
  16035. * Stops and removes all animations that have been applied to the scene
  16036. */
  16037. stopAllAnimations(): void;
  16038. /**
  16039. * Gets the current delta time used by animation engine
  16040. */
  16041. deltaTime: number;
  16042. }
  16043. interface Bone {
  16044. /**
  16045. * Copy an animation range from another bone
  16046. * @param source defines the source bone
  16047. * @param rangeName defines the range name to copy
  16048. * @param frameOffset defines the frame offset
  16049. * @param rescaleAsRequired defines if rescaling must be applied if required
  16050. * @param skelDimensionsRatio defines the scaling ratio
  16051. * @returns true if operation was successful
  16052. */
  16053. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16054. }
  16055. }
  16056. declare module BABYLON {
  16057. /**
  16058. * Class used to handle skinning animations
  16059. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16060. */
  16061. export class Skeleton implements IAnimatable {
  16062. /** defines the skeleton name */
  16063. name: string;
  16064. /** defines the skeleton Id */
  16065. id: string;
  16066. /**
  16067. * Defines the list of child bones
  16068. */
  16069. bones: Bone[];
  16070. /**
  16071. * Defines an estimate of the dimension of the skeleton at rest
  16072. */
  16073. dimensionsAtRest: Vector3;
  16074. /**
  16075. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16076. */
  16077. needInitialSkinMatrix: boolean;
  16078. /**
  16079. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16080. */
  16081. overrideMesh: Nullable<AbstractMesh>;
  16082. /**
  16083. * Gets the list of animations attached to this skeleton
  16084. */
  16085. animations: Array<Animation>;
  16086. private _scene;
  16087. private _isDirty;
  16088. private _transformMatrices;
  16089. private _transformMatrixTexture;
  16090. private _meshesWithPoseMatrix;
  16091. private _animatables;
  16092. private _identity;
  16093. private _synchronizedWithMesh;
  16094. private _ranges;
  16095. private _lastAbsoluteTransformsUpdateId;
  16096. private _canUseTextureForBones;
  16097. private _uniqueId;
  16098. /** @hidden */
  16099. _numBonesWithLinkedTransformNode: number;
  16100. /** @hidden */
  16101. _hasWaitingData: Nullable<boolean>;
  16102. /** @hidden */
  16103. _waitingOverrideMeshId: Nullable<string>;
  16104. /**
  16105. * Specifies if the skeleton should be serialized
  16106. */
  16107. doNotSerialize: boolean;
  16108. private _useTextureToStoreBoneMatrices;
  16109. /**
  16110. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16111. * Please note that this option is not available if the hardware does not support it
  16112. */
  16113. get useTextureToStoreBoneMatrices(): boolean;
  16114. set useTextureToStoreBoneMatrices(value: boolean);
  16115. private _animationPropertiesOverride;
  16116. /**
  16117. * Gets or sets the animation properties override
  16118. */
  16119. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16120. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16121. /**
  16122. * List of inspectable custom properties (used by the Inspector)
  16123. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16124. */
  16125. inspectableCustomProperties: IInspectable[];
  16126. /**
  16127. * An observable triggered before computing the skeleton's matrices
  16128. */
  16129. onBeforeComputeObservable: Observable<Skeleton>;
  16130. /**
  16131. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16132. */
  16133. get isUsingTextureForMatrices(): boolean;
  16134. /**
  16135. * Gets the unique ID of this skeleton
  16136. */
  16137. get uniqueId(): number;
  16138. /**
  16139. * Creates a new skeleton
  16140. * @param name defines the skeleton name
  16141. * @param id defines the skeleton Id
  16142. * @param scene defines the hosting scene
  16143. */
  16144. constructor(
  16145. /** defines the skeleton name */
  16146. name: string,
  16147. /** defines the skeleton Id */
  16148. id: string, scene: Scene);
  16149. /**
  16150. * Gets the current object class name.
  16151. * @return the class name
  16152. */
  16153. getClassName(): string;
  16154. /**
  16155. * Returns an array containing the root bones
  16156. * @returns an array containing the root bones
  16157. */
  16158. getChildren(): Array<Bone>;
  16159. /**
  16160. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16161. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16162. * @returns a Float32Array containing matrices data
  16163. */
  16164. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16165. /**
  16166. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16167. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16168. * @returns a raw texture containing the data
  16169. */
  16170. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16171. /**
  16172. * Gets the current hosting scene
  16173. * @returns a scene object
  16174. */
  16175. getScene(): Scene;
  16176. /**
  16177. * Gets a string representing the current skeleton data
  16178. * @param fullDetails defines a boolean indicating if we want a verbose version
  16179. * @returns a string representing the current skeleton data
  16180. */
  16181. toString(fullDetails?: boolean): string;
  16182. /**
  16183. * Get bone's index searching by name
  16184. * @param name defines bone's name to search for
  16185. * @return the indice of the bone. Returns -1 if not found
  16186. */
  16187. getBoneIndexByName(name: string): number;
  16188. /**
  16189. * Creater a new animation range
  16190. * @param name defines the name of the range
  16191. * @param from defines the start key
  16192. * @param to defines the end key
  16193. */
  16194. createAnimationRange(name: string, from: number, to: number): void;
  16195. /**
  16196. * Delete a specific animation range
  16197. * @param name defines the name of the range
  16198. * @param deleteFrames defines if frames must be removed as well
  16199. */
  16200. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16201. /**
  16202. * Gets a specific animation range
  16203. * @param name defines the name of the range to look for
  16204. * @returns the requested animation range or null if not found
  16205. */
  16206. getAnimationRange(name: string): Nullable<AnimationRange>;
  16207. /**
  16208. * Gets the list of all animation ranges defined on this skeleton
  16209. * @returns an array
  16210. */
  16211. getAnimationRanges(): Nullable<AnimationRange>[];
  16212. /**
  16213. * Copy animation range from a source skeleton.
  16214. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16215. * @param source defines the source skeleton
  16216. * @param name defines the name of the range to copy
  16217. * @param rescaleAsRequired defines if rescaling must be applied if required
  16218. * @returns true if operation was successful
  16219. */
  16220. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16221. /**
  16222. * Forces the skeleton to go to rest pose
  16223. */
  16224. returnToRest(): void;
  16225. private _getHighestAnimationFrame;
  16226. /**
  16227. * Begin a specific animation range
  16228. * @param name defines the name of the range to start
  16229. * @param loop defines if looping must be turned on (false by default)
  16230. * @param speedRatio defines the speed ratio to apply (1 by default)
  16231. * @param onAnimationEnd defines a callback which will be called when animation will end
  16232. * @returns a new animatable
  16233. */
  16234. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16235. /**
  16236. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16237. * @param skeleton defines the Skeleton containing the animation range to convert
  16238. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16239. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16240. * @returns the original skeleton
  16241. */
  16242. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16243. /** @hidden */
  16244. _markAsDirty(): void;
  16245. /** @hidden */
  16246. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16247. /** @hidden */
  16248. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16249. private _computeTransformMatrices;
  16250. /**
  16251. * Build all resources required to render a skeleton
  16252. */
  16253. prepare(): void;
  16254. /**
  16255. * Gets the list of animatables currently running for this skeleton
  16256. * @returns an array of animatables
  16257. */
  16258. getAnimatables(): IAnimatable[];
  16259. /**
  16260. * Clone the current skeleton
  16261. * @param name defines the name of the new skeleton
  16262. * @param id defines the id of the new skeleton
  16263. * @returns the new skeleton
  16264. */
  16265. clone(name: string, id?: string): Skeleton;
  16266. /**
  16267. * Enable animation blending for this skeleton
  16268. * @param blendingSpeed defines the blending speed to apply
  16269. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16270. */
  16271. enableBlending(blendingSpeed?: number): void;
  16272. /**
  16273. * Releases all resources associated with the current skeleton
  16274. */
  16275. dispose(): void;
  16276. /**
  16277. * Serialize the skeleton in a JSON object
  16278. * @returns a JSON object
  16279. */
  16280. serialize(): any;
  16281. /**
  16282. * Creates a new skeleton from serialized data
  16283. * @param parsedSkeleton defines the serialized data
  16284. * @param scene defines the hosting scene
  16285. * @returns a new skeleton
  16286. */
  16287. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16288. /**
  16289. * Compute all node absolute transforms
  16290. * @param forceUpdate defines if computation must be done even if cache is up to date
  16291. */
  16292. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16293. /**
  16294. * Gets the root pose matrix
  16295. * @returns a matrix
  16296. */
  16297. getPoseMatrix(): Nullable<Matrix>;
  16298. /**
  16299. * Sorts bones per internal index
  16300. */
  16301. sortBones(): void;
  16302. private _sortBones;
  16303. /**
  16304. * Set the current local matrix as the restPose for all bones in the skeleton.
  16305. */
  16306. setCurrentPoseAsRest(): void;
  16307. }
  16308. }
  16309. declare module BABYLON {
  16310. /**
  16311. * Creates an instance based on a source mesh.
  16312. */
  16313. export class InstancedMesh extends AbstractMesh {
  16314. private _sourceMesh;
  16315. private _currentLOD;
  16316. /** @hidden */
  16317. _indexInSourceMeshInstanceArray: number;
  16318. constructor(name: string, source: Mesh);
  16319. /**
  16320. * Returns the string "InstancedMesh".
  16321. */
  16322. getClassName(): string;
  16323. /** Gets the list of lights affecting that mesh */
  16324. get lightSources(): Light[];
  16325. _resyncLightSources(): void;
  16326. _resyncLightSource(light: Light): void;
  16327. _removeLightSource(light: Light, dispose: boolean): void;
  16328. /**
  16329. * If the source mesh receives shadows
  16330. */
  16331. get receiveShadows(): boolean;
  16332. /**
  16333. * The material of the source mesh
  16334. */
  16335. get material(): Nullable<Material>;
  16336. /**
  16337. * Visibility of the source mesh
  16338. */
  16339. get visibility(): number;
  16340. /**
  16341. * Skeleton of the source mesh
  16342. */
  16343. get skeleton(): Nullable<Skeleton>;
  16344. /**
  16345. * Rendering ground id of the source mesh
  16346. */
  16347. get renderingGroupId(): number;
  16348. set renderingGroupId(value: number);
  16349. /**
  16350. * Returns the total number of vertices (integer).
  16351. */
  16352. getTotalVertices(): number;
  16353. /**
  16354. * Returns a positive integer : the total number of indices in this mesh geometry.
  16355. * @returns the numner of indices or zero if the mesh has no geometry.
  16356. */
  16357. getTotalIndices(): number;
  16358. /**
  16359. * The source mesh of the instance
  16360. */
  16361. get sourceMesh(): Mesh;
  16362. /**
  16363. * Creates a new InstancedMesh object from the mesh model.
  16364. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16365. * @param name defines the name of the new instance
  16366. * @returns a new InstancedMesh
  16367. */
  16368. createInstance(name: string): InstancedMesh;
  16369. /**
  16370. * Is this node ready to be used/rendered
  16371. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16372. * @return {boolean} is it ready
  16373. */
  16374. isReady(completeCheck?: boolean): boolean;
  16375. /**
  16376. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16377. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16378. * @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.
  16379. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16380. */
  16381. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16382. /**
  16383. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16384. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16385. * The `data` are either a numeric array either a Float32Array.
  16386. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16387. * 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).
  16388. * Note that a new underlying VertexBuffer object is created each call.
  16389. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16390. *
  16391. * Possible `kind` values :
  16392. * - VertexBuffer.PositionKind
  16393. * - VertexBuffer.UVKind
  16394. * - VertexBuffer.UV2Kind
  16395. * - VertexBuffer.UV3Kind
  16396. * - VertexBuffer.UV4Kind
  16397. * - VertexBuffer.UV5Kind
  16398. * - VertexBuffer.UV6Kind
  16399. * - VertexBuffer.ColorKind
  16400. * - VertexBuffer.MatricesIndicesKind
  16401. * - VertexBuffer.MatricesIndicesExtraKind
  16402. * - VertexBuffer.MatricesWeightsKind
  16403. * - VertexBuffer.MatricesWeightsExtraKind
  16404. *
  16405. * Returns the Mesh.
  16406. */
  16407. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16408. /**
  16409. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16410. * If the mesh has no geometry, it is simply returned as it is.
  16411. * The `data` are either a numeric array either a Float32Array.
  16412. * No new underlying VertexBuffer object is created.
  16413. * 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.
  16414. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16415. *
  16416. * Possible `kind` values :
  16417. * - VertexBuffer.PositionKind
  16418. * - VertexBuffer.UVKind
  16419. * - VertexBuffer.UV2Kind
  16420. * - VertexBuffer.UV3Kind
  16421. * - VertexBuffer.UV4Kind
  16422. * - VertexBuffer.UV5Kind
  16423. * - VertexBuffer.UV6Kind
  16424. * - VertexBuffer.ColorKind
  16425. * - VertexBuffer.MatricesIndicesKind
  16426. * - VertexBuffer.MatricesIndicesExtraKind
  16427. * - VertexBuffer.MatricesWeightsKind
  16428. * - VertexBuffer.MatricesWeightsExtraKind
  16429. *
  16430. * Returns the Mesh.
  16431. */
  16432. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16433. /**
  16434. * Sets the mesh indices.
  16435. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16436. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16437. * This method creates a new index buffer each call.
  16438. * Returns the Mesh.
  16439. */
  16440. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16441. /**
  16442. * Boolean : True if the mesh owns the requested kind of data.
  16443. */
  16444. isVerticesDataPresent(kind: string): boolean;
  16445. /**
  16446. * Returns an array of indices (IndicesArray).
  16447. */
  16448. getIndices(): Nullable<IndicesArray>;
  16449. get _positions(): Nullable<Vector3[]>;
  16450. /**
  16451. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16452. * This means the mesh underlying bounding box and sphere are recomputed.
  16453. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16454. * @returns the current mesh
  16455. */
  16456. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16457. /** @hidden */
  16458. _preActivate(): InstancedMesh;
  16459. /** @hidden */
  16460. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16461. /** @hidden */
  16462. _postActivate(): void;
  16463. getWorldMatrix(): Matrix;
  16464. get isAnInstance(): boolean;
  16465. /**
  16466. * Returns the current associated LOD AbstractMesh.
  16467. */
  16468. getLOD(camera: Camera): AbstractMesh;
  16469. /** @hidden */
  16470. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16471. /** @hidden */
  16472. _syncSubMeshes(): InstancedMesh;
  16473. /** @hidden */
  16474. _generatePointsArray(): boolean;
  16475. /** @hidden */
  16476. _updateBoundingInfo(): AbstractMesh;
  16477. /**
  16478. * Creates a new InstancedMesh from the current mesh.
  16479. * - name (string) : the cloned mesh name
  16480. * - newParent (optional Node) : the optional Node to parent the clone to.
  16481. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16482. *
  16483. * Returns the clone.
  16484. */
  16485. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16486. /**
  16487. * Disposes the InstancedMesh.
  16488. * Returns nothing.
  16489. */
  16490. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16491. }
  16492. interface Mesh {
  16493. /**
  16494. * Register a custom buffer that will be instanced
  16495. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16496. * @param kind defines the buffer kind
  16497. * @param stride defines the stride in floats
  16498. */
  16499. registerInstancedBuffer(kind: string, stride: number): void;
  16500. /**
  16501. * true to use the edge renderer for all instances of this mesh
  16502. */
  16503. edgesShareWithInstances: boolean;
  16504. /** @hidden */
  16505. _userInstancedBuffersStorage: {
  16506. data: {
  16507. [key: string]: Float32Array;
  16508. };
  16509. sizes: {
  16510. [key: string]: number;
  16511. };
  16512. vertexBuffers: {
  16513. [key: string]: Nullable<VertexBuffer>;
  16514. };
  16515. strides: {
  16516. [key: string]: number;
  16517. };
  16518. };
  16519. }
  16520. interface AbstractMesh {
  16521. /**
  16522. * Object used to store instanced buffers defined by user
  16523. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16524. */
  16525. instancedBuffers: {
  16526. [key: string]: any;
  16527. };
  16528. }
  16529. }
  16530. declare module BABYLON {
  16531. /**
  16532. * Defines the options associated with the creation of a shader material.
  16533. */
  16534. export interface IShaderMaterialOptions {
  16535. /**
  16536. * Does the material work in alpha blend mode
  16537. */
  16538. needAlphaBlending: boolean;
  16539. /**
  16540. * Does the material work in alpha test mode
  16541. */
  16542. needAlphaTesting: boolean;
  16543. /**
  16544. * The list of attribute names used in the shader
  16545. */
  16546. attributes: string[];
  16547. /**
  16548. * The list of unifrom names used in the shader
  16549. */
  16550. uniforms: string[];
  16551. /**
  16552. * The list of UBO names used in the shader
  16553. */
  16554. uniformBuffers: string[];
  16555. /**
  16556. * The list of sampler names used in the shader
  16557. */
  16558. samplers: string[];
  16559. /**
  16560. * The list of defines used in the shader
  16561. */
  16562. defines: string[];
  16563. }
  16564. /**
  16565. * 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.
  16566. *
  16567. * This returned material effects how the mesh will look based on the code in the shaders.
  16568. *
  16569. * @see https://doc.babylonjs.com/how_to/shader_material
  16570. */
  16571. export class ShaderMaterial extends Material {
  16572. private _shaderPath;
  16573. private _options;
  16574. private _textures;
  16575. private _textureArrays;
  16576. private _floats;
  16577. private _ints;
  16578. private _floatsArrays;
  16579. private _colors3;
  16580. private _colors3Arrays;
  16581. private _colors4;
  16582. private _colors4Arrays;
  16583. private _vectors2;
  16584. private _vectors3;
  16585. private _vectors4;
  16586. private _matrices;
  16587. private _matrixArrays;
  16588. private _matrices3x3;
  16589. private _matrices2x2;
  16590. private _vectors2Arrays;
  16591. private _vectors3Arrays;
  16592. private _vectors4Arrays;
  16593. private _cachedWorldViewMatrix;
  16594. private _cachedWorldViewProjectionMatrix;
  16595. private _renderId;
  16596. private _multiview;
  16597. private _cachedDefines;
  16598. /** Define the Url to load snippets */
  16599. static SnippetUrl: string;
  16600. /** Snippet ID if the material was created from the snippet server */
  16601. snippetId: string;
  16602. /**
  16603. * Instantiate a new shader material.
  16604. * 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.
  16605. * This returned material effects how the mesh will look based on the code in the shaders.
  16606. * @see https://doc.babylonjs.com/how_to/shader_material
  16607. * @param name Define the name of the material in the scene
  16608. * @param scene Define the scene the material belongs to
  16609. * @param shaderPath Defines the route to the shader code in one of three ways:
  16610. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16611. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16612. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16613. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16614. * @param options Define the options used to create the shader
  16615. */
  16616. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16617. /**
  16618. * Gets the shader path used to define the shader code
  16619. * It can be modified to trigger a new compilation
  16620. */
  16621. get shaderPath(): any;
  16622. /**
  16623. * Sets the shader path used to define the shader code
  16624. * It can be modified to trigger a new compilation
  16625. */
  16626. set shaderPath(shaderPath: any);
  16627. /**
  16628. * Gets the options used to compile the shader.
  16629. * They can be modified to trigger a new compilation
  16630. */
  16631. get options(): IShaderMaterialOptions;
  16632. /**
  16633. * Gets the current class name of the material e.g. "ShaderMaterial"
  16634. * Mainly use in serialization.
  16635. * @returns the class name
  16636. */
  16637. getClassName(): string;
  16638. /**
  16639. * Specifies if the material will require alpha blending
  16640. * @returns a boolean specifying if alpha blending is needed
  16641. */
  16642. needAlphaBlending(): boolean;
  16643. /**
  16644. * Specifies if this material should be rendered in alpha test mode
  16645. * @returns a boolean specifying if an alpha test is needed.
  16646. */
  16647. needAlphaTesting(): boolean;
  16648. private _checkUniform;
  16649. /**
  16650. * Set a texture in the shader.
  16651. * @param name Define the name of the uniform samplers as defined in the shader
  16652. * @param texture Define the texture to bind to this sampler
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16656. /**
  16657. * Set a texture array in the shader.
  16658. * @param name Define the name of the uniform sampler array as defined in the shader
  16659. * @param textures Define the list of textures to bind to this sampler
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16663. /**
  16664. * Set a float in the shader.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setFloat(name: string, value: number): ShaderMaterial;
  16670. /**
  16671. * Set a int in the shader.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setInt(name: string, value: number): ShaderMaterial;
  16677. /**
  16678. * Set an array of floats in the shader.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setFloats(name: string, value: number[]): ShaderMaterial;
  16684. /**
  16685. * Set a vec3 in the shader from a Color3.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setColor3(name: string, value: Color3): ShaderMaterial;
  16691. /**
  16692. * Set a vec3 array in the shader from a Color3 array.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16698. /**
  16699. * Set a vec4 in the shader from a Color4.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setColor4(name: string, value: Color4): ShaderMaterial;
  16705. /**
  16706. * Set a vec4 array in the shader from a Color4 array.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16712. /**
  16713. * Set a vec2 in the shader from a Vector2.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setVector2(name: string, value: Vector2): ShaderMaterial;
  16719. /**
  16720. * Set a vec3 in the shader from a Vector3.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setVector3(name: string, value: Vector3): ShaderMaterial;
  16726. /**
  16727. * Set a vec4 in the shader from a Vector4.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setVector4(name: string, value: Vector4): ShaderMaterial;
  16733. /**
  16734. * Set a mat4 in the shader from a Matrix.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16740. /**
  16741. * Set a float32Array in the shader from a matrix array.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16747. /**
  16748. * Set a mat3 in the shader from a Float32Array.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16754. /**
  16755. * Set a mat2 in the shader from a Float32Array.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16761. /**
  16762. * Set a vec2 array in the shader from a number array.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setArray2(name: string, value: number[]): ShaderMaterial;
  16768. /**
  16769. * Set a vec3 array in the shader from a number array.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setArray3(name: string, value: number[]): ShaderMaterial;
  16775. /**
  16776. * Set a vec4 array in the shader from a number array.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setArray4(name: string, value: number[]): ShaderMaterial;
  16782. private _checkCache;
  16783. /**
  16784. * Specifies that the submesh is ready to be used
  16785. * @param mesh defines the mesh to check
  16786. * @param subMesh defines which submesh to check
  16787. * @param useInstances specifies that instances should be used
  16788. * @returns a boolean indicating that the submesh is ready or not
  16789. */
  16790. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16791. /**
  16792. * Checks if the material is ready to render the requested mesh
  16793. * @param mesh Define the mesh to render
  16794. * @param useInstances Define whether or not the material is used with instances
  16795. * @returns true if ready, otherwise false
  16796. */
  16797. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16798. /**
  16799. * Binds the world matrix to the material
  16800. * @param world defines the world transformation matrix
  16801. * @param effectOverride - If provided, use this effect instead of internal effect
  16802. */
  16803. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16804. /**
  16805. * Binds the submesh to this material by preparing the effect and shader to draw
  16806. * @param world defines the world transformation matrix
  16807. * @param mesh defines the mesh containing the submesh
  16808. * @param subMesh defines the submesh to bind the material to
  16809. */
  16810. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16811. /**
  16812. * Binds the material to the mesh
  16813. * @param world defines the world transformation matrix
  16814. * @param mesh defines the mesh to bind the material to
  16815. * @param effectOverride - If provided, use this effect instead of internal effect
  16816. */
  16817. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16818. protected _afterBind(mesh?: Mesh): void;
  16819. /**
  16820. * Gets the active textures from the material
  16821. * @returns an array of textures
  16822. */
  16823. getActiveTextures(): BaseTexture[];
  16824. /**
  16825. * Specifies if the material uses a texture
  16826. * @param texture defines the texture to check against the material
  16827. * @returns a boolean specifying if the material uses the texture
  16828. */
  16829. hasTexture(texture: BaseTexture): boolean;
  16830. /**
  16831. * Makes a duplicate of the material, and gives it a new name
  16832. * @param name defines the new name for the duplicated material
  16833. * @returns the cloned material
  16834. */
  16835. clone(name: string): ShaderMaterial;
  16836. /**
  16837. * Disposes the material
  16838. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16839. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16840. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16841. */
  16842. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16843. /**
  16844. * Serializes this material in a JSON representation
  16845. * @returns the serialized material object
  16846. */
  16847. serialize(): any;
  16848. /**
  16849. * Creates a shader material from parsed shader material data
  16850. * @param source defines the JSON represnetation of the material
  16851. * @param scene defines the hosting scene
  16852. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16853. * @returns a new material
  16854. */
  16855. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16856. /**
  16857. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16858. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16859. * @param url defines the url to load from
  16860. * @param scene defines the hosting scene
  16861. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16862. * @returns a promise that will resolve to the new ShaderMaterial
  16863. */
  16864. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16865. /**
  16866. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16867. * @param snippetId defines the snippet to load
  16868. * @param scene defines the hosting scene
  16869. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16870. * @returns a promise that will resolve to the new ShaderMaterial
  16871. */
  16872. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16873. }
  16874. }
  16875. declare module BABYLON {
  16876. /** @hidden */
  16877. export var colorPixelShader: {
  16878. name: string;
  16879. shader: string;
  16880. };
  16881. }
  16882. declare module BABYLON {
  16883. /** @hidden */
  16884. export var colorVertexShader: {
  16885. name: string;
  16886. shader: string;
  16887. };
  16888. }
  16889. declare module BABYLON {
  16890. /**
  16891. * Line mesh
  16892. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16893. */
  16894. export class LinesMesh extends Mesh {
  16895. /**
  16896. * If vertex color should be applied to the mesh
  16897. */
  16898. readonly useVertexColor?: boolean | undefined;
  16899. /**
  16900. * If vertex alpha should be applied to the mesh
  16901. */
  16902. readonly useVertexAlpha?: boolean | undefined;
  16903. /**
  16904. * Color of the line (Default: White)
  16905. */
  16906. color: Color3;
  16907. /**
  16908. * Alpha of the line (Default: 1)
  16909. */
  16910. alpha: number;
  16911. /**
  16912. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16913. * This margin is expressed in world space coordinates, so its value may vary.
  16914. * Default value is 0.1
  16915. */
  16916. intersectionThreshold: number;
  16917. private _colorShader;
  16918. private color4;
  16919. /**
  16920. * Creates a new LinesMesh
  16921. * @param name defines the name
  16922. * @param scene defines the hosting scene
  16923. * @param parent defines the parent mesh if any
  16924. * @param source defines the optional source LinesMesh used to clone data from
  16925. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16926. * When false, achieved by calling a clone(), also passing False.
  16927. * This will make creation of children, recursive.
  16928. * @param useVertexColor defines if this LinesMesh supports vertex color
  16929. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16930. */
  16931. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16932. /**
  16933. * If vertex color should be applied to the mesh
  16934. */
  16935. useVertexColor?: boolean | undefined,
  16936. /**
  16937. * If vertex alpha should be applied to the mesh
  16938. */
  16939. useVertexAlpha?: boolean | undefined);
  16940. private _addClipPlaneDefine;
  16941. private _removeClipPlaneDefine;
  16942. isReady(): boolean;
  16943. /**
  16944. * Returns the string "LineMesh"
  16945. */
  16946. getClassName(): string;
  16947. /**
  16948. * @hidden
  16949. */
  16950. get material(): Material;
  16951. /**
  16952. * @hidden
  16953. */
  16954. set material(value: Material);
  16955. /**
  16956. * @hidden
  16957. */
  16958. get checkCollisions(): boolean;
  16959. /** @hidden */
  16960. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16961. /** @hidden */
  16962. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16963. /**
  16964. * Disposes of the line mesh
  16965. * @param doNotRecurse If children should be disposed
  16966. */
  16967. dispose(doNotRecurse?: boolean): void;
  16968. /**
  16969. * Returns a new LineMesh object cloned from the current one.
  16970. */
  16971. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16972. /**
  16973. * Creates a new InstancedLinesMesh object from the mesh model.
  16974. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16975. * @param name defines the name of the new instance
  16976. * @returns a new InstancedLinesMesh
  16977. */
  16978. createInstance(name: string): InstancedLinesMesh;
  16979. }
  16980. /**
  16981. * Creates an instance based on a source LinesMesh
  16982. */
  16983. export class InstancedLinesMesh extends InstancedMesh {
  16984. /**
  16985. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16986. * This margin is expressed in world space coordinates, so its value may vary.
  16987. * Initilized with the intersectionThreshold value of the source LinesMesh
  16988. */
  16989. intersectionThreshold: number;
  16990. constructor(name: string, source: LinesMesh);
  16991. /**
  16992. * Returns the string "InstancedLinesMesh".
  16993. */
  16994. getClassName(): string;
  16995. }
  16996. }
  16997. declare module BABYLON {
  16998. /** @hidden */
  16999. export var linePixelShader: {
  17000. name: string;
  17001. shader: string;
  17002. };
  17003. }
  17004. declare module BABYLON {
  17005. /** @hidden */
  17006. export var lineVertexShader: {
  17007. name: string;
  17008. shader: string;
  17009. };
  17010. }
  17011. declare module BABYLON {
  17012. interface Scene {
  17013. /** @hidden */
  17014. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17015. }
  17016. interface AbstractMesh {
  17017. /**
  17018. * Gets the edgesRenderer associated with the mesh
  17019. */
  17020. edgesRenderer: Nullable<EdgesRenderer>;
  17021. }
  17022. interface LinesMesh {
  17023. /**
  17024. * Enables the edge rendering mode on the mesh.
  17025. * This mode makes the mesh edges visible
  17026. * @param epsilon defines the maximal distance between two angles to detect a face
  17027. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17028. * @returns the currentAbstractMesh
  17029. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17030. */
  17031. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17032. }
  17033. interface InstancedLinesMesh {
  17034. /**
  17035. * Enables the edge rendering mode on the mesh.
  17036. * This mode makes the mesh edges visible
  17037. * @param epsilon defines the maximal distance between two angles to detect a face
  17038. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17039. * @returns the current InstancedLinesMesh
  17040. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17041. */
  17042. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17043. }
  17044. /**
  17045. * Defines the minimum contract an Edges renderer should follow.
  17046. */
  17047. export interface IEdgesRenderer extends IDisposable {
  17048. /**
  17049. * Gets or sets a boolean indicating if the edgesRenderer is active
  17050. */
  17051. isEnabled: boolean;
  17052. /**
  17053. * Renders the edges of the attached mesh,
  17054. */
  17055. render(): void;
  17056. /**
  17057. * Checks wether or not the edges renderer is ready to render.
  17058. * @return true if ready, otherwise false.
  17059. */
  17060. isReady(): boolean;
  17061. /**
  17062. * List of instances to render in case the source mesh has instances
  17063. */
  17064. customInstances: SmartArray<Matrix>;
  17065. }
  17066. /**
  17067. * Defines the additional options of the edges renderer
  17068. */
  17069. export interface IEdgesRendererOptions {
  17070. /**
  17071. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17072. * If not defined, the default value is true
  17073. */
  17074. useAlternateEdgeFinder?: boolean;
  17075. /**
  17076. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17077. * If not defined, the default value is true.
  17078. * 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)
  17079. * This option is used only if useAlternateEdgeFinder = true
  17080. */
  17081. useFastVertexMerger?: boolean;
  17082. /**
  17083. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17084. * The default value is 1e-6
  17085. * This option is used only if useAlternateEdgeFinder = true
  17086. */
  17087. epsilonVertexMerge?: number;
  17088. /**
  17089. * 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
  17090. * 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.
  17091. * This option is used only if useAlternateEdgeFinder = true
  17092. */
  17093. applyTessellation?: boolean;
  17094. /**
  17095. * 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
  17096. * The default value is 1e-6
  17097. * This option is used only if useAlternateEdgeFinder = true
  17098. */
  17099. epsilonVertexAligned?: number;
  17100. }
  17101. /**
  17102. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17103. */
  17104. export class EdgesRenderer implements IEdgesRenderer {
  17105. /**
  17106. * Define the size of the edges with an orthographic camera
  17107. */
  17108. edgesWidthScalerForOrthographic: number;
  17109. /**
  17110. * Define the size of the edges with a perspective camera
  17111. */
  17112. edgesWidthScalerForPerspective: number;
  17113. protected _source: AbstractMesh;
  17114. protected _linesPositions: number[];
  17115. protected _linesNormals: number[];
  17116. protected _linesIndices: number[];
  17117. protected _epsilon: number;
  17118. protected _indicesCount: number;
  17119. protected _lineShader: ShaderMaterial;
  17120. protected _ib: DataBuffer;
  17121. protected _buffers: {
  17122. [key: string]: Nullable<VertexBuffer>;
  17123. };
  17124. protected _buffersForInstances: {
  17125. [key: string]: Nullable<VertexBuffer>;
  17126. };
  17127. protected _checkVerticesInsteadOfIndices: boolean;
  17128. protected _options: Nullable<IEdgesRendererOptions>;
  17129. private _meshRebuildObserver;
  17130. private _meshDisposeObserver;
  17131. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17132. isEnabled: boolean;
  17133. /**
  17134. * List of instances to render in case the source mesh has instances
  17135. */
  17136. customInstances: SmartArray<Matrix>;
  17137. private static GetShader;
  17138. /**
  17139. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17140. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17141. * @param source Mesh used to create edges
  17142. * @param epsilon sum of angles in adjacency to check for edge
  17143. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17144. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17145. * @param options The options to apply when generating the edges
  17146. */
  17147. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17148. protected _prepareRessources(): void;
  17149. /** @hidden */
  17150. _rebuild(): void;
  17151. /**
  17152. * Releases the required resources for the edges renderer
  17153. */
  17154. dispose(): void;
  17155. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17156. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17157. /**
  17158. * Checks if the pair of p0 and p1 is en edge
  17159. * @param faceIndex
  17160. * @param edge
  17161. * @param faceNormals
  17162. * @param p0
  17163. * @param p1
  17164. * @private
  17165. */
  17166. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17167. /**
  17168. * push line into the position, normal and index buffer
  17169. * @protected
  17170. */
  17171. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17172. /**
  17173. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17174. */
  17175. private _tessellateTriangle;
  17176. private _generateEdgesLinesAlternate;
  17177. /**
  17178. * Generates lines edges from adjacencjes
  17179. * @private
  17180. */
  17181. _generateEdgesLines(): void;
  17182. /**
  17183. * Checks wether or not the edges renderer is ready to render.
  17184. * @return true if ready, otherwise false.
  17185. */
  17186. isReady(): boolean;
  17187. /**
  17188. * Renders the edges of the attached mesh,
  17189. */
  17190. render(): void;
  17191. }
  17192. /**
  17193. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17194. */
  17195. export class LineEdgesRenderer extends EdgesRenderer {
  17196. /**
  17197. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17198. * @param source LineMesh used to generate edges
  17199. * @param epsilon not important (specified angle for edge detection)
  17200. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17201. */
  17202. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17203. /**
  17204. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17205. */
  17206. _generateEdgesLines(): void;
  17207. }
  17208. }
  17209. declare module BABYLON {
  17210. /**
  17211. * This represents the object necessary to create a rendering group.
  17212. * This is exclusively used and created by the rendering manager.
  17213. * To modify the behavior, you use the available helpers in your scene or meshes.
  17214. * @hidden
  17215. */
  17216. export class RenderingGroup {
  17217. index: number;
  17218. private static _zeroVector;
  17219. private _scene;
  17220. private _opaqueSubMeshes;
  17221. private _transparentSubMeshes;
  17222. private _alphaTestSubMeshes;
  17223. private _depthOnlySubMeshes;
  17224. private _particleSystems;
  17225. private _spriteManagers;
  17226. private _opaqueSortCompareFn;
  17227. private _alphaTestSortCompareFn;
  17228. private _transparentSortCompareFn;
  17229. private _renderOpaque;
  17230. private _renderAlphaTest;
  17231. private _renderTransparent;
  17232. /** @hidden */
  17233. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17234. onBeforeTransparentRendering: () => void;
  17235. /**
  17236. * Set the opaque sort comparison function.
  17237. * If null the sub meshes will be render in the order they were created
  17238. */
  17239. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17240. /**
  17241. * Set the alpha test sort comparison function.
  17242. * If null the sub meshes will be render in the order they were created
  17243. */
  17244. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17245. /**
  17246. * Set the transparent sort comparison function.
  17247. * If null the sub meshes will be render in the order they were created
  17248. */
  17249. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17250. /**
  17251. * Creates a new rendering group.
  17252. * @param index The rendering group index
  17253. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17254. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17255. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17256. */
  17257. 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>);
  17258. /**
  17259. * Render all the sub meshes contained in the group.
  17260. * @param customRenderFunction Used to override the default render behaviour of the group.
  17261. * @returns true if rendered some submeshes.
  17262. */
  17263. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17264. /**
  17265. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17266. * @param subMeshes The submeshes to render
  17267. */
  17268. private renderOpaqueSorted;
  17269. /**
  17270. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17271. * @param subMeshes The submeshes to render
  17272. */
  17273. private renderAlphaTestSorted;
  17274. /**
  17275. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17276. * @param subMeshes The submeshes to render
  17277. */
  17278. private renderTransparentSorted;
  17279. /**
  17280. * Renders the submeshes in a specified order.
  17281. * @param subMeshes The submeshes to sort before render
  17282. * @param sortCompareFn The comparison function use to sort
  17283. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17284. * @param transparent Specifies to activate blending if true
  17285. */
  17286. private static renderSorted;
  17287. /**
  17288. * Renders the submeshes in the order they were dispatched (no sort applied).
  17289. * @param subMeshes The submeshes to render
  17290. */
  17291. private static renderUnsorted;
  17292. /**
  17293. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17294. * are rendered back to front if in the same alpha index.
  17295. *
  17296. * @param a The first submesh
  17297. * @param b The second submesh
  17298. * @returns The result of the comparison
  17299. */
  17300. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17301. /**
  17302. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17303. * are rendered back to front.
  17304. *
  17305. * @param a The first submesh
  17306. * @param b The second submesh
  17307. * @returns The result of the comparison
  17308. */
  17309. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17310. /**
  17311. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17312. * are rendered front to back (prevent overdraw).
  17313. *
  17314. * @param a The first submesh
  17315. * @param b The second submesh
  17316. * @returns The result of the comparison
  17317. */
  17318. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17319. /**
  17320. * Resets the different lists of submeshes to prepare a new frame.
  17321. */
  17322. prepare(): void;
  17323. dispose(): void;
  17324. /**
  17325. * Inserts the submesh in its correct queue depending on its material.
  17326. * @param subMesh The submesh to dispatch
  17327. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17328. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17329. */
  17330. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17331. dispatchSprites(spriteManager: ISpriteManager): void;
  17332. dispatchParticles(particleSystem: IParticleSystem): void;
  17333. private _renderParticles;
  17334. private _renderSprites;
  17335. }
  17336. }
  17337. declare module BABYLON {
  17338. /**
  17339. * Interface describing the different options available in the rendering manager
  17340. * regarding Auto Clear between groups.
  17341. */
  17342. export interface IRenderingManagerAutoClearSetup {
  17343. /**
  17344. * Defines whether or not autoclear is enable.
  17345. */
  17346. autoClear: boolean;
  17347. /**
  17348. * Defines whether or not to autoclear the depth buffer.
  17349. */
  17350. depth: boolean;
  17351. /**
  17352. * Defines whether or not to autoclear the stencil buffer.
  17353. */
  17354. stencil: boolean;
  17355. }
  17356. /**
  17357. * This class is used by the onRenderingGroupObservable
  17358. */
  17359. export class RenderingGroupInfo {
  17360. /**
  17361. * The Scene that being rendered
  17362. */
  17363. scene: Scene;
  17364. /**
  17365. * The camera currently used for the rendering pass
  17366. */
  17367. camera: Nullable<Camera>;
  17368. /**
  17369. * The ID of the renderingGroup being processed
  17370. */
  17371. renderingGroupId: number;
  17372. }
  17373. /**
  17374. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17375. * It is enable to manage the different groups as well as the different necessary sort functions.
  17376. * This should not be used directly aside of the few static configurations
  17377. */
  17378. export class RenderingManager {
  17379. /**
  17380. * The max id used for rendering groups (not included)
  17381. */
  17382. static MAX_RENDERINGGROUPS: number;
  17383. /**
  17384. * The min id used for rendering groups (included)
  17385. */
  17386. static MIN_RENDERINGGROUPS: number;
  17387. /**
  17388. * Used to globally prevent autoclearing scenes.
  17389. */
  17390. static AUTOCLEAR: boolean;
  17391. /**
  17392. * @hidden
  17393. */
  17394. _useSceneAutoClearSetup: boolean;
  17395. private _scene;
  17396. private _renderingGroups;
  17397. private _depthStencilBufferAlreadyCleaned;
  17398. private _autoClearDepthStencil;
  17399. private _customOpaqueSortCompareFn;
  17400. private _customAlphaTestSortCompareFn;
  17401. private _customTransparentSortCompareFn;
  17402. private _renderingGroupInfo;
  17403. /**
  17404. * Instantiates a new rendering group for a particular scene
  17405. * @param scene Defines the scene the groups belongs to
  17406. */
  17407. constructor(scene: Scene);
  17408. private _clearDepthStencilBuffer;
  17409. /**
  17410. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17411. * @hidden
  17412. */
  17413. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17414. /**
  17415. * Resets the different information of the group to prepare a new frame
  17416. * @hidden
  17417. */
  17418. reset(): void;
  17419. /**
  17420. * Dispose and release the group and its associated resources.
  17421. * @hidden
  17422. */
  17423. dispose(): void;
  17424. /**
  17425. * Clear the info related to rendering groups preventing retention points during dispose.
  17426. */
  17427. freeRenderingGroups(): void;
  17428. private _prepareRenderingGroup;
  17429. /**
  17430. * Add a sprite manager to the rendering manager in order to render it this frame.
  17431. * @param spriteManager Define the sprite manager to render
  17432. */
  17433. dispatchSprites(spriteManager: ISpriteManager): void;
  17434. /**
  17435. * Add a particle system to the rendering manager in order to render it this frame.
  17436. * @param particleSystem Define the particle system to render
  17437. */
  17438. dispatchParticles(particleSystem: IParticleSystem): void;
  17439. /**
  17440. * Add a submesh to the manager in order to render it this frame
  17441. * @param subMesh The submesh to dispatch
  17442. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17443. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17444. */
  17445. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17446. /**
  17447. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17448. * This allowed control for front to back rendering or reversly depending of the special needs.
  17449. *
  17450. * @param renderingGroupId The rendering group id corresponding to its index
  17451. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17452. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17453. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17454. */
  17455. 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;
  17456. /**
  17457. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17458. *
  17459. * @param renderingGroupId The rendering group id corresponding to its index
  17460. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17461. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17462. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17463. */
  17464. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17465. /**
  17466. * Gets the current auto clear configuration for one rendering group of the rendering
  17467. * manager.
  17468. * @param index the rendering group index to get the information for
  17469. * @returns The auto clear setup for the requested rendering group
  17470. */
  17471. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17472. }
  17473. }
  17474. declare module BABYLON {
  17475. /**
  17476. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17477. */
  17478. export interface ICustomShaderOptions {
  17479. /**
  17480. * Gets or sets the custom shader name to use
  17481. */
  17482. shaderName: string;
  17483. /**
  17484. * The list of attribute names used in the shader
  17485. */
  17486. attributes?: string[];
  17487. /**
  17488. * The list of unifrom names used in the shader
  17489. */
  17490. uniforms?: string[];
  17491. /**
  17492. * The list of sampler names used in the shader
  17493. */
  17494. samplers?: string[];
  17495. /**
  17496. * The list of defines used in the shader
  17497. */
  17498. defines?: string[];
  17499. }
  17500. /**
  17501. * Interface to implement to create a shadow generator compatible with BJS.
  17502. */
  17503. export interface IShadowGenerator {
  17504. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17505. id: string;
  17506. /**
  17507. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17508. * @returns The render target texture if present otherwise, null
  17509. */
  17510. getShadowMap(): Nullable<RenderTargetTexture>;
  17511. /**
  17512. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17513. * @param subMesh The submesh we want to render in the shadow map
  17514. * @param useInstances Defines wether will draw in the map using instances
  17515. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17516. * @returns true if ready otherwise, false
  17517. */
  17518. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17519. /**
  17520. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17521. * @param defines Defines of the material we want to update
  17522. * @param lightIndex Index of the light in the enabled light list of the material
  17523. */
  17524. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17525. /**
  17526. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17527. * defined in the generator but impacting the effect).
  17528. * It implies the unifroms available on the materials are the standard BJS ones.
  17529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17530. * @param effect The effect we are binfing the information for
  17531. */
  17532. bindShadowLight(lightIndex: string, effect: Effect): void;
  17533. /**
  17534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17535. * (eq to shadow prjection matrix * light transform matrix)
  17536. * @returns The transform matrix used to create the shadow map
  17537. */
  17538. getTransformMatrix(): Matrix;
  17539. /**
  17540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17541. * Cube and 2D textures for instance.
  17542. */
  17543. recreateShadowMap(): void;
  17544. /**
  17545. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17546. * @param onCompiled Callback triggered at the and of the effects compilation
  17547. * @param options Sets of optional options forcing the compilation with different modes
  17548. */
  17549. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17550. useInstances: boolean;
  17551. }>): void;
  17552. /**
  17553. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17554. * @param options Sets of optional options forcing the compilation with different modes
  17555. * @returns A promise that resolves when the compilation completes
  17556. */
  17557. forceCompilationAsync(options?: Partial<{
  17558. useInstances: boolean;
  17559. }>): Promise<void>;
  17560. /**
  17561. * Serializes the shadow generator setup to a json object.
  17562. * @returns The serialized JSON object
  17563. */
  17564. serialize(): any;
  17565. /**
  17566. * Disposes the Shadow map and related Textures and effects.
  17567. */
  17568. dispose(): void;
  17569. }
  17570. /**
  17571. * Default implementation IShadowGenerator.
  17572. * This is the main object responsible of generating shadows in the framework.
  17573. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17574. */
  17575. export class ShadowGenerator implements IShadowGenerator {
  17576. /**
  17577. * Name of the shadow generator class
  17578. */
  17579. static CLASSNAME: string;
  17580. /**
  17581. * Shadow generator mode None: no filtering applied.
  17582. */
  17583. static readonly FILTER_NONE: number;
  17584. /**
  17585. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17586. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17587. */
  17588. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17589. /**
  17590. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17591. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17592. */
  17593. static readonly FILTER_POISSONSAMPLING: number;
  17594. /**
  17595. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17596. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17597. */
  17598. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17599. /**
  17600. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17601. * edge artifacts on steep falloff.
  17602. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17603. */
  17604. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17605. /**
  17606. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17607. * edge artifacts on steep falloff.
  17608. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17609. */
  17610. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17611. /**
  17612. * Shadow generator mode PCF: Percentage Closer Filtering
  17613. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17614. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17615. */
  17616. static readonly FILTER_PCF: number;
  17617. /**
  17618. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17619. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17620. * Contact Hardening
  17621. */
  17622. static readonly FILTER_PCSS: number;
  17623. /**
  17624. * Reserved for PCF and PCSS
  17625. * Highest Quality.
  17626. *
  17627. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17628. *
  17629. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17630. */
  17631. static readonly QUALITY_HIGH: number;
  17632. /**
  17633. * Reserved for PCF and PCSS
  17634. * Good tradeoff for quality/perf cross devices
  17635. *
  17636. * Execute PCF on a 3*3 kernel.
  17637. *
  17638. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17639. */
  17640. static readonly QUALITY_MEDIUM: number;
  17641. /**
  17642. * Reserved for PCF and PCSS
  17643. * The lowest quality but the fastest.
  17644. *
  17645. * Execute PCF on a 1*1 kernel.
  17646. *
  17647. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17648. */
  17649. static readonly QUALITY_LOW: number;
  17650. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17651. id: string;
  17652. /** Gets or sets the custom shader name to use */
  17653. customShaderOptions: ICustomShaderOptions;
  17654. /**
  17655. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17656. */
  17657. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17658. /**
  17659. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17660. */
  17661. onAfterShadowMapRenderObservable: Observable<Effect>;
  17662. /**
  17663. * Observable triggered before a mesh is rendered in the shadow map.
  17664. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17665. */
  17666. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17667. /**
  17668. * Observable triggered after a mesh is rendered in the shadow map.
  17669. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17670. */
  17671. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17672. protected _bias: number;
  17673. /**
  17674. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17675. */
  17676. get bias(): number;
  17677. /**
  17678. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17679. */
  17680. set bias(bias: number);
  17681. protected _normalBias: number;
  17682. /**
  17683. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17684. */
  17685. get normalBias(): number;
  17686. /**
  17687. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17688. */
  17689. set normalBias(normalBias: number);
  17690. protected _blurBoxOffset: number;
  17691. /**
  17692. * Gets the blur box offset: offset applied during the blur pass.
  17693. * Only useful if useKernelBlur = false
  17694. */
  17695. get blurBoxOffset(): number;
  17696. /**
  17697. * Sets the blur box offset: offset applied during the blur pass.
  17698. * Only useful if useKernelBlur = false
  17699. */
  17700. set blurBoxOffset(value: number);
  17701. protected _blurScale: number;
  17702. /**
  17703. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17704. * 2 means half of the size.
  17705. */
  17706. get blurScale(): number;
  17707. /**
  17708. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17709. * 2 means half of the size.
  17710. */
  17711. set blurScale(value: number);
  17712. protected _blurKernel: number;
  17713. /**
  17714. * Gets the blur kernel: kernel size of the blur pass.
  17715. * Only useful if useKernelBlur = true
  17716. */
  17717. get blurKernel(): number;
  17718. /**
  17719. * Sets the blur kernel: kernel size of the blur pass.
  17720. * Only useful if useKernelBlur = true
  17721. */
  17722. set blurKernel(value: number);
  17723. protected _useKernelBlur: boolean;
  17724. /**
  17725. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17726. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17727. */
  17728. get useKernelBlur(): boolean;
  17729. /**
  17730. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17731. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17732. */
  17733. set useKernelBlur(value: boolean);
  17734. protected _depthScale: number;
  17735. /**
  17736. * Gets the depth scale used in ESM mode.
  17737. */
  17738. get depthScale(): number;
  17739. /**
  17740. * Sets the depth scale used in ESM mode.
  17741. * This can override the scale stored on the light.
  17742. */
  17743. set depthScale(value: number);
  17744. protected _validateFilter(filter: number): number;
  17745. protected _filter: number;
  17746. /**
  17747. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17748. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17749. */
  17750. get filter(): number;
  17751. /**
  17752. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17753. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17754. */
  17755. set filter(value: number);
  17756. /**
  17757. * Gets if the current filter is set to Poisson Sampling.
  17758. */
  17759. get usePoissonSampling(): boolean;
  17760. /**
  17761. * Sets the current filter to Poisson Sampling.
  17762. */
  17763. set usePoissonSampling(value: boolean);
  17764. /**
  17765. * Gets if the current filter is set to ESM.
  17766. */
  17767. get useExponentialShadowMap(): boolean;
  17768. /**
  17769. * Sets the current filter is to ESM.
  17770. */
  17771. set useExponentialShadowMap(value: boolean);
  17772. /**
  17773. * Gets if the current filter is set to filtered ESM.
  17774. */
  17775. get useBlurExponentialShadowMap(): boolean;
  17776. /**
  17777. * Gets if the current filter is set to filtered ESM.
  17778. */
  17779. set useBlurExponentialShadowMap(value: boolean);
  17780. /**
  17781. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17782. * exponential to prevent steep falloff artifacts).
  17783. */
  17784. get useCloseExponentialShadowMap(): boolean;
  17785. /**
  17786. * Sets the current filter to "close ESM" (using the inverse of the
  17787. * exponential to prevent steep falloff artifacts).
  17788. */
  17789. set useCloseExponentialShadowMap(value: boolean);
  17790. /**
  17791. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17792. * exponential to prevent steep falloff artifacts).
  17793. */
  17794. get useBlurCloseExponentialShadowMap(): boolean;
  17795. /**
  17796. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17797. * exponential to prevent steep falloff artifacts).
  17798. */
  17799. set useBlurCloseExponentialShadowMap(value: boolean);
  17800. /**
  17801. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17802. */
  17803. get usePercentageCloserFiltering(): boolean;
  17804. /**
  17805. * Sets the current filter to "PCF" (percentage closer filtering).
  17806. */
  17807. set usePercentageCloserFiltering(value: boolean);
  17808. protected _filteringQuality: number;
  17809. /**
  17810. * Gets the PCF or PCSS Quality.
  17811. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17812. */
  17813. get filteringQuality(): number;
  17814. /**
  17815. * Sets the PCF or PCSS Quality.
  17816. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17817. */
  17818. set filteringQuality(filteringQuality: number);
  17819. /**
  17820. * Gets if the current filter is set to "PCSS" (contact hardening).
  17821. */
  17822. get useContactHardeningShadow(): boolean;
  17823. /**
  17824. * Sets the current filter to "PCSS" (contact hardening).
  17825. */
  17826. set useContactHardeningShadow(value: boolean);
  17827. protected _contactHardeningLightSizeUVRatio: number;
  17828. /**
  17829. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17830. * Using a ratio helps keeping shape stability independently of the map size.
  17831. *
  17832. * It does not account for the light projection as it was having too much
  17833. * instability during the light setup or during light position changes.
  17834. *
  17835. * Only valid if useContactHardeningShadow is true.
  17836. */
  17837. get contactHardeningLightSizeUVRatio(): number;
  17838. /**
  17839. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17840. * Using a ratio helps keeping shape stability independently of the map size.
  17841. *
  17842. * It does not account for the light projection as it was having too much
  17843. * instability during the light setup or during light position changes.
  17844. *
  17845. * Only valid if useContactHardeningShadow is true.
  17846. */
  17847. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17848. protected _darkness: number;
  17849. /** Gets or sets the actual darkness of a shadow */
  17850. get darkness(): number;
  17851. set darkness(value: number);
  17852. /**
  17853. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17854. * 0 means strongest and 1 would means no shadow.
  17855. * @returns the darkness.
  17856. */
  17857. getDarkness(): number;
  17858. /**
  17859. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17860. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17861. * @returns the shadow generator allowing fluent coding.
  17862. */
  17863. setDarkness(darkness: number): ShadowGenerator;
  17864. protected _transparencyShadow: boolean;
  17865. /** Gets or sets the ability to have transparent shadow */
  17866. get transparencyShadow(): boolean;
  17867. set transparencyShadow(value: boolean);
  17868. /**
  17869. * Sets the ability to have transparent shadow (boolean).
  17870. * @param transparent True if transparent else False
  17871. * @returns the shadow generator allowing fluent coding
  17872. */
  17873. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17874. /**
  17875. * Enables or disables shadows with varying strength based on the transparency
  17876. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17877. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17878. * mesh.visibility * alphaTexture.a
  17879. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17880. */
  17881. enableSoftTransparentShadow: boolean;
  17882. protected _shadowMap: Nullable<RenderTargetTexture>;
  17883. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17884. /**
  17885. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17886. * @returns The render target texture if present otherwise, null
  17887. */
  17888. getShadowMap(): Nullable<RenderTargetTexture>;
  17889. /**
  17890. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17891. * @returns The render target texture if the shadow map is present otherwise, null
  17892. */
  17893. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17894. /**
  17895. * Gets the class name of that object
  17896. * @returns "ShadowGenerator"
  17897. */
  17898. getClassName(): string;
  17899. /**
  17900. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17901. * @param mesh Mesh to add
  17902. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17903. * @returns the Shadow Generator itself
  17904. */
  17905. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17906. /**
  17907. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17908. * @param mesh Mesh to remove
  17909. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17910. * @returns the Shadow Generator itself
  17911. */
  17912. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17913. /**
  17914. * Controls the extent to which the shadows fade out at the edge of the frustum
  17915. */
  17916. frustumEdgeFalloff: number;
  17917. protected _light: IShadowLight;
  17918. /**
  17919. * Returns the associated light object.
  17920. * @returns the light generating the shadow
  17921. */
  17922. getLight(): IShadowLight;
  17923. /**
  17924. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17925. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17926. * It might on the other hand introduce peter panning.
  17927. */
  17928. forceBackFacesOnly: boolean;
  17929. protected _scene: Scene;
  17930. protected _lightDirection: Vector3;
  17931. protected _effect: Effect;
  17932. protected _viewMatrix: Matrix;
  17933. protected _projectionMatrix: Matrix;
  17934. protected _transformMatrix: Matrix;
  17935. protected _cachedPosition: Vector3;
  17936. protected _cachedDirection: Vector3;
  17937. protected _cachedDefines: string;
  17938. protected _currentRenderID: number;
  17939. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17940. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17941. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17942. protected _blurPostProcesses: PostProcess[];
  17943. protected _mapSize: number;
  17944. protected _currentFaceIndex: number;
  17945. protected _currentFaceIndexCache: number;
  17946. protected _textureType: number;
  17947. protected _defaultTextureMatrix: Matrix;
  17948. protected _storedUniqueId: Nullable<number>;
  17949. /** @hidden */
  17950. static _SceneComponentInitialization: (scene: Scene) => void;
  17951. /**
  17952. * Creates a ShadowGenerator object.
  17953. * A ShadowGenerator is the required tool to use the shadows.
  17954. * Each light casting shadows needs to use its own ShadowGenerator.
  17955. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17956. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17957. * @param light The light object generating the shadows.
  17958. * @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.
  17959. */
  17960. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17961. protected _initializeGenerator(): void;
  17962. protected _createTargetRenderTexture(): void;
  17963. protected _initializeShadowMap(): void;
  17964. protected _initializeBlurRTTAndPostProcesses(): void;
  17965. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17966. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17967. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17968. protected _applyFilterValues(): void;
  17969. /**
  17970. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17971. * @param onCompiled Callback triggered at the and of the effects compilation
  17972. * @param options Sets of optional options forcing the compilation with different modes
  17973. */
  17974. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17975. useInstances: boolean;
  17976. }>): void;
  17977. /**
  17978. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17979. * @param options Sets of optional options forcing the compilation with different modes
  17980. * @returns A promise that resolves when the compilation completes
  17981. */
  17982. forceCompilationAsync(options?: Partial<{
  17983. useInstances: boolean;
  17984. }>): Promise<void>;
  17985. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17986. private _prepareShadowDefines;
  17987. /**
  17988. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17989. * @param subMesh The submesh we want to render in the shadow map
  17990. * @param useInstances Defines wether will draw in the map using instances
  17991. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17992. * @returns true if ready otherwise, false
  17993. */
  17994. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17995. /**
  17996. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17997. * @param defines Defines of the material we want to update
  17998. * @param lightIndex Index of the light in the enabled light list of the material
  17999. */
  18000. prepareDefines(defines: any, lightIndex: number): void;
  18001. /**
  18002. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18003. * defined in the generator but impacting the effect).
  18004. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18005. * @param effect The effect we are binfing the information for
  18006. */
  18007. bindShadowLight(lightIndex: string, effect: Effect): void;
  18008. /**
  18009. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18010. * (eq to shadow prjection matrix * light transform matrix)
  18011. * @returns The transform matrix used to create the shadow map
  18012. */
  18013. getTransformMatrix(): Matrix;
  18014. /**
  18015. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18016. * Cube and 2D textures for instance.
  18017. */
  18018. recreateShadowMap(): void;
  18019. protected _disposeBlurPostProcesses(): void;
  18020. protected _disposeRTTandPostProcesses(): void;
  18021. /**
  18022. * Disposes the ShadowGenerator.
  18023. * Returns nothing.
  18024. */
  18025. dispose(): void;
  18026. /**
  18027. * Serializes the shadow generator setup to a json object.
  18028. * @returns The serialized JSON object
  18029. */
  18030. serialize(): any;
  18031. /**
  18032. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18033. * @param parsedShadowGenerator The JSON object to parse
  18034. * @param scene The scene to create the shadow map for
  18035. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18036. * @returns The parsed shadow generator
  18037. */
  18038. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18039. }
  18040. }
  18041. declare module BABYLON {
  18042. /**
  18043. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18044. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18045. * 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.
  18046. */
  18047. export abstract class Light extends Node {
  18048. /**
  18049. * Falloff Default: light is falling off following the material specification:
  18050. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18051. */
  18052. static readonly FALLOFF_DEFAULT: number;
  18053. /**
  18054. * Falloff Physical: light is falling off following the inverse squared distance law.
  18055. */
  18056. static readonly FALLOFF_PHYSICAL: number;
  18057. /**
  18058. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18059. * to enhance interoperability with other engines.
  18060. */
  18061. static readonly FALLOFF_GLTF: number;
  18062. /**
  18063. * Falloff Standard: light is falling off like in the standard material
  18064. * to enhance interoperability with other materials.
  18065. */
  18066. static readonly FALLOFF_STANDARD: number;
  18067. /**
  18068. * If every light affecting the material is in this lightmapMode,
  18069. * material.lightmapTexture adds or multiplies
  18070. * (depends on material.useLightmapAsShadowmap)
  18071. * after every other light calculations.
  18072. */
  18073. static readonly LIGHTMAP_DEFAULT: number;
  18074. /**
  18075. * material.lightmapTexture as only diffuse lighting from this light
  18076. * adds only specular lighting from this light
  18077. * adds dynamic shadows
  18078. */
  18079. static readonly LIGHTMAP_SPECULAR: number;
  18080. /**
  18081. * material.lightmapTexture as only lighting
  18082. * no light calculation from this light
  18083. * only adds dynamic shadows from this light
  18084. */
  18085. static readonly LIGHTMAP_SHADOWSONLY: number;
  18086. /**
  18087. * Each light type uses the default quantity according to its type:
  18088. * point/spot lights use luminous intensity
  18089. * directional lights use illuminance
  18090. */
  18091. static readonly INTENSITYMODE_AUTOMATIC: number;
  18092. /**
  18093. * lumen (lm)
  18094. */
  18095. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18096. /**
  18097. * candela (lm/sr)
  18098. */
  18099. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18100. /**
  18101. * lux (lm/m^2)
  18102. */
  18103. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18104. /**
  18105. * nit (cd/m^2)
  18106. */
  18107. static readonly INTENSITYMODE_LUMINANCE: number;
  18108. /**
  18109. * Light type const id of the point light.
  18110. */
  18111. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18112. /**
  18113. * Light type const id of the directional light.
  18114. */
  18115. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18116. /**
  18117. * Light type const id of the spot light.
  18118. */
  18119. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18120. /**
  18121. * Light type const id of the hemispheric light.
  18122. */
  18123. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18124. /**
  18125. * Diffuse gives the basic color to an object.
  18126. */
  18127. diffuse: Color3;
  18128. /**
  18129. * Specular produces a highlight color on an object.
  18130. * Note: This is note affecting PBR materials.
  18131. */
  18132. specular: Color3;
  18133. /**
  18134. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18135. * falling off base on range or angle.
  18136. * This can be set to any values in Light.FALLOFF_x.
  18137. *
  18138. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18139. * other types of materials.
  18140. */
  18141. falloffType: number;
  18142. /**
  18143. * Strength of the light.
  18144. * Note: By default it is define in the framework own unit.
  18145. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18146. */
  18147. intensity: number;
  18148. private _range;
  18149. protected _inverseSquaredRange: number;
  18150. /**
  18151. * Defines how far from the source the light is impacting in scene units.
  18152. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18153. */
  18154. get range(): number;
  18155. /**
  18156. * Defines how far from the source the light is impacting in scene units.
  18157. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18158. */
  18159. set range(value: number);
  18160. /**
  18161. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18162. * of light.
  18163. */
  18164. private _photometricScale;
  18165. private _intensityMode;
  18166. /**
  18167. * Gets the photometric scale used to interpret the intensity.
  18168. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18169. */
  18170. get intensityMode(): number;
  18171. /**
  18172. * Sets the photometric scale used to interpret the intensity.
  18173. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18174. */
  18175. set intensityMode(value: number);
  18176. private _radius;
  18177. /**
  18178. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18179. */
  18180. get radius(): number;
  18181. /**
  18182. * sets the light radius used by PBR Materials to simulate soft area lights.
  18183. */
  18184. set radius(value: number);
  18185. private _renderPriority;
  18186. /**
  18187. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18188. * exceeding the number allowed of the materials.
  18189. */
  18190. renderPriority: number;
  18191. private _shadowEnabled;
  18192. /**
  18193. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18194. * the current shadow generator.
  18195. */
  18196. get shadowEnabled(): boolean;
  18197. /**
  18198. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18199. * the current shadow generator.
  18200. */
  18201. set shadowEnabled(value: boolean);
  18202. private _includedOnlyMeshes;
  18203. /**
  18204. * Gets the only meshes impacted by this light.
  18205. */
  18206. get includedOnlyMeshes(): AbstractMesh[];
  18207. /**
  18208. * Sets the only meshes impacted by this light.
  18209. */
  18210. set includedOnlyMeshes(value: AbstractMesh[]);
  18211. private _excludedMeshes;
  18212. /**
  18213. * Gets the meshes not impacted by this light.
  18214. */
  18215. get excludedMeshes(): AbstractMesh[];
  18216. /**
  18217. * Sets the meshes not impacted by this light.
  18218. */
  18219. set excludedMeshes(value: AbstractMesh[]);
  18220. private _excludeWithLayerMask;
  18221. /**
  18222. * Gets the layer id use to find what meshes are not impacted by the light.
  18223. * Inactive if 0
  18224. */
  18225. get excludeWithLayerMask(): number;
  18226. /**
  18227. * Sets the layer id use to find what meshes are not impacted by the light.
  18228. * Inactive if 0
  18229. */
  18230. set excludeWithLayerMask(value: number);
  18231. private _includeOnlyWithLayerMask;
  18232. /**
  18233. * Gets the layer id use to find what meshes are impacted by the light.
  18234. * Inactive if 0
  18235. */
  18236. get includeOnlyWithLayerMask(): number;
  18237. /**
  18238. * Sets the layer id use to find what meshes are impacted by the light.
  18239. * Inactive if 0
  18240. */
  18241. set includeOnlyWithLayerMask(value: number);
  18242. private _lightmapMode;
  18243. /**
  18244. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18245. */
  18246. get lightmapMode(): number;
  18247. /**
  18248. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18249. */
  18250. set lightmapMode(value: number);
  18251. /**
  18252. * Shadow generator associted to the light.
  18253. * @hidden Internal use only.
  18254. */
  18255. _shadowGenerator: Nullable<IShadowGenerator>;
  18256. /**
  18257. * @hidden Internal use only.
  18258. */
  18259. _excludedMeshesIds: string[];
  18260. /**
  18261. * @hidden Internal use only.
  18262. */
  18263. _includedOnlyMeshesIds: string[];
  18264. /**
  18265. * The current light unifom buffer.
  18266. * @hidden Internal use only.
  18267. */
  18268. _uniformBuffer: UniformBuffer;
  18269. /** @hidden */
  18270. _renderId: number;
  18271. /**
  18272. * Creates a Light object in the scene.
  18273. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18274. * @param name The firendly name of the light
  18275. * @param scene The scene the light belongs too
  18276. */
  18277. constructor(name: string, scene: Scene);
  18278. protected abstract _buildUniformLayout(): void;
  18279. /**
  18280. * Sets the passed Effect "effect" with the Light information.
  18281. * @param effect The effect to update
  18282. * @param lightIndex The index of the light in the effect to update
  18283. * @returns The light
  18284. */
  18285. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18286. /**
  18287. * Sets the passed Effect "effect" with the Light textures.
  18288. * @param effect The effect to update
  18289. * @param lightIndex The index of the light in the effect to update
  18290. * @returns The light
  18291. */
  18292. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18293. /**
  18294. * Binds the lights information from the scene to the effect for the given mesh.
  18295. * @param lightIndex Light index
  18296. * @param scene The scene where the light belongs to
  18297. * @param effect The effect we are binding the data to
  18298. * @param useSpecular Defines if specular is supported
  18299. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18300. */
  18301. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18302. /**
  18303. * Sets the passed Effect "effect" with the Light information.
  18304. * @param effect The effect to update
  18305. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18306. * @returns The light
  18307. */
  18308. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18309. /**
  18310. * Returns the string "Light".
  18311. * @returns the class name
  18312. */
  18313. getClassName(): string;
  18314. /** @hidden */
  18315. readonly _isLight: boolean;
  18316. /**
  18317. * Converts the light information to a readable string for debug purpose.
  18318. * @param fullDetails Supports for multiple levels of logging within scene loading
  18319. * @returns the human readable light info
  18320. */
  18321. toString(fullDetails?: boolean): string;
  18322. /** @hidden */
  18323. protected _syncParentEnabledState(): void;
  18324. /**
  18325. * Set the enabled state of this node.
  18326. * @param value - the new enabled state
  18327. */
  18328. setEnabled(value: boolean): void;
  18329. /**
  18330. * Returns the Light associated shadow generator if any.
  18331. * @return the associated shadow generator.
  18332. */
  18333. getShadowGenerator(): Nullable<IShadowGenerator>;
  18334. /**
  18335. * Returns a Vector3, the absolute light position in the World.
  18336. * @returns the world space position of the light
  18337. */
  18338. getAbsolutePosition(): Vector3;
  18339. /**
  18340. * Specifies if the light will affect the passed mesh.
  18341. * @param mesh The mesh to test against the light
  18342. * @return true the mesh is affected otherwise, false.
  18343. */
  18344. canAffectMesh(mesh: AbstractMesh): boolean;
  18345. /**
  18346. * Sort function to order lights for rendering.
  18347. * @param a First Light object to compare to second.
  18348. * @param b Second Light object to compare first.
  18349. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18350. */
  18351. static CompareLightsPriority(a: Light, b: Light): number;
  18352. /**
  18353. * Releases resources associated with this node.
  18354. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18355. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18356. */
  18357. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18358. /**
  18359. * Returns the light type ID (integer).
  18360. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18361. */
  18362. getTypeID(): number;
  18363. /**
  18364. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18365. * @returns the scaled intensity in intensity mode unit
  18366. */
  18367. getScaledIntensity(): number;
  18368. /**
  18369. * Returns a new Light object, named "name", from the current one.
  18370. * @param name The name of the cloned light
  18371. * @param newParent The parent of this light, if it has one
  18372. * @returns the new created light
  18373. */
  18374. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18375. /**
  18376. * Serializes the current light into a Serialization object.
  18377. * @returns the serialized object.
  18378. */
  18379. serialize(): any;
  18380. /**
  18381. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18382. * This new light is named "name" and added to the passed scene.
  18383. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18384. * @param name The friendly name of the light
  18385. * @param scene The scene the new light will belong to
  18386. * @returns the constructor function
  18387. */
  18388. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18389. /**
  18390. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18391. * @param parsedLight The JSON representation of the light
  18392. * @param scene The scene to create the parsed light in
  18393. * @returns the created light after parsing
  18394. */
  18395. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18396. private _hookArrayForExcluded;
  18397. private _hookArrayForIncludedOnly;
  18398. private _resyncMeshes;
  18399. /**
  18400. * Forces the meshes to update their light related information in their rendering used effects
  18401. * @hidden Internal Use Only
  18402. */
  18403. _markMeshesAsLightDirty(): void;
  18404. /**
  18405. * Recomputes the cached photometric scale if needed.
  18406. */
  18407. private _computePhotometricScale;
  18408. /**
  18409. * Returns the Photometric Scale according to the light type and intensity mode.
  18410. */
  18411. private _getPhotometricScale;
  18412. /**
  18413. * Reorder the light in the scene according to their defined priority.
  18414. * @hidden Internal Use Only
  18415. */
  18416. _reorderLightsInScene(): void;
  18417. /**
  18418. * Prepares the list of defines specific to the light type.
  18419. * @param defines the list of defines
  18420. * @param lightIndex defines the index of the light for the effect
  18421. */
  18422. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18423. }
  18424. }
  18425. declare module BABYLON {
  18426. /**
  18427. * Configuration needed for prepass-capable materials
  18428. */
  18429. export class PrePassConfiguration {
  18430. /**
  18431. * Previous world matrices of meshes carrying this material
  18432. * Used for computing velocity
  18433. */
  18434. previousWorldMatrices: {
  18435. [index: number]: Matrix;
  18436. };
  18437. /**
  18438. * Previous view project matrix
  18439. * Used for computing velocity
  18440. */
  18441. previousViewProjection: Matrix;
  18442. /**
  18443. * Previous bones of meshes carrying this material
  18444. * Used for computing velocity
  18445. */
  18446. previousBones: {
  18447. [index: number]: Float32Array;
  18448. };
  18449. /**
  18450. * Add the required uniforms to the current list.
  18451. * @param uniforms defines the current uniform list.
  18452. */
  18453. static AddUniforms(uniforms: string[]): void;
  18454. /**
  18455. * Add the required samplers to the current list.
  18456. * @param samplers defines the current sampler list.
  18457. */
  18458. static AddSamplers(samplers: string[]): void;
  18459. /**
  18460. * Binds the material data.
  18461. * @param effect defines the effect to update
  18462. * @param scene defines the scene the material belongs to.
  18463. * @param mesh The mesh
  18464. * @param world World matrix of this mesh
  18465. * @param isFrozen Is the material frozen
  18466. */
  18467. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18468. }
  18469. }
  18470. declare module BABYLON {
  18471. /**
  18472. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18473. * This is the base of the follow, arc rotate cameras and Free camera
  18474. * @see https://doc.babylonjs.com/features/cameras
  18475. */
  18476. export class TargetCamera extends Camera {
  18477. private static _RigCamTransformMatrix;
  18478. private static _TargetTransformMatrix;
  18479. private static _TargetFocalPoint;
  18480. private _tmpUpVector;
  18481. private _tmpTargetVector;
  18482. /**
  18483. * Define the current direction the camera is moving to
  18484. */
  18485. cameraDirection: Vector3;
  18486. /**
  18487. * Define the current rotation the camera is rotating to
  18488. */
  18489. cameraRotation: Vector2;
  18490. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18491. ignoreParentScaling: boolean;
  18492. /**
  18493. * When set, the up vector of the camera will be updated by the rotation of the camera
  18494. */
  18495. updateUpVectorFromRotation: boolean;
  18496. private _tmpQuaternion;
  18497. /**
  18498. * Define the current rotation of the camera
  18499. */
  18500. rotation: Vector3;
  18501. /**
  18502. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18503. */
  18504. rotationQuaternion: Quaternion;
  18505. /**
  18506. * Define the current speed of the camera
  18507. */
  18508. speed: number;
  18509. /**
  18510. * Add constraint to the camera to prevent it to move freely in all directions and
  18511. * around all axis.
  18512. */
  18513. noRotationConstraint: boolean;
  18514. /**
  18515. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18516. * panning
  18517. */
  18518. invertRotation: boolean;
  18519. /**
  18520. * Speed multiplier for inverse camera panning
  18521. */
  18522. inverseRotationSpeed: number;
  18523. /**
  18524. * Define the current target of the camera as an object or a position.
  18525. */
  18526. lockedTarget: any;
  18527. /** @hidden */
  18528. _currentTarget: Vector3;
  18529. /** @hidden */
  18530. _initialFocalDistance: number;
  18531. /** @hidden */
  18532. _viewMatrix: Matrix;
  18533. /** @hidden */
  18534. _camMatrix: Matrix;
  18535. /** @hidden */
  18536. _cameraTransformMatrix: Matrix;
  18537. /** @hidden */
  18538. _cameraRotationMatrix: Matrix;
  18539. /** @hidden */
  18540. _referencePoint: Vector3;
  18541. /** @hidden */
  18542. _transformedReferencePoint: Vector3;
  18543. /** @hidden */
  18544. _reset: () => void;
  18545. private _defaultUp;
  18546. /**
  18547. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18548. * This is the base of the follow, arc rotate cameras and Free camera
  18549. * @see https://doc.babylonjs.com/features/cameras
  18550. * @param name Defines the name of the camera in the scene
  18551. * @param position Defines the start position of the camera in the scene
  18552. * @param scene Defines the scene the camera belongs to
  18553. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18554. */
  18555. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18556. /**
  18557. * Gets the position in front of the camera at a given distance.
  18558. * @param distance The distance from the camera we want the position to be
  18559. * @returns the position
  18560. */
  18561. getFrontPosition(distance: number): Vector3;
  18562. /** @hidden */
  18563. _getLockedTargetPosition(): Nullable<Vector3>;
  18564. private _storedPosition;
  18565. private _storedRotation;
  18566. private _storedRotationQuaternion;
  18567. /**
  18568. * Store current camera state of the camera (fov, position, rotation, etc..)
  18569. * @returns the camera
  18570. */
  18571. storeState(): Camera;
  18572. /**
  18573. * Restored camera state. You must call storeState() first
  18574. * @returns whether it was successful or not
  18575. * @hidden
  18576. */
  18577. _restoreStateValues(): boolean;
  18578. /** @hidden */
  18579. _initCache(): void;
  18580. /** @hidden */
  18581. _updateCache(ignoreParentClass?: boolean): void;
  18582. /** @hidden */
  18583. _isSynchronizedViewMatrix(): boolean;
  18584. /** @hidden */
  18585. _computeLocalCameraSpeed(): number;
  18586. /**
  18587. * Defines the target the camera should look at.
  18588. * @param target Defines the new target as a Vector or a mesh
  18589. */
  18590. setTarget(target: Vector3): void;
  18591. /**
  18592. * Defines the target point of the camera.
  18593. * The camera looks towards it form the radius distance.
  18594. */
  18595. get target(): Vector3;
  18596. set target(value: Vector3);
  18597. /**
  18598. * Return the current target position of the camera. This value is expressed in local space.
  18599. * @returns the target position
  18600. */
  18601. getTarget(): Vector3;
  18602. /** @hidden */
  18603. _decideIfNeedsToMove(): boolean;
  18604. /** @hidden */
  18605. _updatePosition(): void;
  18606. /** @hidden */
  18607. _checkInputs(): void;
  18608. protected _updateCameraRotationMatrix(): void;
  18609. /**
  18610. * 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)
  18611. * @returns the current camera
  18612. */
  18613. private _rotateUpVectorWithCameraRotationMatrix;
  18614. private _cachedRotationZ;
  18615. private _cachedQuaternionRotationZ;
  18616. /** @hidden */
  18617. _getViewMatrix(): Matrix;
  18618. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18619. /**
  18620. * @hidden
  18621. */
  18622. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18623. /**
  18624. * @hidden
  18625. */
  18626. _updateRigCameras(): void;
  18627. private _getRigCamPositionAndTarget;
  18628. /**
  18629. * Gets the current object class name.
  18630. * @return the class name
  18631. */
  18632. getClassName(): string;
  18633. }
  18634. }
  18635. declare module BABYLON {
  18636. /**
  18637. * Gather the list of keyboard event types as constants.
  18638. */
  18639. export class KeyboardEventTypes {
  18640. /**
  18641. * The keydown event is fired when a key becomes active (pressed).
  18642. */
  18643. static readonly KEYDOWN: number;
  18644. /**
  18645. * The keyup event is fired when a key has been released.
  18646. */
  18647. static readonly KEYUP: number;
  18648. }
  18649. /**
  18650. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18651. */
  18652. export class KeyboardInfo {
  18653. /**
  18654. * Defines the type of event (KeyboardEventTypes)
  18655. */
  18656. type: number;
  18657. /**
  18658. * Defines the related dom event
  18659. */
  18660. event: KeyboardEvent;
  18661. /**
  18662. * Instantiates a new keyboard info.
  18663. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18664. * @param type Defines the type of event (KeyboardEventTypes)
  18665. * @param event Defines the related dom event
  18666. */
  18667. constructor(
  18668. /**
  18669. * Defines the type of event (KeyboardEventTypes)
  18670. */
  18671. type: number,
  18672. /**
  18673. * Defines the related dom event
  18674. */
  18675. event: KeyboardEvent);
  18676. }
  18677. /**
  18678. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18679. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18680. */
  18681. export class KeyboardInfoPre extends KeyboardInfo {
  18682. /**
  18683. * Defines the type of event (KeyboardEventTypes)
  18684. */
  18685. type: number;
  18686. /**
  18687. * Defines the related dom event
  18688. */
  18689. event: KeyboardEvent;
  18690. /**
  18691. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18692. */
  18693. skipOnPointerObservable: boolean;
  18694. /**
  18695. * Instantiates a new keyboard pre info.
  18696. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18697. * @param type Defines the type of event (KeyboardEventTypes)
  18698. * @param event Defines the related dom event
  18699. */
  18700. constructor(
  18701. /**
  18702. * Defines the type of event (KeyboardEventTypes)
  18703. */
  18704. type: number,
  18705. /**
  18706. * Defines the related dom event
  18707. */
  18708. event: KeyboardEvent);
  18709. }
  18710. }
  18711. declare module BABYLON {
  18712. /**
  18713. * Manage the keyboard inputs to control the movement of a free camera.
  18714. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18715. */
  18716. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18717. /**
  18718. * Defines the camera the input is attached to.
  18719. */
  18720. camera: FreeCamera;
  18721. /**
  18722. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18723. */
  18724. keysUp: number[];
  18725. /**
  18726. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18727. */
  18728. keysUpward: number[];
  18729. /**
  18730. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18731. */
  18732. keysDown: number[];
  18733. /**
  18734. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18735. */
  18736. keysDownward: number[];
  18737. /**
  18738. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18739. */
  18740. keysLeft: number[];
  18741. /**
  18742. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18743. */
  18744. keysRight: number[];
  18745. private _keys;
  18746. private _onCanvasBlurObserver;
  18747. private _onKeyboardObserver;
  18748. private _engine;
  18749. private _scene;
  18750. /**
  18751. * Attach the input controls to a specific dom element to get the input from.
  18752. * @param element Defines the element the controls should be listened from
  18753. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18754. */
  18755. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18756. /**
  18757. * Detach the current controls from the specified dom element.
  18758. * @param element Defines the element to stop listening the inputs from
  18759. */
  18760. detachControl(element: Nullable<HTMLElement>): void;
  18761. /**
  18762. * Update the current camera state depending on the inputs that have been used this frame.
  18763. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18764. */
  18765. checkInputs(): void;
  18766. /**
  18767. * Gets the class name of the current intput.
  18768. * @returns the class name
  18769. */
  18770. getClassName(): string;
  18771. /** @hidden */
  18772. _onLostFocus(): void;
  18773. /**
  18774. * Get the friendly name associated with the input class.
  18775. * @returns the input friendly name
  18776. */
  18777. getSimpleName(): string;
  18778. }
  18779. }
  18780. declare module BABYLON {
  18781. /**
  18782. * Gather the list of pointer event types as constants.
  18783. */
  18784. export class PointerEventTypes {
  18785. /**
  18786. * 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.
  18787. */
  18788. static readonly POINTERDOWN: number;
  18789. /**
  18790. * The pointerup event is fired when a pointer is no longer active.
  18791. */
  18792. static readonly POINTERUP: number;
  18793. /**
  18794. * The pointermove event is fired when a pointer changes coordinates.
  18795. */
  18796. static readonly POINTERMOVE: number;
  18797. /**
  18798. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18799. */
  18800. static readonly POINTERWHEEL: number;
  18801. /**
  18802. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18803. */
  18804. static readonly POINTERPICK: number;
  18805. /**
  18806. * The pointertap event is fired when a the object has been touched and released without drag.
  18807. */
  18808. static readonly POINTERTAP: number;
  18809. /**
  18810. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18811. */
  18812. static readonly POINTERDOUBLETAP: number;
  18813. }
  18814. /**
  18815. * Base class of pointer info types.
  18816. */
  18817. export class PointerInfoBase {
  18818. /**
  18819. * Defines the type of event (PointerEventTypes)
  18820. */
  18821. type: number;
  18822. /**
  18823. * Defines the related dom event
  18824. */
  18825. event: PointerEvent | MouseWheelEvent;
  18826. /**
  18827. * Instantiates the base class of pointers info.
  18828. * @param type Defines the type of event (PointerEventTypes)
  18829. * @param event Defines the related dom event
  18830. */
  18831. constructor(
  18832. /**
  18833. * Defines the type of event (PointerEventTypes)
  18834. */
  18835. type: number,
  18836. /**
  18837. * Defines the related dom event
  18838. */
  18839. event: PointerEvent | MouseWheelEvent);
  18840. }
  18841. /**
  18842. * This class is used to store pointer related info for the onPrePointerObservable event.
  18843. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18844. */
  18845. export class PointerInfoPre extends PointerInfoBase {
  18846. /**
  18847. * Ray from a pointer if availible (eg. 6dof controller)
  18848. */
  18849. ray: Nullable<Ray>;
  18850. /**
  18851. * Defines the local position of the pointer on the canvas.
  18852. */
  18853. localPosition: Vector2;
  18854. /**
  18855. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18856. */
  18857. skipOnPointerObservable: boolean;
  18858. /**
  18859. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18860. * @param type Defines the type of event (PointerEventTypes)
  18861. * @param event Defines the related dom event
  18862. * @param localX Defines the local x coordinates of the pointer when the event occured
  18863. * @param localY Defines the local y coordinates of the pointer when the event occured
  18864. */
  18865. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18866. }
  18867. /**
  18868. * This type contains all the data related to a pointer event in Babylon.js.
  18869. * 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.
  18870. */
  18871. export class PointerInfo extends PointerInfoBase {
  18872. /**
  18873. * Defines the picking info associated to the info (if any)\
  18874. */
  18875. pickInfo: Nullable<PickingInfo>;
  18876. /**
  18877. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18878. * @param type Defines the type of event (PointerEventTypes)
  18879. * @param event Defines the related dom event
  18880. * @param pickInfo Defines the picking info associated to the info (if any)\
  18881. */
  18882. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18883. /**
  18884. * Defines the picking info associated to the info (if any)\
  18885. */
  18886. pickInfo: Nullable<PickingInfo>);
  18887. }
  18888. /**
  18889. * Data relating to a touch event on the screen.
  18890. */
  18891. export interface PointerTouch {
  18892. /**
  18893. * X coordinate of touch.
  18894. */
  18895. x: number;
  18896. /**
  18897. * Y coordinate of touch.
  18898. */
  18899. y: number;
  18900. /**
  18901. * Id of touch. Unique for each finger.
  18902. */
  18903. pointerId: number;
  18904. /**
  18905. * Event type passed from DOM.
  18906. */
  18907. type: any;
  18908. }
  18909. }
  18910. declare module BABYLON {
  18911. /**
  18912. * Manage the mouse inputs to control the movement of a free camera.
  18913. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18914. */
  18915. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18916. /**
  18917. * Define if touch is enabled in the mouse input
  18918. */
  18919. touchEnabled: boolean;
  18920. /**
  18921. * Defines the camera the input is attached to.
  18922. */
  18923. camera: FreeCamera;
  18924. /**
  18925. * Defines the buttons associated with the input to handle camera move.
  18926. */
  18927. buttons: number[];
  18928. /**
  18929. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18930. */
  18931. angularSensibility: number;
  18932. private _pointerInput;
  18933. private _onMouseMove;
  18934. private _observer;
  18935. private previousPosition;
  18936. /**
  18937. * Observable for when a pointer move event occurs containing the move offset
  18938. */
  18939. onPointerMovedObservable: Observable<{
  18940. offsetX: number;
  18941. offsetY: number;
  18942. }>;
  18943. /**
  18944. * @hidden
  18945. * If the camera should be rotated automatically based on pointer movement
  18946. */
  18947. _allowCameraRotation: boolean;
  18948. /**
  18949. * Manage the mouse inputs to control the movement of a free camera.
  18950. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18951. * @param touchEnabled Defines if touch is enabled or not
  18952. */
  18953. constructor(
  18954. /**
  18955. * Define if touch is enabled in the mouse input
  18956. */
  18957. touchEnabled?: boolean);
  18958. /**
  18959. * Attach the input controls to a specific dom element to get the input from.
  18960. * @param element Defines the element the controls should be listened from
  18961. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18962. */
  18963. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18964. /**
  18965. * Called on JS contextmenu event.
  18966. * Override this method to provide functionality.
  18967. */
  18968. protected onContextMenu(evt: PointerEvent): void;
  18969. /**
  18970. * Detach the current controls from the specified dom element.
  18971. * @param element Defines the element to stop listening the inputs from
  18972. */
  18973. detachControl(element: Nullable<HTMLElement>): void;
  18974. /**
  18975. * Gets the class name of the current intput.
  18976. * @returns the class name
  18977. */
  18978. getClassName(): string;
  18979. /**
  18980. * Get the friendly name associated with the input class.
  18981. * @returns the input friendly name
  18982. */
  18983. getSimpleName(): string;
  18984. }
  18985. }
  18986. declare module BABYLON {
  18987. /**
  18988. * Manage the touch inputs to control the movement of a free camera.
  18989. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18990. */
  18991. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18992. /**
  18993. * Define if mouse events can be treated as touch events
  18994. */
  18995. allowMouse: boolean;
  18996. /**
  18997. * Defines the camera the input is attached to.
  18998. */
  18999. camera: FreeCamera;
  19000. /**
  19001. * Defines the touch sensibility for rotation.
  19002. * The higher the faster.
  19003. */
  19004. touchAngularSensibility: number;
  19005. /**
  19006. * Defines the touch sensibility for move.
  19007. * The higher the faster.
  19008. */
  19009. touchMoveSensibility: number;
  19010. private _offsetX;
  19011. private _offsetY;
  19012. private _pointerPressed;
  19013. private _pointerInput;
  19014. private _observer;
  19015. private _onLostFocus;
  19016. /**
  19017. * Manage the touch inputs to control the movement of a free camera.
  19018. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19019. * @param allowMouse Defines if mouse events can be treated as touch events
  19020. */
  19021. constructor(
  19022. /**
  19023. * Define if mouse events can be treated as touch events
  19024. */
  19025. allowMouse?: boolean);
  19026. /**
  19027. * Attach the input controls to a specific dom element to get the input from.
  19028. * @param element Defines the element the controls should be listened from
  19029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19030. */
  19031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19032. /**
  19033. * Detach the current controls from the specified dom element.
  19034. * @param element Defines the element to stop listening the inputs from
  19035. */
  19036. detachControl(element: Nullable<HTMLElement>): void;
  19037. /**
  19038. * Update the current camera state depending on the inputs that have been used this frame.
  19039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19040. */
  19041. checkInputs(): void;
  19042. /**
  19043. * Gets the class name of the current intput.
  19044. * @returns the class name
  19045. */
  19046. getClassName(): string;
  19047. /**
  19048. * Get the friendly name associated with the input class.
  19049. * @returns the input friendly name
  19050. */
  19051. getSimpleName(): string;
  19052. }
  19053. }
  19054. declare module BABYLON {
  19055. /**
  19056. * Default Inputs manager for the FreeCamera.
  19057. * It groups all the default supported inputs for ease of use.
  19058. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19059. */
  19060. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19061. /**
  19062. * @hidden
  19063. */
  19064. _mouseInput: Nullable<FreeCameraMouseInput>;
  19065. /**
  19066. * Instantiates a new FreeCameraInputsManager.
  19067. * @param camera Defines the camera the inputs belong to
  19068. */
  19069. constructor(camera: FreeCamera);
  19070. /**
  19071. * Add keyboard input support to the input manager.
  19072. * @returns the current input manager
  19073. */
  19074. addKeyboard(): FreeCameraInputsManager;
  19075. /**
  19076. * Add mouse input support to the input manager.
  19077. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19078. * @returns the current input manager
  19079. */
  19080. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19081. /**
  19082. * Removes the mouse input support from the manager
  19083. * @returns the current input manager
  19084. */
  19085. removeMouse(): FreeCameraInputsManager;
  19086. /**
  19087. * Add touch input support to the input manager.
  19088. * @returns the current input manager
  19089. */
  19090. addTouch(): FreeCameraInputsManager;
  19091. /**
  19092. * Remove all attached input methods from a camera
  19093. */
  19094. clear(): void;
  19095. }
  19096. }
  19097. declare module BABYLON {
  19098. /**
  19099. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19100. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19101. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19102. */
  19103. export class FreeCamera extends TargetCamera {
  19104. /**
  19105. * Define the collision ellipsoid of the camera.
  19106. * This is helpful to simulate a camera body like the player body around the camera
  19107. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19108. */
  19109. ellipsoid: Vector3;
  19110. /**
  19111. * Define an offset for the position of the ellipsoid around the camera.
  19112. * This can be helpful to determine the center of the body near the gravity center of the body
  19113. * instead of its head.
  19114. */
  19115. ellipsoidOffset: Vector3;
  19116. /**
  19117. * Enable or disable collisions of the camera with the rest of the scene objects.
  19118. */
  19119. checkCollisions: boolean;
  19120. /**
  19121. * Enable or disable gravity on the camera.
  19122. */
  19123. applyGravity: boolean;
  19124. /**
  19125. * Define the input manager associated to the camera.
  19126. */
  19127. inputs: FreeCameraInputsManager;
  19128. /**
  19129. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19130. * Higher values reduce sensitivity.
  19131. */
  19132. get angularSensibility(): number;
  19133. /**
  19134. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19135. * Higher values reduce sensitivity.
  19136. */
  19137. set angularSensibility(value: number);
  19138. /**
  19139. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19140. */
  19141. get keysUp(): number[];
  19142. set keysUp(value: number[]);
  19143. /**
  19144. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19145. */
  19146. get keysUpward(): number[];
  19147. set keysUpward(value: number[]);
  19148. /**
  19149. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19150. */
  19151. get keysDown(): number[];
  19152. set keysDown(value: number[]);
  19153. /**
  19154. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19155. */
  19156. get keysDownward(): number[];
  19157. set keysDownward(value: number[]);
  19158. /**
  19159. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19160. */
  19161. get keysLeft(): number[];
  19162. set keysLeft(value: number[]);
  19163. /**
  19164. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19165. */
  19166. get keysRight(): number[];
  19167. set keysRight(value: number[]);
  19168. /**
  19169. * Event raised when the camera collide with a mesh in the scene.
  19170. */
  19171. onCollide: (collidedMesh: AbstractMesh) => void;
  19172. private _collider;
  19173. private _needMoveForGravity;
  19174. private _oldPosition;
  19175. private _diffPosition;
  19176. private _newPosition;
  19177. /** @hidden */
  19178. _localDirection: Vector3;
  19179. /** @hidden */
  19180. _transformedDirection: Vector3;
  19181. /**
  19182. * Instantiates a Free Camera.
  19183. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19184. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19185. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19186. * @param name Define the name of the camera in the scene
  19187. * @param position Define the start position of the camera in the scene
  19188. * @param scene Define the scene the camera belongs to
  19189. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19190. */
  19191. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19192. /**
  19193. * Attached controls to the current camera.
  19194. * @param element Defines the element the controls should be listened from
  19195. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19196. */
  19197. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19198. /**
  19199. * Detach the current controls from the camera.
  19200. * The camera will stop reacting to inputs.
  19201. * @param element Defines the element to stop listening the inputs from
  19202. */
  19203. detachControl(element: HTMLElement): void;
  19204. private _collisionMask;
  19205. /**
  19206. * Define a collision mask to limit the list of object the camera can collide with
  19207. */
  19208. get collisionMask(): number;
  19209. set collisionMask(mask: number);
  19210. /** @hidden */
  19211. _collideWithWorld(displacement: Vector3): void;
  19212. private _onCollisionPositionChange;
  19213. /** @hidden */
  19214. _checkInputs(): void;
  19215. /** @hidden */
  19216. _decideIfNeedsToMove(): boolean;
  19217. /** @hidden */
  19218. _updatePosition(): void;
  19219. /**
  19220. * Destroy the camera and release the current resources hold by it.
  19221. */
  19222. dispose(): void;
  19223. /**
  19224. * Gets the current object class name.
  19225. * @return the class name
  19226. */
  19227. getClassName(): string;
  19228. }
  19229. }
  19230. declare module BABYLON {
  19231. /**
  19232. * Represents a gamepad control stick position
  19233. */
  19234. export class StickValues {
  19235. /**
  19236. * The x component of the control stick
  19237. */
  19238. x: number;
  19239. /**
  19240. * The y component of the control stick
  19241. */
  19242. y: number;
  19243. /**
  19244. * Initializes the gamepad x and y control stick values
  19245. * @param x The x component of the gamepad control stick value
  19246. * @param y The y component of the gamepad control stick value
  19247. */
  19248. constructor(
  19249. /**
  19250. * The x component of the control stick
  19251. */
  19252. x: number,
  19253. /**
  19254. * The y component of the control stick
  19255. */
  19256. y: number);
  19257. }
  19258. /**
  19259. * An interface which manages callbacks for gamepad button changes
  19260. */
  19261. export interface GamepadButtonChanges {
  19262. /**
  19263. * Called when a gamepad has been changed
  19264. */
  19265. changed: boolean;
  19266. /**
  19267. * Called when a gamepad press event has been triggered
  19268. */
  19269. pressChanged: boolean;
  19270. /**
  19271. * Called when a touch event has been triggered
  19272. */
  19273. touchChanged: boolean;
  19274. /**
  19275. * Called when a value has changed
  19276. */
  19277. valueChanged: boolean;
  19278. }
  19279. /**
  19280. * Represents a gamepad
  19281. */
  19282. export class Gamepad {
  19283. /**
  19284. * The id of the gamepad
  19285. */
  19286. id: string;
  19287. /**
  19288. * The index of the gamepad
  19289. */
  19290. index: number;
  19291. /**
  19292. * The browser gamepad
  19293. */
  19294. browserGamepad: any;
  19295. /**
  19296. * Specifies what type of gamepad this represents
  19297. */
  19298. type: number;
  19299. private _leftStick;
  19300. private _rightStick;
  19301. /** @hidden */
  19302. _isConnected: boolean;
  19303. private _leftStickAxisX;
  19304. private _leftStickAxisY;
  19305. private _rightStickAxisX;
  19306. private _rightStickAxisY;
  19307. /**
  19308. * Triggered when the left control stick has been changed
  19309. */
  19310. private _onleftstickchanged;
  19311. /**
  19312. * Triggered when the right control stick has been changed
  19313. */
  19314. private _onrightstickchanged;
  19315. /**
  19316. * Represents a gamepad controller
  19317. */
  19318. static GAMEPAD: number;
  19319. /**
  19320. * Represents a generic controller
  19321. */
  19322. static GENERIC: number;
  19323. /**
  19324. * Represents an XBox controller
  19325. */
  19326. static XBOX: number;
  19327. /**
  19328. * Represents a pose-enabled controller
  19329. */
  19330. static POSE_ENABLED: number;
  19331. /**
  19332. * Represents an Dual Shock controller
  19333. */
  19334. static DUALSHOCK: number;
  19335. /**
  19336. * Specifies whether the left control stick should be Y-inverted
  19337. */
  19338. protected _invertLeftStickY: boolean;
  19339. /**
  19340. * Specifies if the gamepad has been connected
  19341. */
  19342. get isConnected(): boolean;
  19343. /**
  19344. * Initializes the gamepad
  19345. * @param id The id of the gamepad
  19346. * @param index The index of the gamepad
  19347. * @param browserGamepad The browser gamepad
  19348. * @param leftStickX The x component of the left joystick
  19349. * @param leftStickY The y component of the left joystick
  19350. * @param rightStickX The x component of the right joystick
  19351. * @param rightStickY The y component of the right joystick
  19352. */
  19353. constructor(
  19354. /**
  19355. * The id of the gamepad
  19356. */
  19357. id: string,
  19358. /**
  19359. * The index of the gamepad
  19360. */
  19361. index: number,
  19362. /**
  19363. * The browser gamepad
  19364. */
  19365. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19366. /**
  19367. * Callback triggered when the left joystick has changed
  19368. * @param callback
  19369. */
  19370. onleftstickchanged(callback: (values: StickValues) => void): void;
  19371. /**
  19372. * Callback triggered when the right joystick has changed
  19373. * @param callback
  19374. */
  19375. onrightstickchanged(callback: (values: StickValues) => void): void;
  19376. /**
  19377. * Gets the left joystick
  19378. */
  19379. get leftStick(): StickValues;
  19380. /**
  19381. * Sets the left joystick values
  19382. */
  19383. set leftStick(newValues: StickValues);
  19384. /**
  19385. * Gets the right joystick
  19386. */
  19387. get rightStick(): StickValues;
  19388. /**
  19389. * Sets the right joystick value
  19390. */
  19391. set rightStick(newValues: StickValues);
  19392. /**
  19393. * Updates the gamepad joystick positions
  19394. */
  19395. update(): void;
  19396. /**
  19397. * Disposes the gamepad
  19398. */
  19399. dispose(): void;
  19400. }
  19401. /**
  19402. * Represents a generic gamepad
  19403. */
  19404. export class GenericPad extends Gamepad {
  19405. private _buttons;
  19406. private _onbuttondown;
  19407. private _onbuttonup;
  19408. /**
  19409. * Observable triggered when a button has been pressed
  19410. */
  19411. onButtonDownObservable: Observable<number>;
  19412. /**
  19413. * Observable triggered when a button has been released
  19414. */
  19415. onButtonUpObservable: Observable<number>;
  19416. /**
  19417. * Callback triggered when a button has been pressed
  19418. * @param callback Called when a button has been pressed
  19419. */
  19420. onbuttondown(callback: (buttonPressed: number) => void): void;
  19421. /**
  19422. * Callback triggered when a button has been released
  19423. * @param callback Called when a button has been released
  19424. */
  19425. onbuttonup(callback: (buttonReleased: number) => void): void;
  19426. /**
  19427. * Initializes the generic gamepad
  19428. * @param id The id of the generic gamepad
  19429. * @param index The index of the generic gamepad
  19430. * @param browserGamepad The browser gamepad
  19431. */
  19432. constructor(id: string, index: number, browserGamepad: any);
  19433. private _setButtonValue;
  19434. /**
  19435. * Updates the generic gamepad
  19436. */
  19437. update(): void;
  19438. /**
  19439. * Disposes the generic gamepad
  19440. */
  19441. dispose(): void;
  19442. }
  19443. }
  19444. declare module BABYLON {
  19445. /**
  19446. * Defines the types of pose enabled controllers that are supported
  19447. */
  19448. export enum PoseEnabledControllerType {
  19449. /**
  19450. * HTC Vive
  19451. */
  19452. VIVE = 0,
  19453. /**
  19454. * Oculus Rift
  19455. */
  19456. OCULUS = 1,
  19457. /**
  19458. * Windows mixed reality
  19459. */
  19460. WINDOWS = 2,
  19461. /**
  19462. * Samsung gear VR
  19463. */
  19464. GEAR_VR = 3,
  19465. /**
  19466. * Google Daydream
  19467. */
  19468. DAYDREAM = 4,
  19469. /**
  19470. * Generic
  19471. */
  19472. GENERIC = 5
  19473. }
  19474. /**
  19475. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19476. */
  19477. export interface MutableGamepadButton {
  19478. /**
  19479. * Value of the button/trigger
  19480. */
  19481. value: number;
  19482. /**
  19483. * If the button/trigger is currently touched
  19484. */
  19485. touched: boolean;
  19486. /**
  19487. * If the button/trigger is currently pressed
  19488. */
  19489. pressed: boolean;
  19490. }
  19491. /**
  19492. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19493. * @hidden
  19494. */
  19495. export interface ExtendedGamepadButton extends GamepadButton {
  19496. /**
  19497. * If the button/trigger is currently pressed
  19498. */
  19499. readonly pressed: boolean;
  19500. /**
  19501. * If the button/trigger is currently touched
  19502. */
  19503. readonly touched: boolean;
  19504. /**
  19505. * Value of the button/trigger
  19506. */
  19507. readonly value: number;
  19508. }
  19509. /** @hidden */
  19510. export interface _GamePadFactory {
  19511. /**
  19512. * Returns whether or not the current gamepad can be created for this type of controller.
  19513. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19514. * @returns true if it can be created, otherwise false
  19515. */
  19516. canCreate(gamepadInfo: any): boolean;
  19517. /**
  19518. * Creates a new instance of the Gamepad.
  19519. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19520. * @returns the new gamepad instance
  19521. */
  19522. create(gamepadInfo: any): Gamepad;
  19523. }
  19524. /**
  19525. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19526. */
  19527. export class PoseEnabledControllerHelper {
  19528. /** @hidden */
  19529. static _ControllerFactories: _GamePadFactory[];
  19530. /** @hidden */
  19531. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19532. /**
  19533. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19534. * @param vrGamepad the gamepad to initialized
  19535. * @returns a vr controller of the type the gamepad identified as
  19536. */
  19537. static InitiateController(vrGamepad: any): Gamepad;
  19538. }
  19539. /**
  19540. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19541. */
  19542. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19543. /**
  19544. * If the controller is used in a webXR session
  19545. */
  19546. isXR: boolean;
  19547. private _deviceRoomPosition;
  19548. private _deviceRoomRotationQuaternion;
  19549. /**
  19550. * The device position in babylon space
  19551. */
  19552. devicePosition: Vector3;
  19553. /**
  19554. * The device rotation in babylon space
  19555. */
  19556. deviceRotationQuaternion: Quaternion;
  19557. /**
  19558. * The scale factor of the device in babylon space
  19559. */
  19560. deviceScaleFactor: number;
  19561. /**
  19562. * (Likely devicePosition should be used instead) The device position in its room space
  19563. */
  19564. position: Vector3;
  19565. /**
  19566. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19567. */
  19568. rotationQuaternion: Quaternion;
  19569. /**
  19570. * The type of controller (Eg. Windows mixed reality)
  19571. */
  19572. controllerType: PoseEnabledControllerType;
  19573. protected _calculatedPosition: Vector3;
  19574. private _calculatedRotation;
  19575. /**
  19576. * The raw pose from the device
  19577. */
  19578. rawPose: DevicePose;
  19579. private _trackPosition;
  19580. private _maxRotationDistFromHeadset;
  19581. private _draggedRoomRotation;
  19582. /**
  19583. * @hidden
  19584. */
  19585. _disableTrackPosition(fixedPosition: Vector3): void;
  19586. /**
  19587. * Internal, the mesh attached to the controller
  19588. * @hidden
  19589. */
  19590. _mesh: Nullable<AbstractMesh>;
  19591. private _poseControlledCamera;
  19592. private _leftHandSystemQuaternion;
  19593. /**
  19594. * Internal, matrix used to convert room space to babylon space
  19595. * @hidden
  19596. */
  19597. _deviceToWorld: Matrix;
  19598. /**
  19599. * Node to be used when casting a ray from the controller
  19600. * @hidden
  19601. */
  19602. _pointingPoseNode: Nullable<TransformNode>;
  19603. /**
  19604. * Name of the child mesh that can be used to cast a ray from the controller
  19605. */
  19606. static readonly POINTING_POSE: string;
  19607. /**
  19608. * Creates a new PoseEnabledController from a gamepad
  19609. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19610. */
  19611. constructor(browserGamepad: any);
  19612. private _workingMatrix;
  19613. /**
  19614. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19615. */
  19616. update(): void;
  19617. /**
  19618. * Updates only the pose device and mesh without doing any button event checking
  19619. */
  19620. protected _updatePoseAndMesh(): void;
  19621. /**
  19622. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19623. * @param poseData raw pose fromthe device
  19624. */
  19625. updateFromDevice(poseData: DevicePose): void;
  19626. /**
  19627. * @hidden
  19628. */
  19629. _meshAttachedObservable: Observable<AbstractMesh>;
  19630. /**
  19631. * Attaches a mesh to the controller
  19632. * @param mesh the mesh to be attached
  19633. */
  19634. attachToMesh(mesh: AbstractMesh): void;
  19635. /**
  19636. * Attaches the controllers mesh to a camera
  19637. * @param camera the camera the mesh should be attached to
  19638. */
  19639. attachToPoseControlledCamera(camera: TargetCamera): void;
  19640. /**
  19641. * Disposes of the controller
  19642. */
  19643. dispose(): void;
  19644. /**
  19645. * The mesh that is attached to the controller
  19646. */
  19647. get mesh(): Nullable<AbstractMesh>;
  19648. /**
  19649. * Gets the ray of the controller in the direction the controller is pointing
  19650. * @param length the length the resulting ray should be
  19651. * @returns a ray in the direction the controller is pointing
  19652. */
  19653. getForwardRay(length?: number): Ray;
  19654. }
  19655. }
  19656. declare module BABYLON {
  19657. /**
  19658. * Defines the WebVRController object that represents controllers tracked in 3D space
  19659. */
  19660. export abstract class WebVRController extends PoseEnabledController {
  19661. /**
  19662. * Internal, the default controller model for the controller
  19663. */
  19664. protected _defaultModel: Nullable<AbstractMesh>;
  19665. /**
  19666. * Fired when the trigger state has changed
  19667. */
  19668. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19669. /**
  19670. * Fired when the main button state has changed
  19671. */
  19672. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19673. /**
  19674. * Fired when the secondary button state has changed
  19675. */
  19676. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19677. /**
  19678. * Fired when the pad state has changed
  19679. */
  19680. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19681. /**
  19682. * Fired when controllers stick values have changed
  19683. */
  19684. onPadValuesChangedObservable: Observable<StickValues>;
  19685. /**
  19686. * Array of button availible on the controller
  19687. */
  19688. protected _buttons: Array<MutableGamepadButton>;
  19689. private _onButtonStateChange;
  19690. /**
  19691. * Fired when a controller button's state has changed
  19692. * @param callback the callback containing the button that was modified
  19693. */
  19694. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19695. /**
  19696. * X and Y axis corresponding to the controllers joystick
  19697. */
  19698. pad: StickValues;
  19699. /**
  19700. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19701. */
  19702. hand: string;
  19703. /**
  19704. * The default controller model for the controller
  19705. */
  19706. get defaultModel(): Nullable<AbstractMesh>;
  19707. /**
  19708. * Creates a new WebVRController from a gamepad
  19709. * @param vrGamepad the gamepad that the WebVRController should be created from
  19710. */
  19711. constructor(vrGamepad: any);
  19712. /**
  19713. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19714. */
  19715. update(): void;
  19716. /**
  19717. * Function to be called when a button is modified
  19718. */
  19719. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19720. /**
  19721. * Loads a mesh and attaches it to the controller
  19722. * @param scene the scene the mesh should be added to
  19723. * @param meshLoaded callback for when the mesh has been loaded
  19724. */
  19725. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19726. private _setButtonValue;
  19727. private _changes;
  19728. private _checkChanges;
  19729. /**
  19730. * Disposes of th webVRCOntroller
  19731. */
  19732. dispose(): void;
  19733. }
  19734. }
  19735. declare module BABYLON {
  19736. /**
  19737. * The HemisphericLight simulates the ambient environment light,
  19738. * so the passed direction is the light reflection direction, not the incoming direction.
  19739. */
  19740. export class HemisphericLight extends Light {
  19741. /**
  19742. * The groundColor is the light in the opposite direction to the one specified during creation.
  19743. * 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.
  19744. */
  19745. groundColor: Color3;
  19746. /**
  19747. * The light reflection direction, not the incoming direction.
  19748. */
  19749. direction: Vector3;
  19750. /**
  19751. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19752. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19753. * The HemisphericLight can't cast shadows.
  19754. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19755. * @param name The friendly name of the light
  19756. * @param direction The direction of the light reflection
  19757. * @param scene The scene the light belongs to
  19758. */
  19759. constructor(name: string, direction: Vector3, scene: Scene);
  19760. protected _buildUniformLayout(): void;
  19761. /**
  19762. * Returns the string "HemisphericLight".
  19763. * @return The class name
  19764. */
  19765. getClassName(): string;
  19766. /**
  19767. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19768. * Returns the updated direction.
  19769. * @param target The target the direction should point to
  19770. * @return The computed direction
  19771. */
  19772. setDirectionToTarget(target: Vector3): Vector3;
  19773. /**
  19774. * Returns the shadow generator associated to the light.
  19775. * @returns Always null for hemispheric lights because it does not support shadows.
  19776. */
  19777. getShadowGenerator(): Nullable<IShadowGenerator>;
  19778. /**
  19779. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19780. * @param effect The effect to update
  19781. * @param lightIndex The index of the light in the effect to update
  19782. * @returns The hemispheric light
  19783. */
  19784. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19785. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19786. /**
  19787. * Computes the world matrix of the node
  19788. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19789. * @param useWasUpdatedFlag defines a reserved property
  19790. * @returns the world matrix
  19791. */
  19792. computeWorldMatrix(): Matrix;
  19793. /**
  19794. * Returns the integer 3.
  19795. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19796. */
  19797. getTypeID(): number;
  19798. /**
  19799. * Prepares the list of defines specific to the light type.
  19800. * @param defines the list of defines
  19801. * @param lightIndex defines the index of the light for the effect
  19802. */
  19803. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19804. }
  19805. }
  19806. declare module BABYLON {
  19807. /** @hidden */
  19808. export var vrMultiviewToSingleviewPixelShader: {
  19809. name: string;
  19810. shader: string;
  19811. };
  19812. }
  19813. declare module BABYLON {
  19814. /**
  19815. * Renders to multiple views with a single draw call
  19816. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19817. */
  19818. export class MultiviewRenderTarget extends RenderTargetTexture {
  19819. /**
  19820. * Creates a multiview render target
  19821. * @param scene scene used with the render target
  19822. * @param size the size of the render target (used for each view)
  19823. */
  19824. constructor(scene: Scene, size?: number | {
  19825. width: number;
  19826. height: number;
  19827. } | {
  19828. ratio: number;
  19829. });
  19830. /**
  19831. * @hidden
  19832. * @param faceIndex the face index, if its a cube texture
  19833. */
  19834. _bindFrameBuffer(faceIndex?: number): void;
  19835. /**
  19836. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19837. * @returns the view count
  19838. */
  19839. getViewCount(): number;
  19840. }
  19841. }
  19842. declare module BABYLON {
  19843. interface Engine {
  19844. /**
  19845. * Creates a new multiview render target
  19846. * @param width defines the width of the texture
  19847. * @param height defines the height of the texture
  19848. * @returns the created multiview texture
  19849. */
  19850. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19851. /**
  19852. * Binds a multiview framebuffer to be drawn to
  19853. * @param multiviewTexture texture to bind
  19854. */
  19855. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19856. }
  19857. interface Camera {
  19858. /**
  19859. * @hidden
  19860. * 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)
  19861. */
  19862. _useMultiviewToSingleView: boolean;
  19863. /**
  19864. * @hidden
  19865. * 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)
  19866. */
  19867. _multiviewTexture: Nullable<RenderTargetTexture>;
  19868. /**
  19869. * @hidden
  19870. * ensures the multiview texture of the camera exists and has the specified width/height
  19871. * @param width height to set on the multiview texture
  19872. * @param height width to set on the multiview texture
  19873. */
  19874. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19875. }
  19876. interface Scene {
  19877. /** @hidden */
  19878. _transformMatrixR: Matrix;
  19879. /** @hidden */
  19880. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19881. /** @hidden */
  19882. _createMultiviewUbo(): void;
  19883. /** @hidden */
  19884. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19885. /** @hidden */
  19886. _renderMultiviewToSingleView(camera: Camera): void;
  19887. }
  19888. }
  19889. declare module BABYLON {
  19890. /**
  19891. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19892. * This will not be used for webXR as it supports displaying texture arrays directly
  19893. */
  19894. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19895. /**
  19896. * Gets a string identifying the name of the class
  19897. * @returns "VRMultiviewToSingleviewPostProcess" string
  19898. */
  19899. getClassName(): string;
  19900. /**
  19901. * Initializes a VRMultiviewToSingleview
  19902. * @param name name of the post process
  19903. * @param camera camera to be applied to
  19904. * @param scaleFactor scaling factor to the size of the output texture
  19905. */
  19906. constructor(name: string, camera: Camera, scaleFactor: number);
  19907. }
  19908. }
  19909. declare module BABYLON {
  19910. /**
  19911. * Interface used to define additional presentation attributes
  19912. */
  19913. export interface IVRPresentationAttributes {
  19914. /**
  19915. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19916. */
  19917. highRefreshRate: boolean;
  19918. /**
  19919. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19920. */
  19921. foveationLevel: number;
  19922. }
  19923. interface Engine {
  19924. /** @hidden */
  19925. _vrDisplay: any;
  19926. /** @hidden */
  19927. _vrSupported: boolean;
  19928. /** @hidden */
  19929. _oldSize: Size;
  19930. /** @hidden */
  19931. _oldHardwareScaleFactor: number;
  19932. /** @hidden */
  19933. _vrExclusivePointerMode: boolean;
  19934. /** @hidden */
  19935. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19936. /** @hidden */
  19937. _onVRDisplayPointerRestricted: () => void;
  19938. /** @hidden */
  19939. _onVRDisplayPointerUnrestricted: () => void;
  19940. /** @hidden */
  19941. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19942. /** @hidden */
  19943. _onVrDisplayDisconnect: Nullable<() => void>;
  19944. /** @hidden */
  19945. _onVrDisplayPresentChange: Nullable<() => void>;
  19946. /**
  19947. * Observable signaled when VR display mode changes
  19948. */
  19949. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19950. /**
  19951. * Observable signaled when VR request present is complete
  19952. */
  19953. onVRRequestPresentComplete: Observable<boolean>;
  19954. /**
  19955. * Observable signaled when VR request present starts
  19956. */
  19957. onVRRequestPresentStart: Observable<Engine>;
  19958. /**
  19959. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19960. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19961. */
  19962. isInVRExclusivePointerMode: boolean;
  19963. /**
  19964. * Gets a boolean indicating if a webVR device was detected
  19965. * @returns true if a webVR device was detected
  19966. */
  19967. isVRDevicePresent(): boolean;
  19968. /**
  19969. * Gets the current webVR device
  19970. * @returns the current webVR device (or null)
  19971. */
  19972. getVRDevice(): any;
  19973. /**
  19974. * Initializes a webVR display and starts listening to display change events
  19975. * The onVRDisplayChangedObservable will be notified upon these changes
  19976. * @returns A promise containing a VRDisplay and if vr is supported
  19977. */
  19978. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19979. /** @hidden */
  19980. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19981. /**
  19982. * Gets or sets the presentation attributes used to configure VR rendering
  19983. */
  19984. vrPresentationAttributes?: IVRPresentationAttributes;
  19985. /**
  19986. * Call this function to switch to webVR mode
  19987. * Will do nothing if webVR is not supported or if there is no webVR device
  19988. * @param options the webvr options provided to the camera. mainly used for multiview
  19989. * @see https://doc.babylonjs.com/how_to/webvr_camera
  19990. */
  19991. enableVR(options: WebVROptions): void;
  19992. /** @hidden */
  19993. _onVRFullScreenTriggered(): void;
  19994. }
  19995. }
  19996. declare module BABYLON {
  19997. /**
  19998. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19999. * IMPORTANT!! The data is right-hand data.
  20000. * @export
  20001. * @interface DevicePose
  20002. */
  20003. export interface DevicePose {
  20004. /**
  20005. * The position of the device, values in array are [x,y,z].
  20006. */
  20007. readonly position: Nullable<Float32Array>;
  20008. /**
  20009. * The linearVelocity of the device, values in array are [x,y,z].
  20010. */
  20011. readonly linearVelocity: Nullable<Float32Array>;
  20012. /**
  20013. * The linearAcceleration of the device, values in array are [x,y,z].
  20014. */
  20015. readonly linearAcceleration: Nullable<Float32Array>;
  20016. /**
  20017. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20018. */
  20019. readonly orientation: Nullable<Float32Array>;
  20020. /**
  20021. * The angularVelocity of the device, values in array are [x,y,z].
  20022. */
  20023. readonly angularVelocity: Nullable<Float32Array>;
  20024. /**
  20025. * The angularAcceleration of the device, values in array are [x,y,z].
  20026. */
  20027. readonly angularAcceleration: Nullable<Float32Array>;
  20028. }
  20029. /**
  20030. * Interface representing a pose controlled object in Babylon.
  20031. * A pose controlled object has both regular pose values as well as pose values
  20032. * from an external device such as a VR head mounted display
  20033. */
  20034. export interface PoseControlled {
  20035. /**
  20036. * The position of the object in babylon space.
  20037. */
  20038. position: Vector3;
  20039. /**
  20040. * The rotation quaternion of the object in babylon space.
  20041. */
  20042. rotationQuaternion: Quaternion;
  20043. /**
  20044. * The position of the device in babylon space.
  20045. */
  20046. devicePosition?: Vector3;
  20047. /**
  20048. * The rotation quaternion of the device in babylon space.
  20049. */
  20050. deviceRotationQuaternion: Quaternion;
  20051. /**
  20052. * The raw pose coming from the device.
  20053. */
  20054. rawPose: Nullable<DevicePose>;
  20055. /**
  20056. * The scale of the device to be used when translating from device space to babylon space.
  20057. */
  20058. deviceScaleFactor: number;
  20059. /**
  20060. * Updates the poseControlled values based on the input device pose.
  20061. * @param poseData the pose data to update the object with
  20062. */
  20063. updateFromDevice(poseData: DevicePose): void;
  20064. }
  20065. /**
  20066. * Set of options to customize the webVRCamera
  20067. */
  20068. export interface WebVROptions {
  20069. /**
  20070. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20071. */
  20072. trackPosition?: boolean;
  20073. /**
  20074. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20075. */
  20076. positionScale?: number;
  20077. /**
  20078. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20079. */
  20080. displayName?: string;
  20081. /**
  20082. * Should the native controller meshes be initialized. (default: true)
  20083. */
  20084. controllerMeshes?: boolean;
  20085. /**
  20086. * Creating a default HemiLight only on controllers. (default: true)
  20087. */
  20088. defaultLightingOnControllers?: boolean;
  20089. /**
  20090. * If you don't want to use the default VR button of the helper. (default: false)
  20091. */
  20092. useCustomVRButton?: boolean;
  20093. /**
  20094. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20095. */
  20096. customVRButton?: HTMLButtonElement;
  20097. /**
  20098. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20099. */
  20100. rayLength?: number;
  20101. /**
  20102. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20103. */
  20104. defaultHeight?: number;
  20105. /**
  20106. * If multiview should be used if availible (default: false)
  20107. */
  20108. useMultiview?: boolean;
  20109. }
  20110. /**
  20111. * This represents a WebVR camera.
  20112. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20113. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20114. */
  20115. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20116. private webVROptions;
  20117. /**
  20118. * @hidden
  20119. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20120. */
  20121. _vrDevice: any;
  20122. /**
  20123. * The rawPose of the vrDevice.
  20124. */
  20125. rawPose: Nullable<DevicePose>;
  20126. private _onVREnabled;
  20127. private _specsVersion;
  20128. private _attached;
  20129. private _frameData;
  20130. protected _descendants: Array<Node>;
  20131. private _deviceRoomPosition;
  20132. /** @hidden */
  20133. _deviceRoomRotationQuaternion: Quaternion;
  20134. private _standingMatrix;
  20135. /**
  20136. * Represents device position in babylon space.
  20137. */
  20138. devicePosition: Vector3;
  20139. /**
  20140. * Represents device rotation in babylon space.
  20141. */
  20142. deviceRotationQuaternion: Quaternion;
  20143. /**
  20144. * The scale of the device to be used when translating from device space to babylon space.
  20145. */
  20146. deviceScaleFactor: number;
  20147. private _deviceToWorld;
  20148. private _worldToDevice;
  20149. /**
  20150. * References to the webVR controllers for the vrDevice.
  20151. */
  20152. controllers: Array<WebVRController>;
  20153. /**
  20154. * Emits an event when a controller is attached.
  20155. */
  20156. onControllersAttachedObservable: Observable<WebVRController[]>;
  20157. /**
  20158. * Emits an event when a controller's mesh has been loaded;
  20159. */
  20160. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20161. /**
  20162. * Emits an event when the HMD's pose has been updated.
  20163. */
  20164. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20165. private _poseSet;
  20166. /**
  20167. * If the rig cameras be used as parent instead of this camera.
  20168. */
  20169. rigParenting: boolean;
  20170. private _lightOnControllers;
  20171. private _defaultHeight?;
  20172. /**
  20173. * Instantiates a WebVRFreeCamera.
  20174. * @param name The name of the WebVRFreeCamera
  20175. * @param position The starting anchor position for the camera
  20176. * @param scene The scene the camera belongs to
  20177. * @param webVROptions a set of customizable options for the webVRCamera
  20178. */
  20179. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20180. /**
  20181. * Gets the device distance from the ground in meters.
  20182. * @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.
  20183. */
  20184. deviceDistanceToRoomGround(): number;
  20185. /**
  20186. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20187. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20188. */
  20189. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20190. /**
  20191. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20192. * @returns A promise with a boolean set to if the standing matrix is supported.
  20193. */
  20194. useStandingMatrixAsync(): Promise<boolean>;
  20195. /**
  20196. * Disposes the camera
  20197. */
  20198. dispose(): void;
  20199. /**
  20200. * Gets a vrController by name.
  20201. * @param name The name of the controller to retreive
  20202. * @returns the controller matching the name specified or null if not found
  20203. */
  20204. getControllerByName(name: string): Nullable<WebVRController>;
  20205. private _leftController;
  20206. /**
  20207. * The controller corresponding to the users left hand.
  20208. */
  20209. get leftController(): Nullable<WebVRController>;
  20210. private _rightController;
  20211. /**
  20212. * The controller corresponding to the users right hand.
  20213. */
  20214. get rightController(): Nullable<WebVRController>;
  20215. /**
  20216. * Casts a ray forward from the vrCamera's gaze.
  20217. * @param length Length of the ray (default: 100)
  20218. * @returns the ray corresponding to the gaze
  20219. */
  20220. getForwardRay(length?: number): Ray;
  20221. /**
  20222. * @hidden
  20223. * Updates the camera based on device's frame data
  20224. */
  20225. _checkInputs(): void;
  20226. /**
  20227. * Updates the poseControlled values based on the input device pose.
  20228. * @param poseData Pose coming from the device
  20229. */
  20230. updateFromDevice(poseData: DevicePose): void;
  20231. private _htmlElementAttached;
  20232. private _detachIfAttached;
  20233. /**
  20234. * WebVR's attach control will start broadcasting frames to the device.
  20235. * Note that in certain browsers (chrome for example) this function must be called
  20236. * within a user-interaction callback. Example:
  20237. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20238. *
  20239. * @param element html element to attach the vrDevice to
  20240. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20241. */
  20242. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20243. /**
  20244. * Detaches the camera from the html element and disables VR
  20245. *
  20246. * @param element html element to detach from
  20247. */
  20248. detachControl(element: HTMLElement): void;
  20249. /**
  20250. * @returns the name of this class
  20251. */
  20252. getClassName(): string;
  20253. /**
  20254. * Calls resetPose on the vrDisplay
  20255. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20256. */
  20257. resetToCurrentRotation(): void;
  20258. /**
  20259. * @hidden
  20260. * Updates the rig cameras (left and right eye)
  20261. */
  20262. _updateRigCameras(): void;
  20263. private _workingVector;
  20264. private _oneVector;
  20265. private _workingMatrix;
  20266. private updateCacheCalled;
  20267. private _correctPositionIfNotTrackPosition;
  20268. /**
  20269. * @hidden
  20270. * Updates the cached values of the camera
  20271. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20272. */
  20273. _updateCache(ignoreParentClass?: boolean): void;
  20274. /**
  20275. * @hidden
  20276. * Get current device position in babylon world
  20277. */
  20278. _computeDevicePosition(): void;
  20279. /**
  20280. * Updates the current device position and rotation in the babylon world
  20281. */
  20282. update(): void;
  20283. /**
  20284. * @hidden
  20285. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20286. * @returns an identity matrix
  20287. */
  20288. _getViewMatrix(): Matrix;
  20289. private _tmpMatrix;
  20290. /**
  20291. * This function is called by the two RIG cameras.
  20292. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20293. * @hidden
  20294. */
  20295. _getWebVRViewMatrix(): Matrix;
  20296. /** @hidden */
  20297. _getWebVRProjectionMatrix(): Matrix;
  20298. private _onGamepadConnectedObserver;
  20299. private _onGamepadDisconnectedObserver;
  20300. private _updateCacheWhenTrackingDisabledObserver;
  20301. /**
  20302. * Initializes the controllers and their meshes
  20303. */
  20304. initControllers(): void;
  20305. }
  20306. }
  20307. declare module BABYLON {
  20308. /**
  20309. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20310. *
  20311. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20312. *
  20313. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20314. */
  20315. export class MaterialHelper {
  20316. /**
  20317. * Bind the current view position to an effect.
  20318. * @param effect The effect to be bound
  20319. * @param scene The scene the eyes position is used from
  20320. * @param variableName name of the shader variable that will hold the eye position
  20321. */
  20322. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20323. /**
  20324. * Helps preparing the defines values about the UVs in used in the effect.
  20325. * UVs are shared as much as we can accross channels in the shaders.
  20326. * @param texture The texture we are preparing the UVs for
  20327. * @param defines The defines to update
  20328. * @param key The channel key "diffuse", "specular"... used in the shader
  20329. */
  20330. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20331. /**
  20332. * Binds a texture matrix value to its corrsponding uniform
  20333. * @param texture The texture to bind the matrix for
  20334. * @param uniformBuffer The uniform buffer receivin the data
  20335. * @param key The channel key "diffuse", "specular"... used in the shader
  20336. */
  20337. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20338. /**
  20339. * Gets the current status of the fog (should it be enabled?)
  20340. * @param mesh defines the mesh to evaluate for fog support
  20341. * @param scene defines the hosting scene
  20342. * @returns true if fog must be enabled
  20343. */
  20344. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20345. /**
  20346. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20347. * @param mesh defines the current mesh
  20348. * @param scene defines the current scene
  20349. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20350. * @param pointsCloud defines if point cloud rendering has to be turned on
  20351. * @param fogEnabled defines if fog has to be turned on
  20352. * @param alphaTest defines if alpha testing has to be turned on
  20353. * @param defines defines the current list of defines
  20354. */
  20355. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20356. /**
  20357. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20358. * @param scene defines the current scene
  20359. * @param engine defines the current engine
  20360. * @param defines specifies the list of active defines
  20361. * @param useInstances defines if instances have to be turned on
  20362. * @param useClipPlane defines if clip plane have to be turned on
  20363. * @param useInstances defines if instances have to be turned on
  20364. * @param useThinInstances defines if thin instances have to be turned on
  20365. */
  20366. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20367. /**
  20368. * Prepares the defines for bones
  20369. * @param mesh The mesh containing the geometry data we will draw
  20370. * @param defines The defines to update
  20371. */
  20372. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20373. /**
  20374. * Prepares the defines for morph targets
  20375. * @param mesh The mesh containing the geometry data we will draw
  20376. * @param defines The defines to update
  20377. */
  20378. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20379. /**
  20380. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20381. * @param mesh The mesh containing the geometry data we will draw
  20382. * @param defines The defines to update
  20383. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20384. * @param useBones Precise whether bones should be used or not (override mesh info)
  20385. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20386. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20387. * @returns false if defines are considered not dirty and have not been checked
  20388. */
  20389. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20390. /**
  20391. * Prepares the defines related to multiview
  20392. * @param scene The scene we are intending to draw
  20393. * @param defines The defines to update
  20394. */
  20395. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20396. /**
  20397. * Prepares the defines related to the prepass
  20398. * @param scene The scene we are intending to draw
  20399. * @param defines The defines to update
  20400. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20401. */
  20402. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20403. /**
  20404. * Prepares the defines related to the light information passed in parameter
  20405. * @param scene The scene we are intending to draw
  20406. * @param mesh The mesh the effect is compiling for
  20407. * @param light The light the effect is compiling for
  20408. * @param lightIndex The index of the light
  20409. * @param defines The defines to update
  20410. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20411. * @param state Defines the current state regarding what is needed (normals, etc...)
  20412. */
  20413. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20414. needNormals: boolean;
  20415. needRebuild: boolean;
  20416. shadowEnabled: boolean;
  20417. specularEnabled: boolean;
  20418. lightmapMode: boolean;
  20419. }): void;
  20420. /**
  20421. * Prepares the defines related to the light information passed in parameter
  20422. * @param scene The scene we are intending to draw
  20423. * @param mesh The mesh the effect is compiling for
  20424. * @param defines The defines to update
  20425. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20426. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20427. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20428. * @returns true if normals will be required for the rest of the effect
  20429. */
  20430. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20431. /**
  20432. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20433. * @param lightIndex defines the light index
  20434. * @param uniformsList The uniform list
  20435. * @param samplersList The sampler list
  20436. * @param projectedLightTexture defines if projected texture must be used
  20437. * @param uniformBuffersList defines an optional list of uniform buffers
  20438. */
  20439. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20440. /**
  20441. * Prepares the uniforms and samplers list to be used in the effect
  20442. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20443. * @param samplersList The sampler list
  20444. * @param defines The defines helping in the list generation
  20445. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20446. */
  20447. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20448. /**
  20449. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20450. * @param defines The defines to update while falling back
  20451. * @param fallbacks The authorized effect fallbacks
  20452. * @param maxSimultaneousLights The maximum number of lights allowed
  20453. * @param rank the current rank of the Effect
  20454. * @returns The newly affected rank
  20455. */
  20456. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20457. private static _TmpMorphInfluencers;
  20458. /**
  20459. * Prepares the list of attributes required for morph targets according to the effect defines.
  20460. * @param attribs The current list of supported attribs
  20461. * @param mesh The mesh to prepare the morph targets attributes for
  20462. * @param influencers The number of influencers
  20463. */
  20464. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20465. /**
  20466. * Prepares the list of attributes required for morph targets according to the effect defines.
  20467. * @param attribs The current list of supported attribs
  20468. * @param mesh The mesh to prepare the morph targets attributes for
  20469. * @param defines The current Defines of the effect
  20470. */
  20471. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20472. /**
  20473. * Prepares the list of attributes required for bones according to the effect defines.
  20474. * @param attribs The current list of supported attribs
  20475. * @param mesh The mesh to prepare the bones attributes for
  20476. * @param defines The current Defines of the effect
  20477. * @param fallbacks The current efffect fallback strategy
  20478. */
  20479. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20480. /**
  20481. * Check and prepare the list of attributes required for instances according to the effect defines.
  20482. * @param attribs The current list of supported attribs
  20483. * @param defines The current MaterialDefines of the effect
  20484. */
  20485. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20486. /**
  20487. * Add the list of attributes required for instances to the attribs array.
  20488. * @param attribs The current list of supported attribs
  20489. */
  20490. static PushAttributesForInstances(attribs: string[]): void;
  20491. /**
  20492. * Binds the light information to the effect.
  20493. * @param light The light containing the generator
  20494. * @param effect The effect we are binding the data to
  20495. * @param lightIndex The light index in the effect used to render
  20496. */
  20497. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20498. /**
  20499. * Binds the lights information from the scene to the effect for the given mesh.
  20500. * @param light Light to bind
  20501. * @param lightIndex Light index
  20502. * @param scene The scene where the light belongs to
  20503. * @param effect The effect we are binding the data to
  20504. * @param useSpecular Defines if specular is supported
  20505. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20506. */
  20507. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20508. /**
  20509. * Binds the lights information from the scene to the effect for the given mesh.
  20510. * @param scene The scene the lights belongs to
  20511. * @param mesh The mesh we are binding the information to render
  20512. * @param effect The effect we are binding the data to
  20513. * @param defines The generated defines for the effect
  20514. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20515. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20516. */
  20517. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20518. private static _tempFogColor;
  20519. /**
  20520. * Binds the fog information from the scene to the effect for the given mesh.
  20521. * @param scene The scene the lights belongs to
  20522. * @param mesh The mesh we are binding the information to render
  20523. * @param effect The effect we are binding the data to
  20524. * @param linearSpace Defines if the fog effect is applied in linear space
  20525. */
  20526. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20527. /**
  20528. * Binds the bones information from the mesh to the effect.
  20529. * @param mesh The mesh we are binding the information to render
  20530. * @param effect The effect we are binding the data to
  20531. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20532. */
  20533. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20534. private static _CopyBonesTransformationMatrices;
  20535. /**
  20536. * Binds the morph targets information from the mesh to the effect.
  20537. * @param abstractMesh The mesh we are binding the information to render
  20538. * @param effect The effect we are binding the data to
  20539. */
  20540. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20541. /**
  20542. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20543. * @param defines The generated defines used in the effect
  20544. * @param effect The effect we are binding the data to
  20545. * @param scene The scene we are willing to render with logarithmic scale for
  20546. */
  20547. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20548. /**
  20549. * Binds the clip plane information from the scene to the effect.
  20550. * @param scene The scene the clip plane information are extracted from
  20551. * @param effect The effect we are binding the data to
  20552. */
  20553. static BindClipPlane(effect: Effect, scene: Scene): void;
  20554. }
  20555. }
  20556. declare module BABYLON {
  20557. /**
  20558. * Block used to expose an input value
  20559. */
  20560. export class InputBlock extends NodeMaterialBlock {
  20561. private _mode;
  20562. private _associatedVariableName;
  20563. private _storedValue;
  20564. private _valueCallback;
  20565. private _type;
  20566. private _animationType;
  20567. /** Gets or set a value used to limit the range of float values */
  20568. min: number;
  20569. /** Gets or set a value used to limit the range of float values */
  20570. max: number;
  20571. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20572. isBoolean: boolean;
  20573. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20574. matrixMode: number;
  20575. /** @hidden */
  20576. _systemValue: Nullable<NodeMaterialSystemValues>;
  20577. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20578. isConstant: boolean;
  20579. /** Gets or sets the group to use to display this block in the Inspector */
  20580. groupInInspector: string;
  20581. /** Gets an observable raised when the value is changed */
  20582. onValueChangedObservable: Observable<InputBlock>;
  20583. /**
  20584. * Gets or sets the connection point type (default is float)
  20585. */
  20586. get type(): NodeMaterialBlockConnectionPointTypes;
  20587. /**
  20588. * Creates a new InputBlock
  20589. * @param name defines the block name
  20590. * @param target defines the target of that block (Vertex by default)
  20591. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20592. */
  20593. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20594. /**
  20595. * Validates if a name is a reserve word.
  20596. * @param newName the new name to be given to the node.
  20597. * @returns false if the name is a reserve word, else true.
  20598. */
  20599. validateBlockName(newName: string): boolean;
  20600. /**
  20601. * Gets the output component
  20602. */
  20603. get output(): NodeMaterialConnectionPoint;
  20604. /**
  20605. * Set the source of this connection point to a vertex attribute
  20606. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20607. * @returns the current connection point
  20608. */
  20609. setAsAttribute(attributeName?: string): InputBlock;
  20610. /**
  20611. * Set the source of this connection point to a system value
  20612. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20613. * @returns the current connection point
  20614. */
  20615. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20616. /**
  20617. * Gets or sets the value of that point.
  20618. * Please note that this value will be ignored if valueCallback is defined
  20619. */
  20620. get value(): any;
  20621. set value(value: any);
  20622. /**
  20623. * Gets or sets a callback used to get the value of that point.
  20624. * Please note that setting this value will force the connection point to ignore the value property
  20625. */
  20626. get valueCallback(): () => any;
  20627. set valueCallback(value: () => any);
  20628. /**
  20629. * Gets or sets the associated variable name in the shader
  20630. */
  20631. get associatedVariableName(): string;
  20632. set associatedVariableName(value: string);
  20633. /** Gets or sets the type of animation applied to the input */
  20634. get animationType(): AnimatedInputBlockTypes;
  20635. set animationType(value: AnimatedInputBlockTypes);
  20636. /**
  20637. * Gets a boolean indicating that this connection point not defined yet
  20638. */
  20639. get isUndefined(): boolean;
  20640. /**
  20641. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20642. * In this case the connection point name must be the name of the uniform to use.
  20643. * Can only be set on inputs
  20644. */
  20645. get isUniform(): boolean;
  20646. set isUniform(value: boolean);
  20647. /**
  20648. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20649. * In this case the connection point name must be the name of the attribute to use
  20650. * Can only be set on inputs
  20651. */
  20652. get isAttribute(): boolean;
  20653. set isAttribute(value: boolean);
  20654. /**
  20655. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20656. * Can only be set on exit points
  20657. */
  20658. get isVarying(): boolean;
  20659. set isVarying(value: boolean);
  20660. /**
  20661. * Gets a boolean indicating that the current connection point is a system value
  20662. */
  20663. get isSystemValue(): boolean;
  20664. /**
  20665. * Gets or sets the current well known value or null if not defined as a system value
  20666. */
  20667. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20668. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20669. /**
  20670. * Gets the current class name
  20671. * @returns the class name
  20672. */
  20673. getClassName(): string;
  20674. /**
  20675. * Animate the input if animationType !== None
  20676. * @param scene defines the rendering scene
  20677. */
  20678. animate(scene: Scene): void;
  20679. private _emitDefine;
  20680. initialize(state: NodeMaterialBuildState): void;
  20681. /**
  20682. * Set the input block to its default value (based on its type)
  20683. */
  20684. setDefaultValue(): void;
  20685. private _emitConstant;
  20686. /** @hidden */
  20687. get _noContextSwitch(): boolean;
  20688. private _emit;
  20689. /** @hidden */
  20690. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20691. /** @hidden */
  20692. _transmit(effect: Effect, scene: Scene): void;
  20693. protected _buildBlock(state: NodeMaterialBuildState): void;
  20694. protected _dumpPropertiesCode(): string;
  20695. dispose(): void;
  20696. serialize(): any;
  20697. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20698. }
  20699. }
  20700. declare module BABYLON {
  20701. /**
  20702. * Enum used to define the compatibility state between two connection points
  20703. */
  20704. export enum NodeMaterialConnectionPointCompatibilityStates {
  20705. /** Points are compatibles */
  20706. Compatible = 0,
  20707. /** Points are incompatible because of their types */
  20708. TypeIncompatible = 1,
  20709. /** Points are incompatible because of their targets (vertex vs fragment) */
  20710. TargetIncompatible = 2
  20711. }
  20712. /**
  20713. * Defines the direction of a connection point
  20714. */
  20715. export enum NodeMaterialConnectionPointDirection {
  20716. /** Input */
  20717. Input = 0,
  20718. /** Output */
  20719. Output = 1
  20720. }
  20721. /**
  20722. * Defines a connection point for a block
  20723. */
  20724. export class NodeMaterialConnectionPoint {
  20725. /** @hidden */
  20726. _ownerBlock: NodeMaterialBlock;
  20727. /** @hidden */
  20728. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20729. private _endpoints;
  20730. private _associatedVariableName;
  20731. private _direction;
  20732. /** @hidden */
  20733. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20734. /** @hidden */
  20735. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20736. private _type;
  20737. /** @hidden */
  20738. _enforceAssociatedVariableName: boolean;
  20739. /** Gets the direction of the point */
  20740. get direction(): NodeMaterialConnectionPointDirection;
  20741. /** Indicates that this connection point needs dual validation before being connected to another point */
  20742. needDualDirectionValidation: boolean;
  20743. /**
  20744. * Gets or sets the additional types supported by this connection point
  20745. */
  20746. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20747. /**
  20748. * Gets or sets the additional types excluded by this connection point
  20749. */
  20750. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20751. /**
  20752. * Observable triggered when this point is connected
  20753. */
  20754. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20755. /**
  20756. * Gets or sets the associated variable name in the shader
  20757. */
  20758. get associatedVariableName(): string;
  20759. set associatedVariableName(value: string);
  20760. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20761. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20762. /**
  20763. * Gets or sets the connection point type (default is float)
  20764. */
  20765. get type(): NodeMaterialBlockConnectionPointTypes;
  20766. set type(value: NodeMaterialBlockConnectionPointTypes);
  20767. /**
  20768. * Gets or sets the connection point name
  20769. */
  20770. name: string;
  20771. /**
  20772. * Gets or sets the connection point name
  20773. */
  20774. displayName: string;
  20775. /**
  20776. * Gets or sets a boolean indicating that this connection point can be omitted
  20777. */
  20778. isOptional: boolean;
  20779. /**
  20780. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20781. */
  20782. isExposedOnFrame: boolean;
  20783. /**
  20784. * Gets or sets number indicating the position that the port is exposed to on a frame
  20785. */
  20786. exposedPortPosition: number;
  20787. /**
  20788. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20789. */
  20790. define: string;
  20791. /** @hidden */
  20792. _prioritizeVertex: boolean;
  20793. private _target;
  20794. /** Gets or sets the target of that connection point */
  20795. get target(): NodeMaterialBlockTargets;
  20796. set target(value: NodeMaterialBlockTargets);
  20797. /**
  20798. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20799. */
  20800. get isConnected(): boolean;
  20801. /**
  20802. * Gets a boolean indicating that the current point is connected to an input block
  20803. */
  20804. get isConnectedToInputBlock(): boolean;
  20805. /**
  20806. * Gets a the connected input block (if any)
  20807. */
  20808. get connectInputBlock(): Nullable<InputBlock>;
  20809. /** Get the other side of the connection (if any) */
  20810. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20811. /** Get the block that owns this connection point */
  20812. get ownerBlock(): NodeMaterialBlock;
  20813. /** Get the block connected on the other side of this connection (if any) */
  20814. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20815. /** Get the block connected on the endpoints of this connection (if any) */
  20816. get connectedBlocks(): Array<NodeMaterialBlock>;
  20817. /** Gets the list of connected endpoints */
  20818. get endpoints(): NodeMaterialConnectionPoint[];
  20819. /** Gets a boolean indicating if that output point is connected to at least one input */
  20820. get hasEndpoints(): boolean;
  20821. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20822. get isConnectedInVertexShader(): boolean;
  20823. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20824. get isConnectedInFragmentShader(): boolean;
  20825. /**
  20826. * Creates a block suitable to be used as an input for this input point.
  20827. * If null is returned, a block based on the point type will be created.
  20828. * @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
  20829. */
  20830. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20831. /**
  20832. * Creates a new connection point
  20833. * @param name defines the connection point name
  20834. * @param ownerBlock defines the block hosting this connection point
  20835. * @param direction defines the direction of the connection point
  20836. */
  20837. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20838. /**
  20839. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20840. * @returns the class name
  20841. */
  20842. getClassName(): string;
  20843. /**
  20844. * Gets a boolean indicating if the current point can be connected to another point
  20845. * @param connectionPoint defines the other connection point
  20846. * @returns a boolean
  20847. */
  20848. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20849. /**
  20850. * Gets a number indicating if the current point can be connected to another point
  20851. * @param connectionPoint defines the other connection point
  20852. * @returns a number defining the compatibility state
  20853. */
  20854. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20855. /**
  20856. * Connect this point to another connection point
  20857. * @param connectionPoint defines the other connection point
  20858. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20859. * @returns the current connection point
  20860. */
  20861. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20862. /**
  20863. * Disconnect this point from one of his endpoint
  20864. * @param endpoint defines the other connection point
  20865. * @returns the current connection point
  20866. */
  20867. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20868. /**
  20869. * Serializes this point in a JSON representation
  20870. * @param isInput defines if the connection point is an input (default is true)
  20871. * @returns the serialized point object
  20872. */
  20873. serialize(isInput?: boolean): any;
  20874. /**
  20875. * Release resources
  20876. */
  20877. dispose(): void;
  20878. }
  20879. }
  20880. declare module BABYLON {
  20881. /**
  20882. * Enum used to define the material modes
  20883. */
  20884. export enum NodeMaterialModes {
  20885. /** Regular material */
  20886. Material = 0,
  20887. /** For post process */
  20888. PostProcess = 1,
  20889. /** For particle system */
  20890. Particle = 2,
  20891. /** For procedural texture */
  20892. ProceduralTexture = 3
  20893. }
  20894. }
  20895. declare module BABYLON {
  20896. /**
  20897. * Block used to read a texture from a sampler
  20898. */
  20899. export class TextureBlock extends NodeMaterialBlock {
  20900. private _defineName;
  20901. private _linearDefineName;
  20902. private _gammaDefineName;
  20903. private _tempTextureRead;
  20904. private _samplerName;
  20905. private _transformedUVName;
  20906. private _textureTransformName;
  20907. private _textureInfoName;
  20908. private _mainUVName;
  20909. private _mainUVDefineName;
  20910. private _fragmentOnly;
  20911. /**
  20912. * Gets or sets the texture associated with the node
  20913. */
  20914. texture: Nullable<Texture>;
  20915. /**
  20916. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20917. */
  20918. convertToGammaSpace: boolean;
  20919. /**
  20920. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20921. */
  20922. convertToLinearSpace: boolean;
  20923. /**
  20924. * Create a new TextureBlock
  20925. * @param name defines the block name
  20926. */
  20927. constructor(name: string, fragmentOnly?: boolean);
  20928. /**
  20929. * Gets the current class name
  20930. * @returns the class name
  20931. */
  20932. getClassName(): string;
  20933. /**
  20934. * Gets the uv input component
  20935. */
  20936. get uv(): NodeMaterialConnectionPoint;
  20937. /**
  20938. * Gets the rgba output component
  20939. */
  20940. get rgba(): NodeMaterialConnectionPoint;
  20941. /**
  20942. * Gets the rgb output component
  20943. */
  20944. get rgb(): NodeMaterialConnectionPoint;
  20945. /**
  20946. * Gets the r output component
  20947. */
  20948. get r(): NodeMaterialConnectionPoint;
  20949. /**
  20950. * Gets the g output component
  20951. */
  20952. get g(): NodeMaterialConnectionPoint;
  20953. /**
  20954. * Gets the b output component
  20955. */
  20956. get b(): NodeMaterialConnectionPoint;
  20957. /**
  20958. * Gets the a output component
  20959. */
  20960. get a(): NodeMaterialConnectionPoint;
  20961. get target(): NodeMaterialBlockTargets;
  20962. autoConfigure(material: NodeMaterial): void;
  20963. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20965. isReady(): boolean;
  20966. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20967. private get _isMixed();
  20968. private _injectVertexCode;
  20969. private _writeTextureRead;
  20970. private _writeOutput;
  20971. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20972. protected _dumpPropertiesCode(): string;
  20973. serialize(): any;
  20974. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20975. }
  20976. }
  20977. declare module BABYLON {
  20978. /** @hidden */
  20979. export var reflectionFunction: {
  20980. name: string;
  20981. shader: string;
  20982. };
  20983. }
  20984. declare module BABYLON {
  20985. /**
  20986. * Base block used to read a reflection texture from a sampler
  20987. */
  20988. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  20989. /** @hidden */
  20990. _define3DName: string;
  20991. /** @hidden */
  20992. _defineCubicName: string;
  20993. /** @hidden */
  20994. _defineExplicitName: string;
  20995. /** @hidden */
  20996. _defineProjectionName: string;
  20997. /** @hidden */
  20998. _defineLocalCubicName: string;
  20999. /** @hidden */
  21000. _defineSphericalName: string;
  21001. /** @hidden */
  21002. _definePlanarName: string;
  21003. /** @hidden */
  21004. _defineEquirectangularName: string;
  21005. /** @hidden */
  21006. _defineMirroredEquirectangularFixedName: string;
  21007. /** @hidden */
  21008. _defineEquirectangularFixedName: string;
  21009. /** @hidden */
  21010. _defineSkyboxName: string;
  21011. /** @hidden */
  21012. _defineOppositeZ: string;
  21013. /** @hidden */
  21014. _cubeSamplerName: string;
  21015. /** @hidden */
  21016. _2DSamplerName: string;
  21017. protected _positionUVWName: string;
  21018. protected _directionWName: string;
  21019. protected _reflectionVectorName: string;
  21020. /** @hidden */
  21021. _reflectionCoordsName: string;
  21022. /** @hidden */
  21023. _reflectionMatrixName: string;
  21024. protected _reflectionColorName: string;
  21025. /**
  21026. * Gets or sets the texture associated with the node
  21027. */
  21028. texture: Nullable<BaseTexture>;
  21029. /**
  21030. * Create a new ReflectionTextureBaseBlock
  21031. * @param name defines the block name
  21032. */
  21033. constructor(name: string);
  21034. /**
  21035. * Gets the current class name
  21036. * @returns the class name
  21037. */
  21038. getClassName(): string;
  21039. /**
  21040. * Gets the world position input component
  21041. */
  21042. abstract get position(): NodeMaterialConnectionPoint;
  21043. /**
  21044. * Gets the world position input component
  21045. */
  21046. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21047. /**
  21048. * Gets the world normal input component
  21049. */
  21050. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21051. /**
  21052. * Gets the world input component
  21053. */
  21054. abstract get world(): NodeMaterialConnectionPoint;
  21055. /**
  21056. * Gets the camera (or eye) position component
  21057. */
  21058. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21059. /**
  21060. * Gets the view input component
  21061. */
  21062. abstract get view(): NodeMaterialConnectionPoint;
  21063. protected _getTexture(): Nullable<BaseTexture>;
  21064. autoConfigure(material: NodeMaterial): void;
  21065. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21066. isReady(): boolean;
  21067. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21068. /**
  21069. * Gets the code to inject in the vertex shader
  21070. * @param state current state of the node material building
  21071. * @returns the shader code
  21072. */
  21073. handleVertexSide(state: NodeMaterialBuildState): string;
  21074. /**
  21075. * Handles the inits for the fragment code path
  21076. * @param state node material build state
  21077. */
  21078. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21079. /**
  21080. * Generates the reflection coords code for the fragment code path
  21081. * @param worldNormalVarName name of the world normal variable
  21082. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21083. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21084. * @returns the shader code
  21085. */
  21086. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21087. /**
  21088. * Generates the reflection color code for the fragment code path
  21089. * @param lodVarName name of the lod variable
  21090. * @param swizzleLookupTexture swizzle to use for the final color variable
  21091. * @returns the shader code
  21092. */
  21093. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21094. /**
  21095. * Generates the code corresponding to the connected output points
  21096. * @param state node material build state
  21097. * @param varName name of the variable to output
  21098. * @returns the shader code
  21099. */
  21100. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21101. protected _buildBlock(state: NodeMaterialBuildState): this;
  21102. protected _dumpPropertiesCode(): string;
  21103. serialize(): any;
  21104. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21105. }
  21106. }
  21107. declare module BABYLON {
  21108. /**
  21109. * Defines a connection point to be used for points with a custom object type
  21110. */
  21111. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21112. private _blockType;
  21113. private _blockName;
  21114. private _nameForCheking?;
  21115. /**
  21116. * Creates a new connection point
  21117. * @param name defines the connection point name
  21118. * @param ownerBlock defines the block hosting this connection point
  21119. * @param direction defines the direction of the connection point
  21120. */
  21121. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21122. /**
  21123. * Gets a number indicating if the current point can be connected to another point
  21124. * @param connectionPoint defines the other connection point
  21125. * @returns a number defining the compatibility state
  21126. */
  21127. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21128. /**
  21129. * Creates a block suitable to be used as an input for this input point.
  21130. * If null is returned, a block based on the point type will be created.
  21131. * @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
  21132. */
  21133. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21134. }
  21135. }
  21136. declare module BABYLON {
  21137. /**
  21138. * Enum defining the type of properties that can be edited in the property pages in the NME
  21139. */
  21140. export enum PropertyTypeForEdition {
  21141. /** property is a boolean */
  21142. Boolean = 0,
  21143. /** property is a float */
  21144. Float = 1,
  21145. /** property is a Vector2 */
  21146. Vector2 = 2,
  21147. /** property is a list of values */
  21148. List = 3
  21149. }
  21150. /**
  21151. * Interface that defines an option in a variable of type list
  21152. */
  21153. export interface IEditablePropertyListOption {
  21154. /** label of the option */
  21155. "label": string;
  21156. /** value of the option */
  21157. "value": number;
  21158. }
  21159. /**
  21160. * Interface that defines the options available for an editable property
  21161. */
  21162. export interface IEditablePropertyOption {
  21163. /** min value */
  21164. "min"?: number;
  21165. /** max value */
  21166. "max"?: number;
  21167. /** notifiers: indicates which actions to take when the property is changed */
  21168. "notifiers"?: {
  21169. /** the material should be rebuilt */
  21170. "rebuild"?: boolean;
  21171. /** the preview should be updated */
  21172. "update"?: boolean;
  21173. };
  21174. /** list of the options for a variable of type list */
  21175. "options"?: IEditablePropertyListOption[];
  21176. }
  21177. /**
  21178. * Interface that describes an editable property
  21179. */
  21180. export interface IPropertyDescriptionForEdition {
  21181. /** name of the property */
  21182. "propertyName": string;
  21183. /** display name of the property */
  21184. "displayName": string;
  21185. /** type of the property */
  21186. "type": PropertyTypeForEdition;
  21187. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21188. "groupName": string;
  21189. /** options for the property */
  21190. "options": IEditablePropertyOption;
  21191. }
  21192. /**
  21193. * Decorator that flags a property in a node material block as being editable
  21194. */
  21195. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21196. }
  21197. declare module BABYLON {
  21198. /**
  21199. * Block used to implement the refraction part of the sub surface module of the PBR material
  21200. */
  21201. export class RefractionBlock extends NodeMaterialBlock {
  21202. /** @hidden */
  21203. _define3DName: string;
  21204. /** @hidden */
  21205. _refractionMatrixName: string;
  21206. /** @hidden */
  21207. _defineLODRefractionAlpha: string;
  21208. /** @hidden */
  21209. _defineLinearSpecularRefraction: string;
  21210. /** @hidden */
  21211. _defineOppositeZ: string;
  21212. /** @hidden */
  21213. _cubeSamplerName: string;
  21214. /** @hidden */
  21215. _2DSamplerName: string;
  21216. /** @hidden */
  21217. _vRefractionMicrosurfaceInfosName: string;
  21218. /** @hidden */
  21219. _vRefractionInfosName: string;
  21220. private _scene;
  21221. /**
  21222. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21223. * Materials half opaque for instance using refraction could benefit from this control.
  21224. */
  21225. linkRefractionWithTransparency: boolean;
  21226. /**
  21227. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21228. */
  21229. invertRefractionY: boolean;
  21230. /**
  21231. * Gets or sets the texture associated with the node
  21232. */
  21233. texture: Nullable<BaseTexture>;
  21234. /**
  21235. * Create a new RefractionBlock
  21236. * @param name defines the block name
  21237. */
  21238. constructor(name: string);
  21239. /**
  21240. * Gets the current class name
  21241. * @returns the class name
  21242. */
  21243. getClassName(): string;
  21244. /**
  21245. * Gets the intensity input component
  21246. */
  21247. get intensity(): NodeMaterialConnectionPoint;
  21248. /**
  21249. * Gets the index of refraction input component
  21250. */
  21251. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21252. /**
  21253. * Gets the tint at distance input component
  21254. */
  21255. get tintAtDistance(): NodeMaterialConnectionPoint;
  21256. /**
  21257. * Gets the view input component
  21258. */
  21259. get view(): NodeMaterialConnectionPoint;
  21260. /**
  21261. * Gets the refraction object output component
  21262. */
  21263. get refraction(): NodeMaterialConnectionPoint;
  21264. /**
  21265. * Returns true if the block has a texture
  21266. */
  21267. get hasTexture(): boolean;
  21268. protected _getTexture(): Nullable<BaseTexture>;
  21269. autoConfigure(material: NodeMaterial): void;
  21270. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21271. isReady(): boolean;
  21272. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21273. /**
  21274. * Gets the main code of the block (fragment side)
  21275. * @param state current state of the node material building
  21276. * @returns the shader code
  21277. */
  21278. getCode(state: NodeMaterialBuildState): string;
  21279. protected _buildBlock(state: NodeMaterialBuildState): this;
  21280. protected _dumpPropertiesCode(): string;
  21281. serialize(): any;
  21282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21283. }
  21284. }
  21285. declare module BABYLON {
  21286. /**
  21287. * Base block used as input for post process
  21288. */
  21289. export class CurrentScreenBlock extends NodeMaterialBlock {
  21290. private _samplerName;
  21291. private _linearDefineName;
  21292. private _gammaDefineName;
  21293. private _mainUVName;
  21294. private _tempTextureRead;
  21295. /**
  21296. * Gets or sets the texture associated with the node
  21297. */
  21298. texture: Nullable<BaseTexture>;
  21299. /**
  21300. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21301. */
  21302. convertToGammaSpace: boolean;
  21303. /**
  21304. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21305. */
  21306. convertToLinearSpace: boolean;
  21307. /**
  21308. * Create a new CurrentScreenBlock
  21309. * @param name defines the block name
  21310. */
  21311. constructor(name: string);
  21312. /**
  21313. * Gets the current class name
  21314. * @returns the class name
  21315. */
  21316. getClassName(): string;
  21317. /**
  21318. * Gets the uv input component
  21319. */
  21320. get uv(): NodeMaterialConnectionPoint;
  21321. /**
  21322. * Gets the rgba output component
  21323. */
  21324. get rgba(): NodeMaterialConnectionPoint;
  21325. /**
  21326. * Gets the rgb output component
  21327. */
  21328. get rgb(): NodeMaterialConnectionPoint;
  21329. /**
  21330. * Gets the r output component
  21331. */
  21332. get r(): NodeMaterialConnectionPoint;
  21333. /**
  21334. * Gets the g output component
  21335. */
  21336. get g(): NodeMaterialConnectionPoint;
  21337. /**
  21338. * Gets the b output component
  21339. */
  21340. get b(): NodeMaterialConnectionPoint;
  21341. /**
  21342. * Gets the a output component
  21343. */
  21344. get a(): NodeMaterialConnectionPoint;
  21345. /**
  21346. * Initialize the block and prepare the context for build
  21347. * @param state defines the state that will be used for the build
  21348. */
  21349. initialize(state: NodeMaterialBuildState): void;
  21350. get target(): NodeMaterialBlockTargets;
  21351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21352. isReady(): boolean;
  21353. private _injectVertexCode;
  21354. private _writeTextureRead;
  21355. private _writeOutput;
  21356. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21357. serialize(): any;
  21358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21359. }
  21360. }
  21361. declare module BABYLON {
  21362. /**
  21363. * Base block used for the particle texture
  21364. */
  21365. export class ParticleTextureBlock extends NodeMaterialBlock {
  21366. private _samplerName;
  21367. private _linearDefineName;
  21368. private _gammaDefineName;
  21369. private _tempTextureRead;
  21370. /**
  21371. * Gets or sets the texture associated with the node
  21372. */
  21373. texture: Nullable<BaseTexture>;
  21374. /**
  21375. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21376. */
  21377. convertToGammaSpace: boolean;
  21378. /**
  21379. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21380. */
  21381. convertToLinearSpace: boolean;
  21382. /**
  21383. * Create a new ParticleTextureBlock
  21384. * @param name defines the block name
  21385. */
  21386. constructor(name: string);
  21387. /**
  21388. * Gets the current class name
  21389. * @returns the class name
  21390. */
  21391. getClassName(): string;
  21392. /**
  21393. * Gets the uv input component
  21394. */
  21395. get uv(): NodeMaterialConnectionPoint;
  21396. /**
  21397. * Gets the rgba output component
  21398. */
  21399. get rgba(): NodeMaterialConnectionPoint;
  21400. /**
  21401. * Gets the rgb output component
  21402. */
  21403. get rgb(): NodeMaterialConnectionPoint;
  21404. /**
  21405. * Gets the r output component
  21406. */
  21407. get r(): NodeMaterialConnectionPoint;
  21408. /**
  21409. * Gets the g output component
  21410. */
  21411. get g(): NodeMaterialConnectionPoint;
  21412. /**
  21413. * Gets the b output component
  21414. */
  21415. get b(): NodeMaterialConnectionPoint;
  21416. /**
  21417. * Gets the a output component
  21418. */
  21419. get a(): NodeMaterialConnectionPoint;
  21420. /**
  21421. * Initialize the block and prepare the context for build
  21422. * @param state defines the state that will be used for the build
  21423. */
  21424. initialize(state: NodeMaterialBuildState): void;
  21425. autoConfigure(material: NodeMaterial): void;
  21426. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21427. isReady(): boolean;
  21428. private _writeOutput;
  21429. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21430. serialize(): any;
  21431. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21432. }
  21433. }
  21434. declare module BABYLON {
  21435. /**
  21436. * Class used to store shared data between 2 NodeMaterialBuildState
  21437. */
  21438. export class NodeMaterialBuildStateSharedData {
  21439. /**
  21440. * Gets the list of emitted varyings
  21441. */
  21442. temps: string[];
  21443. /**
  21444. * Gets the list of emitted varyings
  21445. */
  21446. varyings: string[];
  21447. /**
  21448. * Gets the varying declaration string
  21449. */
  21450. varyingDeclaration: string;
  21451. /**
  21452. * Input blocks
  21453. */
  21454. inputBlocks: InputBlock[];
  21455. /**
  21456. * Input blocks
  21457. */
  21458. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21459. /**
  21460. * Bindable blocks (Blocks that need to set data to the effect)
  21461. */
  21462. bindableBlocks: NodeMaterialBlock[];
  21463. /**
  21464. * List of blocks that can provide a compilation fallback
  21465. */
  21466. blocksWithFallbacks: NodeMaterialBlock[];
  21467. /**
  21468. * List of blocks that can provide a define update
  21469. */
  21470. blocksWithDefines: NodeMaterialBlock[];
  21471. /**
  21472. * List of blocks that can provide a repeatable content
  21473. */
  21474. repeatableContentBlocks: NodeMaterialBlock[];
  21475. /**
  21476. * List of blocks that can provide a dynamic list of uniforms
  21477. */
  21478. dynamicUniformBlocks: NodeMaterialBlock[];
  21479. /**
  21480. * List of blocks that can block the isReady function for the material
  21481. */
  21482. blockingBlocks: NodeMaterialBlock[];
  21483. /**
  21484. * Gets the list of animated inputs
  21485. */
  21486. animatedInputs: InputBlock[];
  21487. /**
  21488. * Build Id used to avoid multiple recompilations
  21489. */
  21490. buildId: number;
  21491. /** List of emitted variables */
  21492. variableNames: {
  21493. [key: string]: number;
  21494. };
  21495. /** List of emitted defines */
  21496. defineNames: {
  21497. [key: string]: number;
  21498. };
  21499. /** Should emit comments? */
  21500. emitComments: boolean;
  21501. /** Emit build activity */
  21502. verbose: boolean;
  21503. /** Gets or sets the hosting scene */
  21504. scene: Scene;
  21505. /**
  21506. * Gets the compilation hints emitted at compilation time
  21507. */
  21508. hints: {
  21509. needWorldViewMatrix: boolean;
  21510. needWorldViewProjectionMatrix: boolean;
  21511. needAlphaBlending: boolean;
  21512. needAlphaTesting: boolean;
  21513. };
  21514. /**
  21515. * List of compilation checks
  21516. */
  21517. checks: {
  21518. emitVertex: boolean;
  21519. emitFragment: boolean;
  21520. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21521. };
  21522. /**
  21523. * Is vertex program allowed to be empty?
  21524. */
  21525. allowEmptyVertexProgram: boolean;
  21526. /** Creates a new shared data */
  21527. constructor();
  21528. /**
  21529. * Emits console errors and exceptions if there is a failing check
  21530. */
  21531. emitErrors(): void;
  21532. }
  21533. }
  21534. declare module BABYLON {
  21535. /**
  21536. * Class used to store node based material build state
  21537. */
  21538. export class NodeMaterialBuildState {
  21539. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21540. supportUniformBuffers: boolean;
  21541. /**
  21542. * Gets the list of emitted attributes
  21543. */
  21544. attributes: string[];
  21545. /**
  21546. * Gets the list of emitted uniforms
  21547. */
  21548. uniforms: string[];
  21549. /**
  21550. * Gets the list of emitted constants
  21551. */
  21552. constants: string[];
  21553. /**
  21554. * Gets the list of emitted samplers
  21555. */
  21556. samplers: string[];
  21557. /**
  21558. * Gets the list of emitted functions
  21559. */
  21560. functions: {
  21561. [key: string]: string;
  21562. };
  21563. /**
  21564. * Gets the list of emitted extensions
  21565. */
  21566. extensions: {
  21567. [key: string]: string;
  21568. };
  21569. /**
  21570. * Gets the target of the compilation state
  21571. */
  21572. target: NodeMaterialBlockTargets;
  21573. /**
  21574. * Gets the list of emitted counters
  21575. */
  21576. counters: {
  21577. [key: string]: number;
  21578. };
  21579. /**
  21580. * Shared data between multiple NodeMaterialBuildState instances
  21581. */
  21582. sharedData: NodeMaterialBuildStateSharedData;
  21583. /** @hidden */
  21584. _vertexState: NodeMaterialBuildState;
  21585. /** @hidden */
  21586. _attributeDeclaration: string;
  21587. /** @hidden */
  21588. _uniformDeclaration: string;
  21589. /** @hidden */
  21590. _constantDeclaration: string;
  21591. /** @hidden */
  21592. _samplerDeclaration: string;
  21593. /** @hidden */
  21594. _varyingTransfer: string;
  21595. /** @hidden */
  21596. _injectAtEnd: string;
  21597. private _repeatableContentAnchorIndex;
  21598. /** @hidden */
  21599. _builtCompilationString: string;
  21600. /**
  21601. * Gets the emitted compilation strings
  21602. */
  21603. compilationString: string;
  21604. /**
  21605. * Finalize the compilation strings
  21606. * @param state defines the current compilation state
  21607. */
  21608. finalize(state: NodeMaterialBuildState): void;
  21609. /** @hidden */
  21610. get _repeatableContentAnchor(): string;
  21611. /** @hidden */
  21612. _getFreeVariableName(prefix: string): string;
  21613. /** @hidden */
  21614. _getFreeDefineName(prefix: string): string;
  21615. /** @hidden */
  21616. _excludeVariableName(name: string): void;
  21617. /** @hidden */
  21618. _emit2DSampler(name: string): void;
  21619. /** @hidden */
  21620. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21621. /** @hidden */
  21622. _emitExtension(name: string, extension: string, define?: string): void;
  21623. /** @hidden */
  21624. _emitFunction(name: string, code: string, comments: string): void;
  21625. /** @hidden */
  21626. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21627. replaceStrings?: {
  21628. search: RegExp;
  21629. replace: string;
  21630. }[];
  21631. repeatKey?: string;
  21632. }): string;
  21633. /** @hidden */
  21634. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21635. repeatKey?: string;
  21636. removeAttributes?: boolean;
  21637. removeUniforms?: boolean;
  21638. removeVaryings?: boolean;
  21639. removeIfDef?: boolean;
  21640. replaceStrings?: {
  21641. search: RegExp;
  21642. replace: string;
  21643. }[];
  21644. }, storeKey?: string): void;
  21645. /** @hidden */
  21646. _registerTempVariable(name: string): boolean;
  21647. /** @hidden */
  21648. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21649. /** @hidden */
  21650. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21651. /** @hidden */
  21652. _emitFloat(value: number): string;
  21653. }
  21654. }
  21655. declare module BABYLON {
  21656. /**
  21657. * Helper class used to generate session unique ID
  21658. */
  21659. export class UniqueIdGenerator {
  21660. private static _UniqueIdCounter;
  21661. /**
  21662. * Gets an unique (relatively to the current scene) Id
  21663. */
  21664. static get UniqueId(): number;
  21665. }
  21666. }
  21667. declare module BABYLON {
  21668. /**
  21669. * Defines a block that can be used inside a node based material
  21670. */
  21671. export class NodeMaterialBlock {
  21672. private _buildId;
  21673. private _buildTarget;
  21674. private _target;
  21675. private _isFinalMerger;
  21676. private _isInput;
  21677. private _name;
  21678. protected _isUnique: boolean;
  21679. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21680. inputsAreExclusive: boolean;
  21681. /** @hidden */
  21682. _codeVariableName: string;
  21683. /** @hidden */
  21684. _inputs: NodeMaterialConnectionPoint[];
  21685. /** @hidden */
  21686. _outputs: NodeMaterialConnectionPoint[];
  21687. /** @hidden */
  21688. _preparationId: number;
  21689. /**
  21690. * Gets the name of the block
  21691. */
  21692. get name(): string;
  21693. /**
  21694. * Sets the name of the block. Will check if the name is valid.
  21695. */
  21696. set name(newName: string);
  21697. /**
  21698. * Gets or sets the unique id of the node
  21699. */
  21700. uniqueId: number;
  21701. /**
  21702. * Gets or sets the comments associated with this block
  21703. */
  21704. comments: string;
  21705. /**
  21706. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21707. */
  21708. get isUnique(): boolean;
  21709. /**
  21710. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21711. */
  21712. get isFinalMerger(): boolean;
  21713. /**
  21714. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21715. */
  21716. get isInput(): boolean;
  21717. /**
  21718. * Gets or sets the build Id
  21719. */
  21720. get buildId(): number;
  21721. set buildId(value: number);
  21722. /**
  21723. * Gets or sets the target of the block
  21724. */
  21725. get target(): NodeMaterialBlockTargets;
  21726. set target(value: NodeMaterialBlockTargets);
  21727. /**
  21728. * Gets the list of input points
  21729. */
  21730. get inputs(): NodeMaterialConnectionPoint[];
  21731. /** Gets the list of output points */
  21732. get outputs(): NodeMaterialConnectionPoint[];
  21733. /**
  21734. * Find an input by its name
  21735. * @param name defines the name of the input to look for
  21736. * @returns the input or null if not found
  21737. */
  21738. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21739. /**
  21740. * Find an output by its name
  21741. * @param name defines the name of the outputto look for
  21742. * @returns the output or null if not found
  21743. */
  21744. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21745. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21746. visibleInInspector: boolean;
  21747. /**
  21748. * Creates a new NodeMaterialBlock
  21749. * @param name defines the block name
  21750. * @param target defines the target of that block (Vertex by default)
  21751. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21752. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21753. */
  21754. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21755. /**
  21756. * Initialize the block and prepare the context for build
  21757. * @param state defines the state that will be used for the build
  21758. */
  21759. initialize(state: NodeMaterialBuildState): void;
  21760. /**
  21761. * Bind data to effect. Will only be called for blocks with isBindable === true
  21762. * @param effect defines the effect to bind data to
  21763. * @param nodeMaterial defines the hosting NodeMaterial
  21764. * @param mesh defines the mesh that will be rendered
  21765. * @param subMesh defines the submesh that will be rendered
  21766. */
  21767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21768. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21769. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21770. protected _writeFloat(value: number): string;
  21771. /**
  21772. * Gets the current class name e.g. "NodeMaterialBlock"
  21773. * @returns the class name
  21774. */
  21775. getClassName(): string;
  21776. /**
  21777. * Register a new input. Must be called inside a block constructor
  21778. * @param name defines the connection point name
  21779. * @param type defines the connection point type
  21780. * @param isOptional defines a boolean indicating that this input can be omitted
  21781. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21782. * @param point an already created connection point. If not provided, create a new one
  21783. * @returns the current block
  21784. */
  21785. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21786. /**
  21787. * Register a new output. Must be called inside a block constructor
  21788. * @param name defines the connection point name
  21789. * @param type defines the connection point type
  21790. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21791. * @param point an already created connection point. If not provided, create a new one
  21792. * @returns the current block
  21793. */
  21794. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21795. /**
  21796. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21797. * @param forOutput defines an optional connection point to check compatibility with
  21798. * @returns the first available input or null
  21799. */
  21800. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21801. /**
  21802. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21803. * @param forBlock defines an optional block to check compatibility with
  21804. * @returns the first available input or null
  21805. */
  21806. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21807. /**
  21808. * Gets the sibling of the given output
  21809. * @param current defines the current output
  21810. * @returns the next output in the list or null
  21811. */
  21812. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21813. /**
  21814. * Connect current block with another block
  21815. * @param other defines the block to connect with
  21816. * @param options define the various options to help pick the right connections
  21817. * @returns the current block
  21818. */
  21819. connectTo(other: NodeMaterialBlock, options?: {
  21820. input?: string;
  21821. output?: string;
  21822. outputSwizzle?: string;
  21823. }): this | undefined;
  21824. protected _buildBlock(state: NodeMaterialBuildState): void;
  21825. /**
  21826. * Add uniforms, samplers and uniform buffers at compilation time
  21827. * @param state defines the state to update
  21828. * @param nodeMaterial defines the node material requesting the update
  21829. * @param defines defines the material defines to update
  21830. * @param uniformBuffers defines the list of uniform buffer names
  21831. */
  21832. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21833. /**
  21834. * Add potential fallbacks if shader compilation fails
  21835. * @param mesh defines the mesh to be rendered
  21836. * @param fallbacks defines the current prioritized list of fallbacks
  21837. */
  21838. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21839. /**
  21840. * Initialize defines for shader compilation
  21841. * @param mesh defines the mesh to be rendered
  21842. * @param nodeMaterial defines the node material requesting the update
  21843. * @param defines defines the material defines to update
  21844. * @param useInstances specifies that instances should be used
  21845. */
  21846. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21847. /**
  21848. * Update defines for shader compilation
  21849. * @param mesh defines the mesh to be rendered
  21850. * @param nodeMaterial defines the node material requesting the update
  21851. * @param defines defines the material defines to update
  21852. * @param useInstances specifies that instances should be used
  21853. * @param subMesh defines which submesh to render
  21854. */
  21855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21856. /**
  21857. * Lets the block try to connect some inputs automatically
  21858. * @param material defines the hosting NodeMaterial
  21859. */
  21860. autoConfigure(material: NodeMaterial): void;
  21861. /**
  21862. * Function called when a block is declared as repeatable content generator
  21863. * @param vertexShaderState defines the current compilation state for the vertex shader
  21864. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21865. * @param mesh defines the mesh to be rendered
  21866. * @param defines defines the material defines to update
  21867. */
  21868. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21869. /**
  21870. * Checks if the block is ready
  21871. * @param mesh defines the mesh to be rendered
  21872. * @param nodeMaterial defines the node material requesting the update
  21873. * @param defines defines the material defines to update
  21874. * @param useInstances specifies that instances should be used
  21875. * @returns true if the block is ready
  21876. */
  21877. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21878. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21879. private _processBuild;
  21880. /**
  21881. * Validates the new name for the block node.
  21882. * @param newName the new name to be given to the node.
  21883. * @returns false if the name is a reserve word, else true.
  21884. */
  21885. validateBlockName(newName: string): boolean;
  21886. /**
  21887. * Compile the current node and generate the shader code
  21888. * @param state defines the current compilation state (uniforms, samplers, current string)
  21889. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21890. * @returns true if already built
  21891. */
  21892. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21893. protected _inputRename(name: string): string;
  21894. protected _outputRename(name: string): string;
  21895. protected _dumpPropertiesCode(): string;
  21896. /** @hidden */
  21897. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21898. /** @hidden */
  21899. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21900. /**
  21901. * Clone the current block to a new identical block
  21902. * @param scene defines the hosting scene
  21903. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21904. * @returns a copy of the current block
  21905. */
  21906. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21907. /**
  21908. * Serializes this block in a JSON representation
  21909. * @returns the serialized block object
  21910. */
  21911. serialize(): any;
  21912. /** @hidden */
  21913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21914. private _deserializePortDisplayNamesAndExposedOnFrame;
  21915. /**
  21916. * Release resources
  21917. */
  21918. dispose(): void;
  21919. }
  21920. }
  21921. declare module BABYLON {
  21922. /**
  21923. * Base class of materials working in push mode in babylon JS
  21924. * @hidden
  21925. */
  21926. export class PushMaterial extends Material {
  21927. protected _activeEffect: Effect;
  21928. protected _normalMatrix: Matrix;
  21929. constructor(name: string, scene: Scene);
  21930. getEffect(): Effect;
  21931. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21932. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21933. /**
  21934. * Binds the given world matrix to the active effect
  21935. *
  21936. * @param world the matrix to bind
  21937. */
  21938. bindOnlyWorldMatrix(world: Matrix): void;
  21939. /**
  21940. * Binds the given normal matrix to the active effect
  21941. *
  21942. * @param normalMatrix the matrix to bind
  21943. */
  21944. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21945. bind(world: Matrix, mesh?: Mesh): void;
  21946. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21947. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21948. }
  21949. }
  21950. declare module BABYLON {
  21951. /**
  21952. * Root class for all node material optimizers
  21953. */
  21954. export class NodeMaterialOptimizer {
  21955. /**
  21956. * Function used to optimize a NodeMaterial graph
  21957. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21958. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21959. */
  21960. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21961. }
  21962. }
  21963. declare module BABYLON {
  21964. /**
  21965. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21966. */
  21967. export class TransformBlock extends NodeMaterialBlock {
  21968. /**
  21969. * Defines the value to use to complement W value to transform it to a Vector4
  21970. */
  21971. complementW: number;
  21972. /**
  21973. * Defines the value to use to complement z value to transform it to a Vector4
  21974. */
  21975. complementZ: number;
  21976. /**
  21977. * Creates a new TransformBlock
  21978. * @param name defines the block name
  21979. */
  21980. constructor(name: string);
  21981. /**
  21982. * Gets the current class name
  21983. * @returns the class name
  21984. */
  21985. getClassName(): string;
  21986. /**
  21987. * Gets the vector input
  21988. */
  21989. get vector(): NodeMaterialConnectionPoint;
  21990. /**
  21991. * Gets the output component
  21992. */
  21993. get output(): NodeMaterialConnectionPoint;
  21994. /**
  21995. * Gets the xyz output component
  21996. */
  21997. get xyz(): NodeMaterialConnectionPoint;
  21998. /**
  21999. * Gets the matrix transform input
  22000. */
  22001. get transform(): NodeMaterialConnectionPoint;
  22002. protected _buildBlock(state: NodeMaterialBuildState): this;
  22003. /**
  22004. * Update defines for shader compilation
  22005. * @param mesh defines the mesh to be rendered
  22006. * @param nodeMaterial defines the node material requesting the update
  22007. * @param defines defines the material defines to update
  22008. * @param useInstances specifies that instances should be used
  22009. * @param subMesh defines which submesh to render
  22010. */
  22011. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22012. serialize(): any;
  22013. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22014. protected _dumpPropertiesCode(): string;
  22015. }
  22016. }
  22017. declare module BABYLON {
  22018. /**
  22019. * Block used to output the vertex position
  22020. */
  22021. export class VertexOutputBlock extends NodeMaterialBlock {
  22022. /**
  22023. * Creates a new VertexOutputBlock
  22024. * @param name defines the block name
  22025. */
  22026. constructor(name: string);
  22027. /**
  22028. * Gets the current class name
  22029. * @returns the class name
  22030. */
  22031. getClassName(): string;
  22032. /**
  22033. * Gets the vector input component
  22034. */
  22035. get vector(): NodeMaterialConnectionPoint;
  22036. protected _buildBlock(state: NodeMaterialBuildState): this;
  22037. }
  22038. }
  22039. declare module BABYLON {
  22040. /**
  22041. * Block used to output the final color
  22042. */
  22043. export class FragmentOutputBlock extends NodeMaterialBlock {
  22044. /**
  22045. * Create a new FragmentOutputBlock
  22046. * @param name defines the block name
  22047. */
  22048. constructor(name: string);
  22049. /**
  22050. * Gets the current class name
  22051. * @returns the class name
  22052. */
  22053. getClassName(): string;
  22054. /**
  22055. * Gets the rgba input component
  22056. */
  22057. get rgba(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the rgb input component
  22060. */
  22061. get rgb(): NodeMaterialConnectionPoint;
  22062. /**
  22063. * Gets the a input component
  22064. */
  22065. get a(): NodeMaterialConnectionPoint;
  22066. protected _buildBlock(state: NodeMaterialBuildState): this;
  22067. }
  22068. }
  22069. declare module BABYLON {
  22070. /**
  22071. * Block used for the particle ramp gradient section
  22072. */
  22073. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22074. /**
  22075. * Create a new ParticleRampGradientBlock
  22076. * @param name defines the block name
  22077. */
  22078. constructor(name: string);
  22079. /**
  22080. * Gets the current class name
  22081. * @returns the class name
  22082. */
  22083. getClassName(): string;
  22084. /**
  22085. * Gets the color input component
  22086. */
  22087. get color(): NodeMaterialConnectionPoint;
  22088. /**
  22089. * Gets the rampColor output component
  22090. */
  22091. get rampColor(): NodeMaterialConnectionPoint;
  22092. /**
  22093. * Initialize the block and prepare the context for build
  22094. * @param state defines the state that will be used for the build
  22095. */
  22096. initialize(state: NodeMaterialBuildState): void;
  22097. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22098. }
  22099. }
  22100. declare module BABYLON {
  22101. /**
  22102. * Block used for the particle blend multiply section
  22103. */
  22104. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22105. /**
  22106. * Create a new ParticleBlendMultiplyBlock
  22107. * @param name defines the block name
  22108. */
  22109. constructor(name: string);
  22110. /**
  22111. * Gets the current class name
  22112. * @returns the class name
  22113. */
  22114. getClassName(): string;
  22115. /**
  22116. * Gets the color input component
  22117. */
  22118. get color(): NodeMaterialConnectionPoint;
  22119. /**
  22120. * Gets the alphaTexture input component
  22121. */
  22122. get alphaTexture(): NodeMaterialConnectionPoint;
  22123. /**
  22124. * Gets the alphaColor input component
  22125. */
  22126. get alphaColor(): NodeMaterialConnectionPoint;
  22127. /**
  22128. * Gets the blendColor output component
  22129. */
  22130. get blendColor(): NodeMaterialConnectionPoint;
  22131. /**
  22132. * Initialize the block and prepare the context for build
  22133. * @param state defines the state that will be used for the build
  22134. */
  22135. initialize(state: NodeMaterialBuildState): void;
  22136. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22137. }
  22138. }
  22139. declare module BABYLON {
  22140. /**
  22141. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22142. */
  22143. export class VectorMergerBlock extends NodeMaterialBlock {
  22144. /**
  22145. * Create a new VectorMergerBlock
  22146. * @param name defines the block name
  22147. */
  22148. constructor(name: string);
  22149. /**
  22150. * Gets the current class name
  22151. * @returns the class name
  22152. */
  22153. getClassName(): string;
  22154. /**
  22155. * Gets the xyz component (input)
  22156. */
  22157. get xyzIn(): NodeMaterialConnectionPoint;
  22158. /**
  22159. * Gets the xy component (input)
  22160. */
  22161. get xyIn(): NodeMaterialConnectionPoint;
  22162. /**
  22163. * Gets the x component (input)
  22164. */
  22165. get x(): NodeMaterialConnectionPoint;
  22166. /**
  22167. * Gets the y component (input)
  22168. */
  22169. get y(): NodeMaterialConnectionPoint;
  22170. /**
  22171. * Gets the z component (input)
  22172. */
  22173. get z(): NodeMaterialConnectionPoint;
  22174. /**
  22175. * Gets the w component (input)
  22176. */
  22177. get w(): NodeMaterialConnectionPoint;
  22178. /**
  22179. * Gets the xyzw component (output)
  22180. */
  22181. get xyzw(): NodeMaterialConnectionPoint;
  22182. /**
  22183. * Gets the xyz component (output)
  22184. */
  22185. get xyzOut(): NodeMaterialConnectionPoint;
  22186. /**
  22187. * Gets the xy component (output)
  22188. */
  22189. get xyOut(): NodeMaterialConnectionPoint;
  22190. /**
  22191. * Gets the xy component (output)
  22192. * @deprecated Please use xyOut instead.
  22193. */
  22194. get xy(): NodeMaterialConnectionPoint;
  22195. /**
  22196. * Gets the xyz component (output)
  22197. * @deprecated Please use xyzOut instead.
  22198. */
  22199. get xyz(): NodeMaterialConnectionPoint;
  22200. protected _buildBlock(state: NodeMaterialBuildState): this;
  22201. }
  22202. }
  22203. declare module BABYLON {
  22204. /**
  22205. * Block used to remap a float from a range to a new one
  22206. */
  22207. export class RemapBlock extends NodeMaterialBlock {
  22208. /**
  22209. * Gets or sets the source range
  22210. */
  22211. sourceRange: Vector2;
  22212. /**
  22213. * Gets or sets the target range
  22214. */
  22215. targetRange: Vector2;
  22216. /**
  22217. * Creates a new RemapBlock
  22218. * @param name defines the block name
  22219. */
  22220. constructor(name: string);
  22221. /**
  22222. * Gets the current class name
  22223. * @returns the class name
  22224. */
  22225. getClassName(): string;
  22226. /**
  22227. * Gets the input component
  22228. */
  22229. get input(): NodeMaterialConnectionPoint;
  22230. /**
  22231. * Gets the source min input component
  22232. */
  22233. get sourceMin(): NodeMaterialConnectionPoint;
  22234. /**
  22235. * Gets the source max input component
  22236. */
  22237. get sourceMax(): NodeMaterialConnectionPoint;
  22238. /**
  22239. * Gets the target min input component
  22240. */
  22241. get targetMin(): NodeMaterialConnectionPoint;
  22242. /**
  22243. * Gets the target max input component
  22244. */
  22245. get targetMax(): NodeMaterialConnectionPoint;
  22246. /**
  22247. * Gets the output component
  22248. */
  22249. get output(): NodeMaterialConnectionPoint;
  22250. protected _buildBlock(state: NodeMaterialBuildState): this;
  22251. protected _dumpPropertiesCode(): string;
  22252. serialize(): any;
  22253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22254. }
  22255. }
  22256. declare module BABYLON {
  22257. /**
  22258. * Block used to multiply 2 values
  22259. */
  22260. export class MultiplyBlock extends NodeMaterialBlock {
  22261. /**
  22262. * Creates a new MultiplyBlock
  22263. * @param name defines the block name
  22264. */
  22265. constructor(name: string);
  22266. /**
  22267. * Gets the current class name
  22268. * @returns the class name
  22269. */
  22270. getClassName(): string;
  22271. /**
  22272. * Gets the left operand input component
  22273. */
  22274. get left(): NodeMaterialConnectionPoint;
  22275. /**
  22276. * Gets the right operand input component
  22277. */
  22278. get right(): NodeMaterialConnectionPoint;
  22279. /**
  22280. * Gets the output component
  22281. */
  22282. get output(): NodeMaterialConnectionPoint;
  22283. protected _buildBlock(state: NodeMaterialBuildState): this;
  22284. }
  22285. }
  22286. declare module BABYLON {
  22287. /**
  22288. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22289. */
  22290. export class ColorSplitterBlock extends NodeMaterialBlock {
  22291. /**
  22292. * Create a new ColorSplitterBlock
  22293. * @param name defines the block name
  22294. */
  22295. constructor(name: string);
  22296. /**
  22297. * Gets the current class name
  22298. * @returns the class name
  22299. */
  22300. getClassName(): string;
  22301. /**
  22302. * Gets the rgba component (input)
  22303. */
  22304. get rgba(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the rgb component (input)
  22307. */
  22308. get rgbIn(): NodeMaterialConnectionPoint;
  22309. /**
  22310. * Gets the rgb component (output)
  22311. */
  22312. get rgbOut(): NodeMaterialConnectionPoint;
  22313. /**
  22314. * Gets the r component (output)
  22315. */
  22316. get r(): NodeMaterialConnectionPoint;
  22317. /**
  22318. * Gets the g component (output)
  22319. */
  22320. get g(): NodeMaterialConnectionPoint;
  22321. /**
  22322. * Gets the b component (output)
  22323. */
  22324. get b(): NodeMaterialConnectionPoint;
  22325. /**
  22326. * Gets the a component (output)
  22327. */
  22328. get a(): NodeMaterialConnectionPoint;
  22329. protected _inputRename(name: string): string;
  22330. protected _outputRename(name: string): string;
  22331. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22332. }
  22333. }
  22334. declare module BABYLON {
  22335. /**
  22336. * Operations supported by the Trigonometry block
  22337. */
  22338. export enum TrigonometryBlockOperations {
  22339. /** Cos */
  22340. Cos = 0,
  22341. /** Sin */
  22342. Sin = 1,
  22343. /** Abs */
  22344. Abs = 2,
  22345. /** Exp */
  22346. Exp = 3,
  22347. /** Exp2 */
  22348. Exp2 = 4,
  22349. /** Round */
  22350. Round = 5,
  22351. /** Floor */
  22352. Floor = 6,
  22353. /** Ceiling */
  22354. Ceiling = 7,
  22355. /** Square root */
  22356. Sqrt = 8,
  22357. /** Log */
  22358. Log = 9,
  22359. /** Tangent */
  22360. Tan = 10,
  22361. /** Arc tangent */
  22362. ArcTan = 11,
  22363. /** Arc cosinus */
  22364. ArcCos = 12,
  22365. /** Arc sinus */
  22366. ArcSin = 13,
  22367. /** Fraction */
  22368. Fract = 14,
  22369. /** Sign */
  22370. Sign = 15,
  22371. /** To radians (from degrees) */
  22372. Radians = 16,
  22373. /** To degrees (from radians) */
  22374. Degrees = 17
  22375. }
  22376. /**
  22377. * Block used to apply trigonometry operation to floats
  22378. */
  22379. export class TrigonometryBlock extends NodeMaterialBlock {
  22380. /**
  22381. * Gets or sets the operation applied by the block
  22382. */
  22383. operation: TrigonometryBlockOperations;
  22384. /**
  22385. * Creates a new TrigonometryBlock
  22386. * @param name defines the block name
  22387. */
  22388. constructor(name: string);
  22389. /**
  22390. * Gets the current class name
  22391. * @returns the class name
  22392. */
  22393. getClassName(): string;
  22394. /**
  22395. * Gets the input component
  22396. */
  22397. get input(): NodeMaterialConnectionPoint;
  22398. /**
  22399. * Gets the output component
  22400. */
  22401. get output(): NodeMaterialConnectionPoint;
  22402. protected _buildBlock(state: NodeMaterialBuildState): this;
  22403. serialize(): any;
  22404. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22405. protected _dumpPropertiesCode(): string;
  22406. }
  22407. }
  22408. declare module BABYLON {
  22409. /**
  22410. * Interface used to configure the node material editor
  22411. */
  22412. export interface INodeMaterialEditorOptions {
  22413. /** Define the URl to load node editor script */
  22414. editorURL?: string;
  22415. }
  22416. /** @hidden */
  22417. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22418. NORMAL: boolean;
  22419. TANGENT: boolean;
  22420. UV1: boolean;
  22421. /** BONES */
  22422. NUM_BONE_INFLUENCERS: number;
  22423. BonesPerMesh: number;
  22424. BONETEXTURE: boolean;
  22425. /** MORPH TARGETS */
  22426. MORPHTARGETS: boolean;
  22427. MORPHTARGETS_NORMAL: boolean;
  22428. MORPHTARGETS_TANGENT: boolean;
  22429. MORPHTARGETS_UV: boolean;
  22430. NUM_MORPH_INFLUENCERS: number;
  22431. /** IMAGE PROCESSING */
  22432. IMAGEPROCESSING: boolean;
  22433. VIGNETTE: boolean;
  22434. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22435. VIGNETTEBLENDMODEOPAQUE: boolean;
  22436. TONEMAPPING: boolean;
  22437. TONEMAPPING_ACES: boolean;
  22438. CONTRAST: boolean;
  22439. EXPOSURE: boolean;
  22440. COLORCURVES: boolean;
  22441. COLORGRADING: boolean;
  22442. COLORGRADING3D: boolean;
  22443. SAMPLER3DGREENDEPTH: boolean;
  22444. SAMPLER3DBGRMAP: boolean;
  22445. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22446. /** MISC. */
  22447. BUMPDIRECTUV: number;
  22448. constructor();
  22449. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22450. }
  22451. /**
  22452. * Class used to configure NodeMaterial
  22453. */
  22454. export interface INodeMaterialOptions {
  22455. /**
  22456. * Defines if blocks should emit comments
  22457. */
  22458. emitComments: boolean;
  22459. }
  22460. /**
  22461. * Class used to create a node based material built by assembling shader blocks
  22462. */
  22463. export class NodeMaterial extends PushMaterial {
  22464. private static _BuildIdGenerator;
  22465. private _options;
  22466. private _vertexCompilationState;
  22467. private _fragmentCompilationState;
  22468. private _sharedData;
  22469. private _buildId;
  22470. private _buildWasSuccessful;
  22471. private _cachedWorldViewMatrix;
  22472. private _cachedWorldViewProjectionMatrix;
  22473. private _optimizers;
  22474. private _animationFrame;
  22475. /** Define the Url to load node editor script */
  22476. static EditorURL: string;
  22477. /** Define the Url to load snippets */
  22478. static SnippetUrl: string;
  22479. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22480. static IgnoreTexturesAtLoadTime: boolean;
  22481. private BJSNODEMATERIALEDITOR;
  22482. /** Get the inspector from bundle or global */
  22483. private _getGlobalNodeMaterialEditor;
  22484. /**
  22485. * Snippet ID if the material was created from the snippet server
  22486. */
  22487. snippetId: string;
  22488. /**
  22489. * Gets or sets data used by visual editor
  22490. * @see https://nme.babylonjs.com
  22491. */
  22492. editorData: any;
  22493. /**
  22494. * 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)
  22495. */
  22496. ignoreAlpha: boolean;
  22497. /**
  22498. * Defines the maximum number of lights that can be used in the material
  22499. */
  22500. maxSimultaneousLights: number;
  22501. /**
  22502. * Observable raised when the material is built
  22503. */
  22504. onBuildObservable: Observable<NodeMaterial>;
  22505. /**
  22506. * Gets or sets the root nodes of the material vertex shader
  22507. */
  22508. _vertexOutputNodes: NodeMaterialBlock[];
  22509. /**
  22510. * Gets or sets the root nodes of the material fragment (pixel) shader
  22511. */
  22512. _fragmentOutputNodes: NodeMaterialBlock[];
  22513. /** Gets or sets options to control the node material overall behavior */
  22514. get options(): INodeMaterialOptions;
  22515. set options(options: INodeMaterialOptions);
  22516. /**
  22517. * Default configuration related to image processing available in the standard Material.
  22518. */
  22519. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22520. /**
  22521. * Gets the image processing configuration used either in this material.
  22522. */
  22523. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22524. /**
  22525. * Sets the Default image processing configuration used either in the this material.
  22526. *
  22527. * If sets to null, the scene one is in use.
  22528. */
  22529. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22530. /**
  22531. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22532. */
  22533. attachedBlocks: NodeMaterialBlock[];
  22534. /**
  22535. * Specifies the mode of the node material
  22536. * @hidden
  22537. */
  22538. _mode: NodeMaterialModes;
  22539. /**
  22540. * Gets the mode property
  22541. */
  22542. get mode(): NodeMaterialModes;
  22543. /**
  22544. * Create a new node based material
  22545. * @param name defines the material name
  22546. * @param scene defines the hosting scene
  22547. * @param options defines creation option
  22548. */
  22549. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22550. /**
  22551. * Gets the current class name of the material e.g. "NodeMaterial"
  22552. * @returns the class name
  22553. */
  22554. getClassName(): string;
  22555. /**
  22556. * Keep track of the image processing observer to allow dispose and replace.
  22557. */
  22558. private _imageProcessingObserver;
  22559. /**
  22560. * Attaches a new image processing configuration to the Standard Material.
  22561. * @param configuration
  22562. */
  22563. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22564. /**
  22565. * Get a block by its name
  22566. * @param name defines the name of the block to retrieve
  22567. * @returns the required block or null if not found
  22568. */
  22569. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22570. /**
  22571. * Get a block by its name
  22572. * @param predicate defines the predicate used to find the good candidate
  22573. * @returns the required block or null if not found
  22574. */
  22575. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22576. /**
  22577. * Get an input block by its name
  22578. * @param predicate defines the predicate used to find the good candidate
  22579. * @returns the required input block or null if not found
  22580. */
  22581. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22582. /**
  22583. * Gets the list of input blocks attached to this material
  22584. * @returns an array of InputBlocks
  22585. */
  22586. getInputBlocks(): InputBlock[];
  22587. /**
  22588. * Adds a new optimizer to the list of optimizers
  22589. * @param optimizer defines the optimizers to add
  22590. * @returns the current material
  22591. */
  22592. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22593. /**
  22594. * Remove an optimizer from the list of optimizers
  22595. * @param optimizer defines the optimizers to remove
  22596. * @returns the current material
  22597. */
  22598. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22599. /**
  22600. * Add a new block to the list of output nodes
  22601. * @param node defines the node to add
  22602. * @returns the current material
  22603. */
  22604. addOutputNode(node: NodeMaterialBlock): this;
  22605. /**
  22606. * Remove a block from the list of root nodes
  22607. * @param node defines the node to remove
  22608. * @returns the current material
  22609. */
  22610. removeOutputNode(node: NodeMaterialBlock): this;
  22611. private _addVertexOutputNode;
  22612. private _removeVertexOutputNode;
  22613. private _addFragmentOutputNode;
  22614. private _removeFragmentOutputNode;
  22615. /**
  22616. * Specifies if the material will require alpha blending
  22617. * @returns a boolean specifying if alpha blending is needed
  22618. */
  22619. needAlphaBlending(): boolean;
  22620. /**
  22621. * Specifies if this material should be rendered in alpha test mode
  22622. * @returns a boolean specifying if an alpha test is needed.
  22623. */
  22624. needAlphaTesting(): boolean;
  22625. private _initializeBlock;
  22626. private _resetDualBlocks;
  22627. /**
  22628. * Remove a block from the current node material
  22629. * @param block defines the block to remove
  22630. */
  22631. removeBlock(block: NodeMaterialBlock): void;
  22632. /**
  22633. * Build the material and generates the inner effect
  22634. * @param verbose defines if the build should log activity
  22635. */
  22636. build(verbose?: boolean): void;
  22637. /**
  22638. * Runs an otpimization phase to try to improve the shader code
  22639. */
  22640. optimize(): void;
  22641. private _prepareDefinesForAttributes;
  22642. /**
  22643. * Create a post process from the material
  22644. * @param camera The camera to apply the render pass to.
  22645. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22646. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22647. * @param engine The engine which the post process will be applied. (default: current engine)
  22648. * @param reusable If the post process can be reused on the same frame. (default: false)
  22649. * @param textureType Type of textures used when performing the post process. (default: 0)
  22650. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22651. * @returns the post process created
  22652. */
  22653. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22654. /**
  22655. * Create the post process effect from the material
  22656. * @param postProcess The post process to create the effect for
  22657. */
  22658. createEffectForPostProcess(postProcess: PostProcess): void;
  22659. private _createEffectForPostProcess;
  22660. /**
  22661. * Create a new procedural texture based on this node material
  22662. * @param size defines the size of the texture
  22663. * @param scene defines the hosting scene
  22664. * @returns the new procedural texture attached to this node material
  22665. */
  22666. createProceduralTexture(size: number | {
  22667. width: number;
  22668. height: number;
  22669. layers?: number;
  22670. }, scene: Scene): Nullable<ProceduralTexture>;
  22671. private _createEffectForParticles;
  22672. private _checkInternals;
  22673. /**
  22674. * Create the effect to be used as the custom effect for a particle system
  22675. * @param particleSystem Particle system to create the effect for
  22676. * @param onCompiled defines a function to call when the effect creation is successful
  22677. * @param onError defines a function to call when the effect creation has failed
  22678. */
  22679. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22680. private _processDefines;
  22681. /**
  22682. * Get if the submesh is ready to be used and all its information available.
  22683. * Child classes can use it to update shaders
  22684. * @param mesh defines the mesh to check
  22685. * @param subMesh defines which submesh to check
  22686. * @param useInstances specifies that instances should be used
  22687. * @returns a boolean indicating that the submesh is ready or not
  22688. */
  22689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22690. /**
  22691. * Get a string representing the shaders built by the current node graph
  22692. */
  22693. get compiledShaders(): string;
  22694. /**
  22695. * Binds the world matrix to the material
  22696. * @param world defines the world transformation matrix
  22697. */
  22698. bindOnlyWorldMatrix(world: Matrix): void;
  22699. /**
  22700. * Binds the submesh to this material by preparing the effect and shader to draw
  22701. * @param world defines the world transformation matrix
  22702. * @param mesh defines the mesh containing the submesh
  22703. * @param subMesh defines the submesh to bind the material to
  22704. */
  22705. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22706. /**
  22707. * Gets the active textures from the material
  22708. * @returns an array of textures
  22709. */
  22710. getActiveTextures(): BaseTexture[];
  22711. /**
  22712. * Gets the list of texture blocks
  22713. * @returns an array of texture blocks
  22714. */
  22715. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22716. /**
  22717. * Specifies if the material uses a texture
  22718. * @param texture defines the texture to check against the material
  22719. * @returns a boolean specifying if the material uses the texture
  22720. */
  22721. hasTexture(texture: BaseTexture): boolean;
  22722. /**
  22723. * Disposes the material
  22724. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22725. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22726. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22727. */
  22728. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22729. /** Creates the node editor window. */
  22730. private _createNodeEditor;
  22731. /**
  22732. * Launch the node material editor
  22733. * @param config Define the configuration of the editor
  22734. * @return a promise fulfilled when the node editor is visible
  22735. */
  22736. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22737. /**
  22738. * Clear the current material
  22739. */
  22740. clear(): void;
  22741. /**
  22742. * Clear the current material and set it to a default state
  22743. */
  22744. setToDefault(): void;
  22745. /**
  22746. * Clear the current material and set it to a default state for post process
  22747. */
  22748. setToDefaultPostProcess(): void;
  22749. /**
  22750. * Clear the current material and set it to a default state for procedural texture
  22751. */
  22752. setToDefaultProceduralTexture(): void;
  22753. /**
  22754. * Clear the current material and set it to a default state for particle
  22755. */
  22756. setToDefaultParticle(): void;
  22757. /**
  22758. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22759. * @param url defines the url to load from
  22760. * @returns a promise that will fullfil when the material is fully loaded
  22761. */
  22762. loadAsync(url: string): Promise<void>;
  22763. private _gatherBlocks;
  22764. /**
  22765. * Generate a string containing the code declaration required to create an equivalent of this material
  22766. * @returns a string
  22767. */
  22768. generateCode(): string;
  22769. /**
  22770. * Serializes this material in a JSON representation
  22771. * @returns the serialized material object
  22772. */
  22773. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22774. private _restoreConnections;
  22775. /**
  22776. * Clear the current graph and load a new one from a serialization object
  22777. * @param source defines the JSON representation of the material
  22778. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22779. * @param merge defines whether or not the source must be merged or replace the current content
  22780. */
  22781. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22782. /**
  22783. * Makes a duplicate of the current material.
  22784. * @param name - name to use for the new material.
  22785. */
  22786. clone(name: string): NodeMaterial;
  22787. /**
  22788. * Creates a node material from parsed material data
  22789. * @param source defines the JSON representation of the material
  22790. * @param scene defines the hosting scene
  22791. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22792. * @returns a new node material
  22793. */
  22794. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22795. /**
  22796. * Creates a node material from a snippet saved in a remote file
  22797. * @param name defines the name of the material to create
  22798. * @param url defines the url to load from
  22799. * @param scene defines the hosting scene
  22800. * @returns a promise that will resolve to the new node material
  22801. */
  22802. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22803. /**
  22804. * Creates a node material from a snippet saved by the node material editor
  22805. * @param snippetId defines the snippet to load
  22806. * @param scene defines the hosting scene
  22807. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22808. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22809. * @returns a promise that will resolve to the new node material
  22810. */
  22811. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22812. /**
  22813. * Creates a new node material set to default basic configuration
  22814. * @param name defines the name of the material
  22815. * @param scene defines the hosting scene
  22816. * @returns a new NodeMaterial
  22817. */
  22818. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22819. }
  22820. }
  22821. declare module BABYLON {
  22822. interface ThinEngine {
  22823. /**
  22824. * Unbind a list of render target textures from the webGL context
  22825. * This is used only when drawBuffer extension or webGL2 are active
  22826. * @param textures defines the render target textures to unbind
  22827. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22828. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22829. */
  22830. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22831. /**
  22832. * Create a multi render target texture
  22833. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22834. * @param size defines the size of the texture
  22835. * @param options defines the creation options
  22836. * @returns the cube texture as an InternalTexture
  22837. */
  22838. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22839. /**
  22840. * Update the sample count for a given multiple render target texture
  22841. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22842. * @param textures defines the textures to update
  22843. * @param samples defines the sample count to set
  22844. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22845. */
  22846. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22847. /**
  22848. * Select a subsets of attachments to draw to.
  22849. * @param attachments gl attachments
  22850. */
  22851. bindAttachments(attachments: number[]): void;
  22852. }
  22853. }
  22854. declare module BABYLON {
  22855. /**
  22856. * Creation options of the multi render target texture.
  22857. */
  22858. export interface IMultiRenderTargetOptions {
  22859. /**
  22860. * Define if the texture needs to create mip maps after render.
  22861. */
  22862. generateMipMaps?: boolean;
  22863. /**
  22864. * Define the types of all the draw buffers we want to create
  22865. */
  22866. types?: number[];
  22867. /**
  22868. * Define the sampling modes of all the draw buffers we want to create
  22869. */
  22870. samplingModes?: number[];
  22871. /**
  22872. * Define if a depth buffer is required
  22873. */
  22874. generateDepthBuffer?: boolean;
  22875. /**
  22876. * Define if a stencil buffer is required
  22877. */
  22878. generateStencilBuffer?: boolean;
  22879. /**
  22880. * Define if a depth texture is required instead of a depth buffer
  22881. */
  22882. generateDepthTexture?: boolean;
  22883. /**
  22884. * Define the number of desired draw buffers
  22885. */
  22886. textureCount?: number;
  22887. /**
  22888. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22889. */
  22890. doNotChangeAspectRatio?: boolean;
  22891. /**
  22892. * Define the default type of the buffers we are creating
  22893. */
  22894. defaultType?: number;
  22895. }
  22896. /**
  22897. * A multi render target, like a render target provides the ability to render to a texture.
  22898. * Unlike the render target, it can render to several draw buffers in one draw.
  22899. * This is specially interesting in deferred rendering or for any effects requiring more than
  22900. * just one color from a single pass.
  22901. */
  22902. export class MultiRenderTarget extends RenderTargetTexture {
  22903. private _internalTextures;
  22904. private _textures;
  22905. private _multiRenderTargetOptions;
  22906. private _count;
  22907. /**
  22908. * Get if draw buffers are currently supported by the used hardware and browser.
  22909. */
  22910. get isSupported(): boolean;
  22911. /**
  22912. * Get the list of textures generated by the multi render target.
  22913. */
  22914. get textures(): Texture[];
  22915. /**
  22916. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22917. */
  22918. get count(): number;
  22919. /**
  22920. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22921. */
  22922. get depthTexture(): Texture;
  22923. /**
  22924. * Set the wrapping mode on U of all the textures we are rendering to.
  22925. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22926. */
  22927. set wrapU(wrap: number);
  22928. /**
  22929. * Set the wrapping mode on V of all the textures we are rendering to.
  22930. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22931. */
  22932. set wrapV(wrap: number);
  22933. /**
  22934. * Instantiate a new multi render target texture.
  22935. * A multi render target, like a render target provides the ability to render to a texture.
  22936. * Unlike the render target, it can render to several draw buffers in one draw.
  22937. * This is specially interesting in deferred rendering or for any effects requiring more than
  22938. * just one color from a single pass.
  22939. * @param name Define the name of the texture
  22940. * @param size Define the size of the buffers to render to
  22941. * @param count Define the number of target we are rendering into
  22942. * @param scene Define the scene the texture belongs to
  22943. * @param options Define the options used to create the multi render target
  22944. */
  22945. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22946. private _initTypes;
  22947. /** @hidden */
  22948. _rebuild(forceFullRebuild?: boolean): void;
  22949. private _createInternalTextures;
  22950. private _createTextures;
  22951. /**
  22952. * Define the number of samples used if MSAA is enabled.
  22953. */
  22954. get samples(): number;
  22955. set samples(value: number);
  22956. /**
  22957. * Resize all the textures in the multi render target.
  22958. * Be careful as it will recreate all the data in the new texture.
  22959. * @param size Define the new size
  22960. */
  22961. resize(size: any): void;
  22962. /**
  22963. * Changes the number of render targets in this MRT
  22964. * Be careful as it will recreate all the data in the new texture.
  22965. * @param count new texture count
  22966. * @param options Specifies texture types and sampling modes for new textures
  22967. */
  22968. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  22969. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  22970. /**
  22971. * Dispose the render targets and their associated resources
  22972. */
  22973. dispose(): void;
  22974. /**
  22975. * Release all the underlying texture used as draw buffers.
  22976. */
  22977. releaseInternalTextures(): void;
  22978. }
  22979. }
  22980. declare module BABYLON {
  22981. /** @hidden */
  22982. export var imageProcessingPixelShader: {
  22983. name: string;
  22984. shader: string;
  22985. };
  22986. }
  22987. declare module BABYLON {
  22988. /**
  22989. * ImageProcessingPostProcess
  22990. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  22991. */
  22992. export class ImageProcessingPostProcess extends PostProcess {
  22993. /**
  22994. * Default configuration related to image processing available in the PBR Material.
  22995. */
  22996. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22997. /**
  22998. * Gets the image processing configuration used either in this material.
  22999. */
  23000. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23001. /**
  23002. * Sets the Default image processing configuration used either in the this material.
  23003. *
  23004. * If sets to null, the scene one is in use.
  23005. */
  23006. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23007. /**
  23008. * Keep track of the image processing observer to allow dispose and replace.
  23009. */
  23010. private _imageProcessingObserver;
  23011. /**
  23012. * Attaches a new image processing configuration to the PBR Material.
  23013. * @param configuration
  23014. */
  23015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23016. /**
  23017. * If the post process is supported.
  23018. */
  23019. get isSupported(): boolean;
  23020. /**
  23021. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23022. */
  23023. get colorCurves(): Nullable<ColorCurves>;
  23024. /**
  23025. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23026. */
  23027. set colorCurves(value: Nullable<ColorCurves>);
  23028. /**
  23029. * Gets wether the color curves effect is enabled.
  23030. */
  23031. get colorCurvesEnabled(): boolean;
  23032. /**
  23033. * Sets wether the color curves effect is enabled.
  23034. */
  23035. set colorCurvesEnabled(value: boolean);
  23036. /**
  23037. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23038. */
  23039. get colorGradingTexture(): Nullable<BaseTexture>;
  23040. /**
  23041. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23042. */
  23043. set colorGradingTexture(value: Nullable<BaseTexture>);
  23044. /**
  23045. * Gets wether the color grading effect is enabled.
  23046. */
  23047. get colorGradingEnabled(): boolean;
  23048. /**
  23049. * Gets wether the color grading effect is enabled.
  23050. */
  23051. set colorGradingEnabled(value: boolean);
  23052. /**
  23053. * Gets exposure used in the effect.
  23054. */
  23055. get exposure(): number;
  23056. /**
  23057. * Sets exposure used in the effect.
  23058. */
  23059. set exposure(value: number);
  23060. /**
  23061. * Gets wether tonemapping is enabled or not.
  23062. */
  23063. get toneMappingEnabled(): boolean;
  23064. /**
  23065. * Sets wether tonemapping is enabled or not
  23066. */
  23067. set toneMappingEnabled(value: boolean);
  23068. /**
  23069. * Gets the type of tone mapping effect.
  23070. */
  23071. get toneMappingType(): number;
  23072. /**
  23073. * Sets the type of tone mapping effect.
  23074. */
  23075. set toneMappingType(value: number);
  23076. /**
  23077. * Gets contrast used in the effect.
  23078. */
  23079. get contrast(): number;
  23080. /**
  23081. * Sets contrast used in the effect.
  23082. */
  23083. set contrast(value: number);
  23084. /**
  23085. * Gets Vignette stretch size.
  23086. */
  23087. get vignetteStretch(): number;
  23088. /**
  23089. * Sets Vignette stretch size.
  23090. */
  23091. set vignetteStretch(value: number);
  23092. /**
  23093. * Gets Vignette centre X Offset.
  23094. */
  23095. get vignetteCentreX(): number;
  23096. /**
  23097. * Sets Vignette centre X Offset.
  23098. */
  23099. set vignetteCentreX(value: number);
  23100. /**
  23101. * Gets Vignette centre Y Offset.
  23102. */
  23103. get vignetteCentreY(): number;
  23104. /**
  23105. * Sets Vignette centre Y Offset.
  23106. */
  23107. set vignetteCentreY(value: number);
  23108. /**
  23109. * Gets Vignette weight or intensity of the vignette effect.
  23110. */
  23111. get vignetteWeight(): number;
  23112. /**
  23113. * Sets Vignette weight or intensity of the vignette effect.
  23114. */
  23115. set vignetteWeight(value: number);
  23116. /**
  23117. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23118. * if vignetteEnabled is set to true.
  23119. */
  23120. get vignetteColor(): Color4;
  23121. /**
  23122. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23123. * if vignetteEnabled is set to true.
  23124. */
  23125. set vignetteColor(value: Color4);
  23126. /**
  23127. * Gets Camera field of view used by the Vignette effect.
  23128. */
  23129. get vignetteCameraFov(): number;
  23130. /**
  23131. * Sets Camera field of view used by the Vignette effect.
  23132. */
  23133. set vignetteCameraFov(value: number);
  23134. /**
  23135. * Gets the vignette blend mode allowing different kind of effect.
  23136. */
  23137. get vignetteBlendMode(): number;
  23138. /**
  23139. * Sets the vignette blend mode allowing different kind of effect.
  23140. */
  23141. set vignetteBlendMode(value: number);
  23142. /**
  23143. * Gets wether the vignette effect is enabled.
  23144. */
  23145. get vignetteEnabled(): boolean;
  23146. /**
  23147. * Sets wether the vignette effect is enabled.
  23148. */
  23149. set vignetteEnabled(value: boolean);
  23150. private _fromLinearSpace;
  23151. /**
  23152. * Gets wether the input of the processing is in Gamma or Linear Space.
  23153. */
  23154. get fromLinearSpace(): boolean;
  23155. /**
  23156. * Sets wether the input of the processing is in Gamma or Linear Space.
  23157. */
  23158. set fromLinearSpace(value: boolean);
  23159. /**
  23160. * Defines cache preventing GC.
  23161. */
  23162. private _defines;
  23163. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23164. /**
  23165. * "ImageProcessingPostProcess"
  23166. * @returns "ImageProcessingPostProcess"
  23167. */
  23168. getClassName(): string;
  23169. /**
  23170. * @hidden
  23171. */
  23172. _updateParameters(): void;
  23173. dispose(camera?: Camera): void;
  23174. }
  23175. }
  23176. declare module BABYLON {
  23177. /**
  23178. * Interface for defining prepass effects in the prepass post-process pipeline
  23179. */
  23180. export interface PrePassEffectConfiguration {
  23181. /**
  23182. * Name of the effect
  23183. */
  23184. name: string;
  23185. /**
  23186. * Post process to attach for this effect
  23187. */
  23188. postProcess?: PostProcess;
  23189. /**
  23190. * Textures required in the MRT
  23191. */
  23192. texturesRequired: number[];
  23193. /**
  23194. * Is the effect enabled
  23195. */
  23196. enabled: boolean;
  23197. /**
  23198. * Disposes the effect configuration
  23199. */
  23200. dispose?: () => void;
  23201. /**
  23202. * Creates the associated post process
  23203. */
  23204. createPostProcess?: () => PostProcess;
  23205. }
  23206. }
  23207. declare module BABYLON {
  23208. /**
  23209. * Renders a pre pass of the scene
  23210. * This means every mesh in the scene will be rendered to a render target texture
  23211. * And then this texture will be composited to the rendering canvas with post processes
  23212. * It is necessary for effects like subsurface scattering or deferred shading
  23213. */
  23214. export class PrePassRenderer {
  23215. /** @hidden */
  23216. static _SceneComponentInitialization: (scene: Scene) => void;
  23217. private _textureFormats;
  23218. /**
  23219. * To save performance, we can excluded skinned meshes from the prepass
  23220. */
  23221. excludedSkinnedMesh: AbstractMesh[];
  23222. private _textureIndices;
  23223. private _scene;
  23224. private _engine;
  23225. private _isDirty;
  23226. /**
  23227. * Number of textures in the multi render target texture where the scene is directly rendered
  23228. */
  23229. mrtCount: number;
  23230. /**
  23231. * The render target where the scene is directly rendered
  23232. */
  23233. prePassRT: MultiRenderTarget;
  23234. private _multiRenderAttachments;
  23235. private _defaultAttachments;
  23236. private _clearAttachments;
  23237. private _postProcesses;
  23238. private readonly _clearColor;
  23239. /**
  23240. * Image processing post process for composition
  23241. */
  23242. imageProcessingPostProcess: ImageProcessingPostProcess;
  23243. /**
  23244. * Configuration for prepass effects
  23245. */
  23246. private _effectConfigurations;
  23247. private _mrtFormats;
  23248. private _mrtLayout;
  23249. private _enabled;
  23250. /**
  23251. * Indicates if the prepass is enabled
  23252. */
  23253. get enabled(): boolean;
  23254. /**
  23255. * How many samples are used for MSAA of the scene render target
  23256. */
  23257. get samples(): number;
  23258. set samples(n: number);
  23259. /**
  23260. * Instanciates a prepass renderer
  23261. * @param scene The scene
  23262. */
  23263. constructor(scene: Scene);
  23264. private _initializeAttachments;
  23265. private _createCompositionEffect;
  23266. /**
  23267. * Indicates if rendering a prepass is supported
  23268. */
  23269. get isSupported(): boolean;
  23270. /**
  23271. * Sets the proper output textures to draw in the engine.
  23272. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  23273. */
  23274. bindAttachmentsForEffect(effect: Effect): void;
  23275. /**
  23276. * @hidden
  23277. */
  23278. _beforeCameraDraw(): void;
  23279. /**
  23280. * @hidden
  23281. */
  23282. _afterCameraDraw(): void;
  23283. private _checkRTSize;
  23284. private _bindFrameBuffer;
  23285. /**
  23286. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  23287. */
  23288. clear(): void;
  23289. private _setState;
  23290. /**
  23291. * Adds an effect configuration to the prepass.
  23292. * If an effect has already been added, it won't add it twice and will return the configuration
  23293. * already present.
  23294. * @param cfg the effect configuration
  23295. * @return the effect configuration now used by the prepass
  23296. */
  23297. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  23298. /**
  23299. * Returns the index of a texture in the multi render target texture array.
  23300. * @param type Texture type
  23301. * @return The index
  23302. */
  23303. getIndex(type: number): number;
  23304. private _enable;
  23305. private _disable;
  23306. private _resetLayout;
  23307. private _resetPostProcessChain;
  23308. private _bindPostProcessChain;
  23309. /**
  23310. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  23311. */
  23312. markAsDirty(): void;
  23313. /**
  23314. * Enables a texture on the MultiRenderTarget for prepass
  23315. */
  23316. private _enableTextures;
  23317. private _update;
  23318. private _markAllMaterialsAsPrePassDirty;
  23319. /**
  23320. * Disposes the prepass renderer.
  23321. */
  23322. dispose(): void;
  23323. }
  23324. }
  23325. declare module BABYLON {
  23326. /**
  23327. * Size options for a post process
  23328. */
  23329. export type PostProcessOptions = {
  23330. width: number;
  23331. height: number;
  23332. };
  23333. /**
  23334. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23335. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23336. */
  23337. export class PostProcess {
  23338. /**
  23339. * Gets or sets the unique id of the post process
  23340. */
  23341. uniqueId: number;
  23342. /** Name of the PostProcess. */
  23343. name: string;
  23344. /**
  23345. * Width of the texture to apply the post process on
  23346. */
  23347. width: number;
  23348. /**
  23349. * Height of the texture to apply the post process on
  23350. */
  23351. height: number;
  23352. /**
  23353. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23354. */
  23355. nodeMaterialSource: Nullable<NodeMaterial>;
  23356. /**
  23357. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23358. * @hidden
  23359. */
  23360. _outputTexture: Nullable<InternalTexture>;
  23361. /**
  23362. * Sampling mode used by the shader
  23363. * See https://doc.babylonjs.com/classes/3.1/texture
  23364. */
  23365. renderTargetSamplingMode: number;
  23366. /**
  23367. * Clear color to use when screen clearing
  23368. */
  23369. clearColor: Color4;
  23370. /**
  23371. * If the buffer needs to be cleared before applying the post process. (default: true)
  23372. * Should be set to false if shader will overwrite all previous pixels.
  23373. */
  23374. autoClear: boolean;
  23375. /**
  23376. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23377. */
  23378. alphaMode: number;
  23379. /**
  23380. * Sets the setAlphaBlendConstants of the babylon engine
  23381. */
  23382. alphaConstants: Color4;
  23383. /**
  23384. * Animations to be used for the post processing
  23385. */
  23386. animations: Animation[];
  23387. /**
  23388. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23389. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23390. */
  23391. enablePixelPerfectMode: boolean;
  23392. /**
  23393. * Force the postprocess to be applied without taking in account viewport
  23394. */
  23395. forceFullscreenViewport: boolean;
  23396. /**
  23397. * List of inspectable custom properties (used by the Inspector)
  23398. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23399. */
  23400. inspectableCustomProperties: IInspectable[];
  23401. /**
  23402. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23403. *
  23404. * | Value | Type | Description |
  23405. * | ----- | ----------------------------------- | ----------- |
  23406. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23407. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23408. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23409. *
  23410. */
  23411. scaleMode: number;
  23412. /**
  23413. * Force textures to be a power of two (default: false)
  23414. */
  23415. alwaysForcePOT: boolean;
  23416. private _samples;
  23417. /**
  23418. * Number of sample textures (default: 1)
  23419. */
  23420. get samples(): number;
  23421. set samples(n: number);
  23422. /**
  23423. * Modify the scale of the post process to be the same as the viewport (default: false)
  23424. */
  23425. adaptScaleToCurrentViewport: boolean;
  23426. private _camera;
  23427. protected _scene: Scene;
  23428. private _engine;
  23429. private _options;
  23430. private _reusable;
  23431. private _textureType;
  23432. private _textureFormat;
  23433. /**
  23434. * Smart array of input and output textures for the post process.
  23435. * @hidden
  23436. */
  23437. _textures: SmartArray<InternalTexture>;
  23438. /**
  23439. * The index in _textures that corresponds to the output texture.
  23440. * @hidden
  23441. */
  23442. _currentRenderTextureInd: number;
  23443. private _effect;
  23444. private _samplers;
  23445. private _fragmentUrl;
  23446. private _vertexUrl;
  23447. private _parameters;
  23448. private _scaleRatio;
  23449. protected _indexParameters: any;
  23450. private _shareOutputWithPostProcess;
  23451. private _texelSize;
  23452. private _forcedOutputTexture;
  23453. /**
  23454. * Prepass configuration in case this post process needs a texture from prepass
  23455. * @hidden
  23456. */
  23457. _prePassEffectConfiguration: PrePassEffectConfiguration;
  23458. /**
  23459. * Returns the fragment url or shader name used in the post process.
  23460. * @returns the fragment url or name in the shader store.
  23461. */
  23462. getEffectName(): string;
  23463. /**
  23464. * An event triggered when the postprocess is activated.
  23465. */
  23466. onActivateObservable: Observable<Camera>;
  23467. private _onActivateObserver;
  23468. /**
  23469. * A function that is added to the onActivateObservable
  23470. */
  23471. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23472. /**
  23473. * An event triggered when the postprocess changes its size.
  23474. */
  23475. onSizeChangedObservable: Observable<PostProcess>;
  23476. private _onSizeChangedObserver;
  23477. /**
  23478. * A function that is added to the onSizeChangedObservable
  23479. */
  23480. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23481. /**
  23482. * An event triggered when the postprocess applies its effect.
  23483. */
  23484. onApplyObservable: Observable<Effect>;
  23485. private _onApplyObserver;
  23486. /**
  23487. * A function that is added to the onApplyObservable
  23488. */
  23489. set onApply(callback: (effect: Effect) => void);
  23490. /**
  23491. * An event triggered before rendering the postprocess
  23492. */
  23493. onBeforeRenderObservable: Observable<Effect>;
  23494. private _onBeforeRenderObserver;
  23495. /**
  23496. * A function that is added to the onBeforeRenderObservable
  23497. */
  23498. set onBeforeRender(callback: (effect: Effect) => void);
  23499. /**
  23500. * An event triggered after rendering the postprocess
  23501. */
  23502. onAfterRenderObservable: Observable<Effect>;
  23503. private _onAfterRenderObserver;
  23504. /**
  23505. * A function that is added to the onAfterRenderObservable
  23506. */
  23507. set onAfterRender(callback: (efect: Effect) => void);
  23508. /**
  23509. * 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
  23510. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23511. */
  23512. get inputTexture(): InternalTexture;
  23513. set inputTexture(value: InternalTexture);
  23514. /**
  23515. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23516. * the only way to unset it is to use this function to restore its internal state
  23517. */
  23518. restoreDefaultInputTexture(): void;
  23519. /**
  23520. * Gets the camera which post process is applied to.
  23521. * @returns The camera the post process is applied to.
  23522. */
  23523. getCamera(): Camera;
  23524. /**
  23525. * Gets the texel size of the postprocess.
  23526. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23527. */
  23528. get texelSize(): Vector2;
  23529. /**
  23530. * Creates a new instance PostProcess
  23531. * @param name The name of the PostProcess.
  23532. * @param fragmentUrl The url of the fragment shader to be used.
  23533. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23534. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23535. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23536. * @param camera The camera to apply the render pass to.
  23537. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23538. * @param engine The engine which the post process will be applied. (default: current engine)
  23539. * @param reusable If the post process can be reused on the same frame. (default: false)
  23540. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23541. * @param textureType Type of textures used when performing the post process. (default: 0)
  23542. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23543. * @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
  23544. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23545. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23546. */
  23547. constructor(name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  23548. /**
  23549. * Gets a string identifying the name of the class
  23550. * @returns "PostProcess" string
  23551. */
  23552. getClassName(): string;
  23553. /**
  23554. * Gets the engine which this post process belongs to.
  23555. * @returns The engine the post process was enabled with.
  23556. */
  23557. getEngine(): Engine;
  23558. /**
  23559. * The effect that is created when initializing the post process.
  23560. * @returns The created effect corresponding the the postprocess.
  23561. */
  23562. getEffect(): Effect;
  23563. /**
  23564. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23565. * @param postProcess The post process to share the output with.
  23566. * @returns This post process.
  23567. */
  23568. shareOutputWith(postProcess: PostProcess): PostProcess;
  23569. /**
  23570. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23571. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23572. */
  23573. useOwnOutput(): void;
  23574. /**
  23575. * Updates the effect with the current post process compile time values and recompiles the shader.
  23576. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23577. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23578. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23579. * @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
  23580. * @param onCompiled Called when the shader has been compiled.
  23581. * @param onError Called if there is an error when compiling a shader.
  23582. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23583. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23584. */
  23585. 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;
  23586. /**
  23587. * The post process is reusable if it can be used multiple times within one frame.
  23588. * @returns If the post process is reusable
  23589. */
  23590. isReusable(): boolean;
  23591. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23592. markTextureDirty(): void;
  23593. /**
  23594. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23595. * 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.
  23596. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23597. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23598. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23599. * @returns The target texture that was bound to be written to.
  23600. */
  23601. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23602. /**
  23603. * If the post process is supported.
  23604. */
  23605. get isSupported(): boolean;
  23606. /**
  23607. * The aspect ratio of the output texture.
  23608. */
  23609. get aspectRatio(): number;
  23610. /**
  23611. * Get a value indicating if the post-process is ready to be used
  23612. * @returns true if the post-process is ready (shader is compiled)
  23613. */
  23614. isReady(): boolean;
  23615. /**
  23616. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23617. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23618. */
  23619. apply(): Nullable<Effect>;
  23620. private _disposeTextures;
  23621. /**
  23622. * Sets the required values to the prepass renderer.
  23623. * @param prePassRenderer defines the prepass renderer to setup.
  23624. * @returns true if the pre pass is needed.
  23625. */
  23626. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  23627. /**
  23628. * Disposes the post process.
  23629. * @param camera The camera to dispose the post process on.
  23630. */
  23631. dispose(camera?: Camera): void;
  23632. /**
  23633. * Serializes the particle system to a JSON object
  23634. * @returns the JSON object
  23635. */
  23636. serialize(): any;
  23637. /**
  23638. * Creates a material from parsed material data
  23639. * @param parsedPostProcess defines parsed post process data
  23640. * @param scene defines the hosting scene
  23641. * @param rootUrl defines the root URL to use to load textures
  23642. * @returns a new post process
  23643. */
  23644. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23645. }
  23646. }
  23647. declare module BABYLON {
  23648. /** @hidden */
  23649. export var kernelBlurVaryingDeclaration: {
  23650. name: string;
  23651. shader: string;
  23652. };
  23653. }
  23654. declare module BABYLON {
  23655. /** @hidden */
  23656. export var kernelBlurFragment: {
  23657. name: string;
  23658. shader: string;
  23659. };
  23660. }
  23661. declare module BABYLON {
  23662. /** @hidden */
  23663. export var kernelBlurFragment2: {
  23664. name: string;
  23665. shader: string;
  23666. };
  23667. }
  23668. declare module BABYLON {
  23669. /** @hidden */
  23670. export var kernelBlurPixelShader: {
  23671. name: string;
  23672. shader: string;
  23673. };
  23674. }
  23675. declare module BABYLON {
  23676. /** @hidden */
  23677. export var kernelBlurVertex: {
  23678. name: string;
  23679. shader: string;
  23680. };
  23681. }
  23682. declare module BABYLON {
  23683. /** @hidden */
  23684. export var kernelBlurVertexShader: {
  23685. name: string;
  23686. shader: string;
  23687. };
  23688. }
  23689. declare module BABYLON {
  23690. /**
  23691. * The Blur Post Process which blurs an image based on a kernel and direction.
  23692. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23693. */
  23694. export class BlurPostProcess extends PostProcess {
  23695. private blockCompilation;
  23696. protected _kernel: number;
  23697. protected _idealKernel: number;
  23698. protected _packedFloat: boolean;
  23699. private _staticDefines;
  23700. /** The direction in which to blur the image. */
  23701. direction: Vector2;
  23702. /**
  23703. * Sets the length in pixels of the blur sample region
  23704. */
  23705. set kernel(v: number);
  23706. /**
  23707. * Gets the length in pixels of the blur sample region
  23708. */
  23709. get kernel(): number;
  23710. /**
  23711. * Sets wether or not the blur needs to unpack/repack floats
  23712. */
  23713. set packedFloat(v: boolean);
  23714. /**
  23715. * Gets wether or not the blur is unpacking/repacking floats
  23716. */
  23717. get packedFloat(): boolean;
  23718. /**
  23719. * Gets a string identifying the name of the class
  23720. * @returns "BlurPostProcess" string
  23721. */
  23722. getClassName(): string;
  23723. /**
  23724. * Creates a new instance BlurPostProcess
  23725. * @param name The name of the effect.
  23726. * @param direction The direction in which to blur the image.
  23727. * @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.
  23728. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23729. * @param camera The camera to apply the render pass to.
  23730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23731. * @param engine The engine which the post process will be applied. (default: current engine)
  23732. * @param reusable If the post process can be reused on the same frame. (default: false)
  23733. * @param textureType Type of textures used when performing the post process. (default: 0)
  23734. * @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)
  23735. */
  23736. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23737. /**
  23738. * Updates the effect with the current post process compile time values and recompiles the shader.
  23739. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23740. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23741. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23742. * @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
  23743. * @param onCompiled Called when the shader has been compiled.
  23744. * @param onError Called if there is an error when compiling a shader.
  23745. */
  23746. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23747. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23748. /**
  23749. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23750. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23751. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23752. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23753. * The gaps between physical kernels are compensated for in the weighting of the samples
  23754. * @param idealKernel Ideal blur kernel.
  23755. * @return Nearest best kernel.
  23756. */
  23757. protected _nearestBestKernel(idealKernel: number): number;
  23758. /**
  23759. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23760. * @param x The point on the Gaussian distribution to sample.
  23761. * @return the value of the Gaussian function at x.
  23762. */
  23763. protected _gaussianWeight(x: number): number;
  23764. /**
  23765. * Generates a string that can be used as a floating point number in GLSL.
  23766. * @param x Value to print.
  23767. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23768. * @return GLSL float string.
  23769. */
  23770. protected _glslFloat(x: number, decimalFigures?: number): string;
  23771. /** @hidden */
  23772. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  23773. }
  23774. }
  23775. declare module BABYLON {
  23776. /**
  23777. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23778. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23779. * You can then easily use it as a reflectionTexture on a flat surface.
  23780. * In case the surface is not a plane, please consider relying on reflection probes.
  23781. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23782. */
  23783. export class MirrorTexture extends RenderTargetTexture {
  23784. private scene;
  23785. /**
  23786. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23787. * 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.
  23788. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23789. */
  23790. mirrorPlane: Plane;
  23791. /**
  23792. * Define the blur ratio used to blur the reflection if needed.
  23793. */
  23794. set blurRatio(value: number);
  23795. get blurRatio(): number;
  23796. /**
  23797. * Define the adaptive blur kernel used to blur the reflection if needed.
  23798. * This will autocompute the closest best match for the `blurKernel`
  23799. */
  23800. set adaptiveBlurKernel(value: number);
  23801. /**
  23802. * Define the blur kernel used to blur the reflection if needed.
  23803. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23804. */
  23805. set blurKernel(value: number);
  23806. /**
  23807. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23808. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23809. */
  23810. set blurKernelX(value: number);
  23811. get blurKernelX(): number;
  23812. /**
  23813. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23814. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23815. */
  23816. set blurKernelY(value: number);
  23817. get blurKernelY(): number;
  23818. private _autoComputeBlurKernel;
  23819. protected _onRatioRescale(): void;
  23820. private _updateGammaSpace;
  23821. private _imageProcessingConfigChangeObserver;
  23822. private _transformMatrix;
  23823. private _mirrorMatrix;
  23824. private _savedViewMatrix;
  23825. private _blurX;
  23826. private _blurY;
  23827. private _adaptiveBlurKernel;
  23828. private _blurKernelX;
  23829. private _blurKernelY;
  23830. private _blurRatio;
  23831. /**
  23832. * Instantiates a Mirror Texture.
  23833. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23834. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23835. * You can then easily use it as a reflectionTexture on a flat surface.
  23836. * In case the surface is not a plane, please consider relying on reflection probes.
  23837. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23838. * @param name
  23839. * @param size
  23840. * @param scene
  23841. * @param generateMipMaps
  23842. * @param type
  23843. * @param samplingMode
  23844. * @param generateDepthBuffer
  23845. */
  23846. constructor(name: string, size: number | {
  23847. width: number;
  23848. height: number;
  23849. } | {
  23850. ratio: number;
  23851. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23852. private _preparePostProcesses;
  23853. /**
  23854. * Clone the mirror texture.
  23855. * @returns the cloned texture
  23856. */
  23857. clone(): MirrorTexture;
  23858. /**
  23859. * Serialize the texture to a JSON representation you could use in Parse later on
  23860. * @returns the serialized JSON representation
  23861. */
  23862. serialize(): any;
  23863. /**
  23864. * Dispose the texture and release its associated resources.
  23865. */
  23866. dispose(): void;
  23867. }
  23868. }
  23869. declare module BABYLON {
  23870. /**
  23871. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23872. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23873. */
  23874. export class Texture extends BaseTexture {
  23875. /**
  23876. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23877. */
  23878. static SerializeBuffers: boolean;
  23879. /** @hidden */
  23880. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23881. /** @hidden */
  23882. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23883. /** @hidden */
  23884. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23885. /** nearest is mag = nearest and min = nearest and mip = linear */
  23886. static readonly NEAREST_SAMPLINGMODE: number;
  23887. /** nearest is mag = nearest and min = nearest and mip = linear */
  23888. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23889. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23890. static readonly BILINEAR_SAMPLINGMODE: number;
  23891. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23892. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23893. /** Trilinear is mag = linear and min = linear and mip = linear */
  23894. static readonly TRILINEAR_SAMPLINGMODE: number;
  23895. /** Trilinear is mag = linear and min = linear and mip = linear */
  23896. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23897. /** mag = nearest and min = nearest and mip = nearest */
  23898. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23899. /** mag = nearest and min = linear and mip = nearest */
  23900. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23901. /** mag = nearest and min = linear and mip = linear */
  23902. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23903. /** mag = nearest and min = linear and mip = none */
  23904. static readonly NEAREST_LINEAR: number;
  23905. /** mag = nearest and min = nearest and mip = none */
  23906. static readonly NEAREST_NEAREST: number;
  23907. /** mag = linear and min = nearest and mip = nearest */
  23908. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23909. /** mag = linear and min = nearest and mip = linear */
  23910. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23911. /** mag = linear and min = linear and mip = none */
  23912. static readonly LINEAR_LINEAR: number;
  23913. /** mag = linear and min = nearest and mip = none */
  23914. static readonly LINEAR_NEAREST: number;
  23915. /** Explicit coordinates mode */
  23916. static readonly EXPLICIT_MODE: number;
  23917. /** Spherical coordinates mode */
  23918. static readonly SPHERICAL_MODE: number;
  23919. /** Planar coordinates mode */
  23920. static readonly PLANAR_MODE: number;
  23921. /** Cubic coordinates mode */
  23922. static readonly CUBIC_MODE: number;
  23923. /** Projection coordinates mode */
  23924. static readonly PROJECTION_MODE: number;
  23925. /** Inverse Cubic coordinates mode */
  23926. static readonly SKYBOX_MODE: number;
  23927. /** Inverse Cubic coordinates mode */
  23928. static readonly INVCUBIC_MODE: number;
  23929. /** Equirectangular coordinates mode */
  23930. static readonly EQUIRECTANGULAR_MODE: number;
  23931. /** Equirectangular Fixed coordinates mode */
  23932. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23933. /** Equirectangular Fixed Mirrored coordinates mode */
  23934. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23935. /** Texture is not repeating outside of 0..1 UVs */
  23936. static readonly CLAMP_ADDRESSMODE: number;
  23937. /** Texture is repeating outside of 0..1 UVs */
  23938. static readonly WRAP_ADDRESSMODE: number;
  23939. /** Texture is repeating and mirrored */
  23940. static readonly MIRROR_ADDRESSMODE: number;
  23941. /**
  23942. * 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
  23943. */
  23944. static UseSerializedUrlIfAny: boolean;
  23945. /**
  23946. * Define the url of the texture.
  23947. */
  23948. url: Nullable<string>;
  23949. /**
  23950. * Define an offset on the texture to offset the u coordinates of the UVs
  23951. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23952. */
  23953. uOffset: number;
  23954. /**
  23955. * Define an offset on the texture to offset the v coordinates of the UVs
  23956. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23957. */
  23958. vOffset: number;
  23959. /**
  23960. * Define an offset on the texture to scale the u coordinates of the UVs
  23961. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23962. */
  23963. uScale: number;
  23964. /**
  23965. * Define an offset on the texture to scale the v coordinates of the UVs
  23966. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23967. */
  23968. vScale: number;
  23969. /**
  23970. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23971. * @see https://doc.babylonjs.com/how_to/more_materials
  23972. */
  23973. uAng: number;
  23974. /**
  23975. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23976. * @see https://doc.babylonjs.com/how_to/more_materials
  23977. */
  23978. vAng: number;
  23979. /**
  23980. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23981. * @see https://doc.babylonjs.com/how_to/more_materials
  23982. */
  23983. wAng: number;
  23984. /**
  23985. * Defines the center of rotation (U)
  23986. */
  23987. uRotationCenter: number;
  23988. /**
  23989. * Defines the center of rotation (V)
  23990. */
  23991. vRotationCenter: number;
  23992. /**
  23993. * Defines the center of rotation (W)
  23994. */
  23995. wRotationCenter: number;
  23996. /**
  23997. * Are mip maps generated for this texture or not.
  23998. */
  23999. get noMipmap(): boolean;
  24000. /**
  24001. * List of inspectable custom properties (used by the Inspector)
  24002. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24003. */
  24004. inspectableCustomProperties: Nullable<IInspectable[]>;
  24005. private _noMipmap;
  24006. /** @hidden */
  24007. _invertY: boolean;
  24008. private _rowGenerationMatrix;
  24009. private _cachedTextureMatrix;
  24010. private _projectionModeMatrix;
  24011. private _t0;
  24012. private _t1;
  24013. private _t2;
  24014. private _cachedUOffset;
  24015. private _cachedVOffset;
  24016. private _cachedUScale;
  24017. private _cachedVScale;
  24018. private _cachedUAng;
  24019. private _cachedVAng;
  24020. private _cachedWAng;
  24021. private _cachedProjectionMatrixId;
  24022. private _cachedCoordinatesMode;
  24023. /** @hidden */
  24024. protected _initialSamplingMode: number;
  24025. /** @hidden */
  24026. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24027. private _deleteBuffer;
  24028. protected _format: Nullable<number>;
  24029. private _delayedOnLoad;
  24030. private _delayedOnError;
  24031. private _mimeType?;
  24032. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24033. get mimeType(): string | undefined;
  24034. /**
  24035. * Observable triggered once the texture has been loaded.
  24036. */
  24037. onLoadObservable: Observable<Texture>;
  24038. protected _isBlocking: boolean;
  24039. /**
  24040. * Is the texture preventing material to render while loading.
  24041. * If false, a default texture will be used instead of the loading one during the preparation step.
  24042. */
  24043. set isBlocking(value: boolean);
  24044. get isBlocking(): boolean;
  24045. /**
  24046. * Get the current sampling mode associated with the texture.
  24047. */
  24048. get samplingMode(): number;
  24049. /**
  24050. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24051. */
  24052. get invertY(): boolean;
  24053. /**
  24054. * Instantiates a new texture.
  24055. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24056. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24057. * @param url defines the url of the picture to load as a texture
  24058. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24059. * @param noMipmap defines if the texture will require mip maps or not
  24060. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24061. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24062. * @param onLoad defines a callback triggered when the texture has been loaded
  24063. * @param onError defines a callback triggered when an error occurred during the loading session
  24064. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24065. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24066. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24067. * @param mimeType defines an optional mime type information
  24068. */
  24069. 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);
  24070. /**
  24071. * Update the url (and optional buffer) of this texture if url was null during construction.
  24072. * @param url the url of the texture
  24073. * @param buffer the buffer of the texture (defaults to null)
  24074. * @param onLoad callback called when the texture is loaded (defaults to null)
  24075. */
  24076. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24077. /**
  24078. * Finish the loading sequence of a texture flagged as delayed load.
  24079. * @hidden
  24080. */
  24081. delayLoad(): void;
  24082. private _prepareRowForTextureGeneration;
  24083. /**
  24084. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24085. * @returns the transform matrix of the texture.
  24086. */
  24087. getTextureMatrix(uBase?: number): Matrix;
  24088. /**
  24089. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24090. * @returns The reflection texture transform
  24091. */
  24092. getReflectionTextureMatrix(): Matrix;
  24093. /**
  24094. * Clones the texture.
  24095. * @returns the cloned texture
  24096. */
  24097. clone(): Texture;
  24098. /**
  24099. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24100. * @returns The JSON representation of the texture
  24101. */
  24102. serialize(): any;
  24103. /**
  24104. * Get the current class name of the texture useful for serialization or dynamic coding.
  24105. * @returns "Texture"
  24106. */
  24107. getClassName(): string;
  24108. /**
  24109. * Dispose the texture and release its associated resources.
  24110. */
  24111. dispose(): void;
  24112. /**
  24113. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24114. * @param parsedTexture Define the JSON representation of the texture
  24115. * @param scene Define the scene the parsed texture should be instantiated in
  24116. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24117. * @returns The parsed texture if successful
  24118. */
  24119. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24120. /**
  24121. * Creates a texture from its base 64 representation.
  24122. * @param data Define the base64 payload without the data: prefix
  24123. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24124. * @param scene Define the scene the texture should belong to
  24125. * @param noMipmap Forces the texture to not create mip map information if true
  24126. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24127. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24128. * @param onLoad define a callback triggered when the texture has been loaded
  24129. * @param onError define a callback triggered when an error occurred during the loading session
  24130. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24131. * @returns the created texture
  24132. */
  24133. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24134. /**
  24135. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24136. * @param data Define the base64 payload without the data: prefix
  24137. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24138. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24139. * @param scene Define the scene the texture should belong to
  24140. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24141. * @param noMipmap Forces the texture to not create mip map information if true
  24142. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24143. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24144. * @param onLoad define a callback triggered when the texture has been loaded
  24145. * @param onError define a callback triggered when an error occurred during the loading session
  24146. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24147. * @returns the created texture
  24148. */
  24149. 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;
  24150. }
  24151. }
  24152. declare module BABYLON {
  24153. /**
  24154. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24155. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24156. */
  24157. export class PostProcessManager {
  24158. private _scene;
  24159. private _indexBuffer;
  24160. private _vertexBuffers;
  24161. /**
  24162. * Creates a new instance PostProcess
  24163. * @param scene The scene that the post process is associated with.
  24164. */
  24165. constructor(scene: Scene);
  24166. private _prepareBuffers;
  24167. private _buildIndexBuffer;
  24168. /**
  24169. * Rebuilds the vertex buffers of the manager.
  24170. * @hidden
  24171. */
  24172. _rebuild(): void;
  24173. /**
  24174. * Prepares a frame to be run through a post process.
  24175. * @param sourceTexture The input texture to the post procesess. (default: null)
  24176. * @param postProcesses An array of post processes to be run. (default: null)
  24177. * @returns True if the post processes were able to be run.
  24178. * @hidden
  24179. */
  24180. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24181. /**
  24182. * Manually render a set of post processes to a texture.
  24183. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24184. * @param postProcesses An array of post processes to be run.
  24185. * @param targetTexture The target texture to render to.
  24186. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24187. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24188. * @param lodLevel defines which lod of the texture to render to
  24189. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24190. */
  24191. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24192. /**
  24193. * Finalize the result of the output of the postprocesses.
  24194. * @param doNotPresent If true the result will not be displayed to the screen.
  24195. * @param targetTexture The target texture to render to.
  24196. * @param faceIndex The index of the face to bind the target texture to.
  24197. * @param postProcesses The array of post processes to render.
  24198. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24199. * @hidden
  24200. */
  24201. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24202. /**
  24203. * Disposes of the post process manager.
  24204. */
  24205. dispose(): void;
  24206. }
  24207. }
  24208. declare module BABYLON {
  24209. /**
  24210. * This Helps creating a texture that will be created from a camera in your scene.
  24211. * It is basically a dynamic texture that could be used to create special effects for instance.
  24212. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24213. */
  24214. export class RenderTargetTexture extends Texture {
  24215. /**
  24216. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24217. */
  24218. static readonly REFRESHRATE_RENDER_ONCE: number;
  24219. /**
  24220. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24221. */
  24222. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24223. /**
  24224. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24225. * the central point of your effect and can save a lot of performances.
  24226. */
  24227. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24228. /**
  24229. * Use this predicate to dynamically define the list of mesh you want to render.
  24230. * If set, the renderList property will be overwritten.
  24231. */
  24232. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24233. private _renderList;
  24234. /**
  24235. * Use this list to define the list of mesh you want to render.
  24236. */
  24237. get renderList(): Nullable<Array<AbstractMesh>>;
  24238. set renderList(value: Nullable<Array<AbstractMesh>>);
  24239. /**
  24240. * Use this function to overload the renderList array at rendering time.
  24241. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24242. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24243. * the cube (if the RTT is a cube, else layerOrFace=0).
  24244. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24245. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24246. * hold dummy elements!
  24247. */
  24248. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24249. private _hookArray;
  24250. /**
  24251. * Define if particles should be rendered in your texture.
  24252. */
  24253. renderParticles: boolean;
  24254. /**
  24255. * Define if sprites should be rendered in your texture.
  24256. */
  24257. renderSprites: boolean;
  24258. /**
  24259. * Define the camera used to render the texture.
  24260. */
  24261. activeCamera: Nullable<Camera>;
  24262. /**
  24263. * Override the mesh isReady function with your own one.
  24264. */
  24265. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24266. /**
  24267. * Override the render function of the texture with your own one.
  24268. */
  24269. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24270. /**
  24271. * Define if camera post processes should be use while rendering the texture.
  24272. */
  24273. useCameraPostProcesses: boolean;
  24274. /**
  24275. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24276. */
  24277. ignoreCameraViewport: boolean;
  24278. private _postProcessManager;
  24279. private _postProcesses;
  24280. private _resizeObserver;
  24281. /**
  24282. * An event triggered when the texture is unbind.
  24283. */
  24284. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24285. /**
  24286. * An event triggered when the texture is unbind.
  24287. */
  24288. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24289. private _onAfterUnbindObserver;
  24290. /**
  24291. * Set a after unbind callback in the texture.
  24292. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24293. */
  24294. set onAfterUnbind(callback: () => void);
  24295. /**
  24296. * An event triggered before rendering the texture
  24297. */
  24298. onBeforeRenderObservable: Observable<number>;
  24299. private _onBeforeRenderObserver;
  24300. /**
  24301. * Set a before render callback in the texture.
  24302. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24303. */
  24304. set onBeforeRender(callback: (faceIndex: number) => void);
  24305. /**
  24306. * An event triggered after rendering the texture
  24307. */
  24308. onAfterRenderObservable: Observable<number>;
  24309. private _onAfterRenderObserver;
  24310. /**
  24311. * Set a after render callback in the texture.
  24312. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24313. */
  24314. set onAfterRender(callback: (faceIndex: number) => void);
  24315. /**
  24316. * An event triggered after the texture clear
  24317. */
  24318. onClearObservable: Observable<Engine>;
  24319. private _onClearObserver;
  24320. /**
  24321. * Set a clear callback in the texture.
  24322. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24323. */
  24324. set onClear(callback: (Engine: Engine) => void);
  24325. /**
  24326. * An event triggered when the texture is resized.
  24327. */
  24328. onResizeObservable: Observable<RenderTargetTexture>;
  24329. /**
  24330. * Define the clear color of the Render Target if it should be different from the scene.
  24331. */
  24332. clearColor: Color4;
  24333. protected _size: number | {
  24334. width: number;
  24335. height: number;
  24336. layers?: number;
  24337. };
  24338. protected _initialSizeParameter: number | {
  24339. width: number;
  24340. height: number;
  24341. } | {
  24342. ratio: number;
  24343. };
  24344. protected _sizeRatio: Nullable<number>;
  24345. /** @hidden */
  24346. _generateMipMaps: boolean;
  24347. protected _renderingManager: RenderingManager;
  24348. /** @hidden */
  24349. _waitingRenderList?: string[];
  24350. protected _doNotChangeAspectRatio: boolean;
  24351. protected _currentRefreshId: number;
  24352. protected _refreshRate: number;
  24353. protected _textureMatrix: Matrix;
  24354. protected _samples: number;
  24355. protected _renderTargetOptions: RenderTargetCreationOptions;
  24356. /**
  24357. * Gets render target creation options that were used.
  24358. */
  24359. get renderTargetOptions(): RenderTargetCreationOptions;
  24360. protected _onRatioRescale(): void;
  24361. /**
  24362. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24363. * It must define where the camera used to render the texture is set
  24364. */
  24365. boundingBoxPosition: Vector3;
  24366. private _boundingBoxSize;
  24367. /**
  24368. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24369. * When defined, the cubemap will switch to local mode
  24370. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24371. * @example https://www.babylonjs-playground.com/#RNASML
  24372. */
  24373. set boundingBoxSize(value: Vector3);
  24374. get boundingBoxSize(): Vector3;
  24375. /**
  24376. * In case the RTT has been created with a depth texture, get the associated
  24377. * depth texture.
  24378. * Otherwise, return null.
  24379. */
  24380. get depthStencilTexture(): Nullable<InternalTexture>;
  24381. /**
  24382. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24383. * or used a shadow, depth texture...
  24384. * @param name The friendly name of the texture
  24385. * @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)
  24386. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24387. * @param generateMipMaps True if mip maps need to be generated after render.
  24388. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24389. * @param type The type of the buffer in the RTT (int, half float, float...)
  24390. * @param isCube True if a cube texture needs to be created
  24391. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24392. * @param generateDepthBuffer True to generate a depth buffer
  24393. * @param generateStencilBuffer True to generate a stencil buffer
  24394. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24395. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24396. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24397. */
  24398. constructor(name: string, size: number | {
  24399. width: number;
  24400. height: number;
  24401. layers?: number;
  24402. } | {
  24403. ratio: number;
  24404. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24405. /**
  24406. * Creates a depth stencil texture.
  24407. * This is only available in WebGL 2 or with the depth texture extension available.
  24408. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24409. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24410. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24411. */
  24412. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24413. private _processSizeParameter;
  24414. /**
  24415. * Define the number of samples to use in case of MSAA.
  24416. * It defaults to one meaning no MSAA has been enabled.
  24417. */
  24418. get samples(): number;
  24419. set samples(value: number);
  24420. /**
  24421. * Resets the refresh counter of the texture and start bak from scratch.
  24422. * Could be useful to regenerate the texture if it is setup to render only once.
  24423. */
  24424. resetRefreshCounter(): void;
  24425. /**
  24426. * Define the refresh rate of the texture or the rendering frequency.
  24427. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24428. */
  24429. get refreshRate(): number;
  24430. set refreshRate(value: number);
  24431. /**
  24432. * Adds a post process to the render target rendering passes.
  24433. * @param postProcess define the post process to add
  24434. */
  24435. addPostProcess(postProcess: PostProcess): void;
  24436. /**
  24437. * Clear all the post processes attached to the render target
  24438. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24439. */
  24440. clearPostProcesses(dispose?: boolean): void;
  24441. /**
  24442. * Remove one of the post process from the list of attached post processes to the texture
  24443. * @param postProcess define the post process to remove from the list
  24444. */
  24445. removePostProcess(postProcess: PostProcess): void;
  24446. /** @hidden */
  24447. _shouldRender(): boolean;
  24448. /**
  24449. * Gets the actual render size of the texture.
  24450. * @returns the width of the render size
  24451. */
  24452. getRenderSize(): number;
  24453. /**
  24454. * Gets the actual render width of the texture.
  24455. * @returns the width of the render size
  24456. */
  24457. getRenderWidth(): number;
  24458. /**
  24459. * Gets the actual render height of the texture.
  24460. * @returns the height of the render size
  24461. */
  24462. getRenderHeight(): number;
  24463. /**
  24464. * Gets the actual number of layers of the texture.
  24465. * @returns the number of layers
  24466. */
  24467. getRenderLayers(): number;
  24468. /**
  24469. * Get if the texture can be rescaled or not.
  24470. */
  24471. get canRescale(): boolean;
  24472. /**
  24473. * Resize the texture using a ratio.
  24474. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24475. */
  24476. scale(ratio: number): void;
  24477. /**
  24478. * Get the texture reflection matrix used to rotate/transform the reflection.
  24479. * @returns the reflection matrix
  24480. */
  24481. getReflectionTextureMatrix(): Matrix;
  24482. /**
  24483. * Resize the texture to a new desired size.
  24484. * Be carrefull as it will recreate all the data in the new texture.
  24485. * @param size Define the new size. It can be:
  24486. * - a number for squared texture,
  24487. * - an object containing { width: number, height: number }
  24488. * - or an object containing a ratio { ratio: number }
  24489. */
  24490. resize(size: number | {
  24491. width: number;
  24492. height: number;
  24493. } | {
  24494. ratio: number;
  24495. }): void;
  24496. private _defaultRenderListPrepared;
  24497. /**
  24498. * Renders all the objects from the render list into the texture.
  24499. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24500. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24501. */
  24502. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24503. private _bestReflectionRenderTargetDimension;
  24504. private _prepareRenderingManager;
  24505. /**
  24506. * @hidden
  24507. * @param faceIndex face index to bind to if this is a cubetexture
  24508. * @param layer defines the index of the texture to bind in the array
  24509. */
  24510. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24511. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24512. private renderToTarget;
  24513. /**
  24514. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24515. * This allowed control for front to back rendering or reversly depending of the special needs.
  24516. *
  24517. * @param renderingGroupId The rendering group id corresponding to its index
  24518. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24519. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24520. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24521. */
  24522. 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;
  24523. /**
  24524. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24525. *
  24526. * @param renderingGroupId The rendering group id corresponding to its index
  24527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24528. */
  24529. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24530. /**
  24531. * Clones the texture.
  24532. * @returns the cloned texture
  24533. */
  24534. clone(): RenderTargetTexture;
  24535. /**
  24536. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24537. * @returns The JSON representation of the texture
  24538. */
  24539. serialize(): any;
  24540. /**
  24541. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24542. */
  24543. disposeFramebufferObjects(): void;
  24544. /**
  24545. * Dispose the texture and release its associated resources.
  24546. */
  24547. dispose(): void;
  24548. /** @hidden */
  24549. _rebuild(): void;
  24550. /**
  24551. * Clear the info related to rendering groups preventing retention point in material dispose.
  24552. */
  24553. freeRenderingGroups(): void;
  24554. /**
  24555. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24556. * @returns the view count
  24557. */
  24558. getViewCount(): number;
  24559. }
  24560. }
  24561. declare module BABYLON {
  24562. /**
  24563. * Class used to manipulate GUIDs
  24564. */
  24565. export class GUID {
  24566. /**
  24567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24568. * Be aware Math.random() could cause collisions, but:
  24569. * "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"
  24570. * @returns a pseudo random id
  24571. */
  24572. static RandomId(): string;
  24573. }
  24574. }
  24575. declare module BABYLON {
  24576. /**
  24577. * Options to be used when creating a shadow depth material
  24578. */
  24579. export interface IIOptionShadowDepthMaterial {
  24580. /** Variables in the vertex shader code that need to have their names remapped.
  24581. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24582. * "var_name" should be either: worldPos or vNormalW
  24583. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24584. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24585. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24586. */
  24587. remappedVariables?: string[];
  24588. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24589. standalone?: boolean;
  24590. }
  24591. /**
  24592. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24593. */
  24594. export class ShadowDepthWrapper {
  24595. private _scene;
  24596. private _options?;
  24597. private _baseMaterial;
  24598. private _onEffectCreatedObserver;
  24599. private _subMeshToEffect;
  24600. private _subMeshToDepthEffect;
  24601. private _meshes;
  24602. /** @hidden */
  24603. _matriceNames: any;
  24604. /** Gets the standalone status of the wrapper */
  24605. get standalone(): boolean;
  24606. /** Gets the base material the wrapper is built upon */
  24607. get baseMaterial(): Material;
  24608. /**
  24609. * Instantiate a new shadow depth wrapper.
  24610. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24611. * generate the shadow depth map. For more information, please refer to the documentation:
  24612. * https://doc.babylonjs.com/babylon101/shadows
  24613. * @param baseMaterial Material to wrap
  24614. * @param scene Define the scene the material belongs to
  24615. * @param options Options used to create the wrapper
  24616. */
  24617. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24618. /**
  24619. * Gets the effect to use to generate the depth map
  24620. * @param subMesh subMesh to get the effect for
  24621. * @param shadowGenerator shadow generator to get the effect for
  24622. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24623. */
  24624. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24625. /**
  24626. * Specifies that the submesh is ready to be used for depth rendering
  24627. * @param subMesh submesh to check
  24628. * @param defines the list of defines to take into account when checking the effect
  24629. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24630. * @param useInstances specifies that instances should be used
  24631. * @returns a boolean indicating that the submesh is ready or not
  24632. */
  24633. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24634. /**
  24635. * Disposes the resources
  24636. */
  24637. dispose(): void;
  24638. private _makeEffect;
  24639. }
  24640. }
  24641. declare module BABYLON {
  24642. /**
  24643. * Options for compiling materials.
  24644. */
  24645. export interface IMaterialCompilationOptions {
  24646. /**
  24647. * Defines whether clip planes are enabled.
  24648. */
  24649. clipPlane: boolean;
  24650. /**
  24651. * Defines whether instances are enabled.
  24652. */
  24653. useInstances: boolean;
  24654. }
  24655. /**
  24656. * Options passed when calling customShaderNameResolve
  24657. */
  24658. export interface ICustomShaderNameResolveOptions {
  24659. /**
  24660. * 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
  24661. */
  24662. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24663. }
  24664. /**
  24665. * Base class for the main features of a material in Babylon.js
  24666. */
  24667. export class Material implements IAnimatable {
  24668. /**
  24669. * Returns the triangle fill mode
  24670. */
  24671. static readonly TriangleFillMode: number;
  24672. /**
  24673. * Returns the wireframe mode
  24674. */
  24675. static readonly WireFrameFillMode: number;
  24676. /**
  24677. * Returns the point fill mode
  24678. */
  24679. static readonly PointFillMode: number;
  24680. /**
  24681. * Returns the point list draw mode
  24682. */
  24683. static readonly PointListDrawMode: number;
  24684. /**
  24685. * Returns the line list draw mode
  24686. */
  24687. static readonly LineListDrawMode: number;
  24688. /**
  24689. * Returns the line loop draw mode
  24690. */
  24691. static readonly LineLoopDrawMode: number;
  24692. /**
  24693. * Returns the line strip draw mode
  24694. */
  24695. static readonly LineStripDrawMode: number;
  24696. /**
  24697. * Returns the triangle strip draw mode
  24698. */
  24699. static readonly TriangleStripDrawMode: number;
  24700. /**
  24701. * Returns the triangle fan draw mode
  24702. */
  24703. static readonly TriangleFanDrawMode: number;
  24704. /**
  24705. * Stores the clock-wise side orientation
  24706. */
  24707. static readonly ClockWiseSideOrientation: number;
  24708. /**
  24709. * Stores the counter clock-wise side orientation
  24710. */
  24711. static readonly CounterClockWiseSideOrientation: number;
  24712. /**
  24713. * The dirty texture flag value
  24714. */
  24715. static readonly TextureDirtyFlag: number;
  24716. /**
  24717. * The dirty light flag value
  24718. */
  24719. static readonly LightDirtyFlag: number;
  24720. /**
  24721. * The dirty fresnel flag value
  24722. */
  24723. static readonly FresnelDirtyFlag: number;
  24724. /**
  24725. * The dirty attribute flag value
  24726. */
  24727. static readonly AttributesDirtyFlag: number;
  24728. /**
  24729. * The dirty misc flag value
  24730. */
  24731. static readonly MiscDirtyFlag: number;
  24732. /**
  24733. * The dirty prepass flag value
  24734. */
  24735. static readonly PrePassDirtyFlag: number;
  24736. /**
  24737. * The all dirty flag value
  24738. */
  24739. static readonly AllDirtyFlag: number;
  24740. /**
  24741. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24742. */
  24743. static readonly MATERIAL_OPAQUE: number;
  24744. /**
  24745. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24746. */
  24747. static readonly MATERIAL_ALPHATEST: number;
  24748. /**
  24749. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24750. */
  24751. static readonly MATERIAL_ALPHABLEND: number;
  24752. /**
  24753. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24754. * They are also discarded below the alpha cutoff threshold to improve performances.
  24755. */
  24756. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24757. /**
  24758. * The Whiteout method is used to blend normals.
  24759. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24760. */
  24761. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24762. /**
  24763. * The Reoriented Normal Mapping method is used to blend normals.
  24764. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24765. */
  24766. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24767. /**
  24768. * Custom callback helping to override the default shader used in the material.
  24769. */
  24770. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24771. /**
  24772. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24773. */
  24774. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24775. /**
  24776. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24777. * This means that the material can keep using a previous shader while a new one is being compiled.
  24778. * This is mostly used when shader parallel compilation is supported (true by default)
  24779. */
  24780. allowShaderHotSwapping: boolean;
  24781. /**
  24782. * The ID of the material
  24783. */
  24784. id: string;
  24785. /**
  24786. * Gets or sets the unique id of the material
  24787. */
  24788. uniqueId: number;
  24789. /**
  24790. * The name of the material
  24791. */
  24792. name: string;
  24793. /**
  24794. * Gets or sets user defined metadata
  24795. */
  24796. metadata: any;
  24797. /**
  24798. * For internal use only. Please do not use.
  24799. */
  24800. reservedDataStore: any;
  24801. /**
  24802. * Specifies if the ready state should be checked on each call
  24803. */
  24804. checkReadyOnEveryCall: boolean;
  24805. /**
  24806. * Specifies if the ready state should be checked once
  24807. */
  24808. checkReadyOnlyOnce: boolean;
  24809. /**
  24810. * The state of the material
  24811. */
  24812. state: string;
  24813. /**
  24814. * If the material can be rendered to several textures with MRT extension
  24815. */
  24816. get canRenderToMRT(): boolean;
  24817. /**
  24818. * The alpha value of the material
  24819. */
  24820. protected _alpha: number;
  24821. /**
  24822. * List of inspectable custom properties (used by the Inspector)
  24823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24824. */
  24825. inspectableCustomProperties: IInspectable[];
  24826. /**
  24827. * Sets the alpha value of the material
  24828. */
  24829. set alpha(value: number);
  24830. /**
  24831. * Gets the alpha value of the material
  24832. */
  24833. get alpha(): number;
  24834. /**
  24835. * Specifies if back face culling is enabled
  24836. */
  24837. protected _backFaceCulling: boolean;
  24838. /**
  24839. * Sets the back-face culling state
  24840. */
  24841. set backFaceCulling(value: boolean);
  24842. /**
  24843. * Gets the back-face culling state
  24844. */
  24845. get backFaceCulling(): boolean;
  24846. /**
  24847. * Stores the value for side orientation
  24848. */
  24849. sideOrientation: number;
  24850. /**
  24851. * Callback triggered when the material is compiled
  24852. */
  24853. onCompiled: Nullable<(effect: Effect) => void>;
  24854. /**
  24855. * Callback triggered when an error occurs
  24856. */
  24857. onError: Nullable<(effect: Effect, errors: string) => void>;
  24858. /**
  24859. * Callback triggered to get the render target textures
  24860. */
  24861. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24862. /**
  24863. * Gets a boolean indicating that current material needs to register RTT
  24864. */
  24865. get hasRenderTargetTextures(): boolean;
  24866. /**
  24867. * Specifies if the material should be serialized
  24868. */
  24869. doNotSerialize: boolean;
  24870. /**
  24871. * @hidden
  24872. */
  24873. _storeEffectOnSubMeshes: boolean;
  24874. /**
  24875. * Stores the animations for the material
  24876. */
  24877. animations: Nullable<Array<Animation>>;
  24878. /**
  24879. * An event triggered when the material is disposed
  24880. */
  24881. onDisposeObservable: Observable<Material>;
  24882. /**
  24883. * An observer which watches for dispose events
  24884. */
  24885. private _onDisposeObserver;
  24886. private _onUnBindObservable;
  24887. /**
  24888. * Called during a dispose event
  24889. */
  24890. set onDispose(callback: () => void);
  24891. private _onBindObservable;
  24892. /**
  24893. * An event triggered when the material is bound
  24894. */
  24895. get onBindObservable(): Observable<AbstractMesh>;
  24896. /**
  24897. * An observer which watches for bind events
  24898. */
  24899. private _onBindObserver;
  24900. /**
  24901. * Called during a bind event
  24902. */
  24903. set onBind(callback: (Mesh: AbstractMesh) => void);
  24904. /**
  24905. * An event triggered when the material is unbound
  24906. */
  24907. get onUnBindObservable(): Observable<Material>;
  24908. protected _onEffectCreatedObservable: Nullable<Observable<{
  24909. effect: Effect;
  24910. subMesh: Nullable<SubMesh>;
  24911. }>>;
  24912. /**
  24913. * An event triggered when the effect is (re)created
  24914. */
  24915. get onEffectCreatedObservable(): Observable<{
  24916. effect: Effect;
  24917. subMesh: Nullable<SubMesh>;
  24918. }>;
  24919. /**
  24920. * Stores the value of the alpha mode
  24921. */
  24922. private _alphaMode;
  24923. /**
  24924. * Sets the value of the alpha mode.
  24925. *
  24926. * | Value | Type | Description |
  24927. * | --- | --- | --- |
  24928. * | 0 | ALPHA_DISABLE | |
  24929. * | 1 | ALPHA_ADD | |
  24930. * | 2 | ALPHA_COMBINE | |
  24931. * | 3 | ALPHA_SUBTRACT | |
  24932. * | 4 | ALPHA_MULTIPLY | |
  24933. * | 5 | ALPHA_MAXIMIZED | |
  24934. * | 6 | ALPHA_ONEONE | |
  24935. * | 7 | ALPHA_PREMULTIPLIED | |
  24936. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24937. * | 9 | ALPHA_INTERPOLATE | |
  24938. * | 10 | ALPHA_SCREENMODE | |
  24939. *
  24940. */
  24941. set alphaMode(value: number);
  24942. /**
  24943. * Gets the value of the alpha mode
  24944. */
  24945. get alphaMode(): number;
  24946. /**
  24947. * Stores the state of the need depth pre-pass value
  24948. */
  24949. private _needDepthPrePass;
  24950. /**
  24951. * Sets the need depth pre-pass value
  24952. */
  24953. set needDepthPrePass(value: boolean);
  24954. /**
  24955. * Gets the depth pre-pass value
  24956. */
  24957. get needDepthPrePass(): boolean;
  24958. /**
  24959. * Specifies if depth writing should be disabled
  24960. */
  24961. disableDepthWrite: boolean;
  24962. /**
  24963. * Specifies if color writing should be disabled
  24964. */
  24965. disableColorWrite: boolean;
  24966. /**
  24967. * Specifies if depth writing should be forced
  24968. */
  24969. forceDepthWrite: boolean;
  24970. /**
  24971. * Specifies the depth function that should be used. 0 means the default engine function
  24972. */
  24973. depthFunction: number;
  24974. /**
  24975. * Specifies if there should be a separate pass for culling
  24976. */
  24977. separateCullingPass: boolean;
  24978. /**
  24979. * Stores the state specifing if fog should be enabled
  24980. */
  24981. private _fogEnabled;
  24982. /**
  24983. * Sets the state for enabling fog
  24984. */
  24985. set fogEnabled(value: boolean);
  24986. /**
  24987. * Gets the value of the fog enabled state
  24988. */
  24989. get fogEnabled(): boolean;
  24990. /**
  24991. * Stores the size of points
  24992. */
  24993. pointSize: number;
  24994. /**
  24995. * Stores the z offset value
  24996. */
  24997. zOffset: number;
  24998. get wireframe(): boolean;
  24999. /**
  25000. * Sets the state of wireframe mode
  25001. */
  25002. set wireframe(value: boolean);
  25003. /**
  25004. * Gets the value specifying if point clouds are enabled
  25005. */
  25006. get pointsCloud(): boolean;
  25007. /**
  25008. * Sets the state of point cloud mode
  25009. */
  25010. set pointsCloud(value: boolean);
  25011. /**
  25012. * Gets the material fill mode
  25013. */
  25014. get fillMode(): number;
  25015. /**
  25016. * Sets the material fill mode
  25017. */
  25018. set fillMode(value: number);
  25019. /**
  25020. * @hidden
  25021. * Stores the effects for the material
  25022. */
  25023. _effect: Nullable<Effect>;
  25024. /**
  25025. * Specifies if uniform buffers should be used
  25026. */
  25027. private _useUBO;
  25028. /**
  25029. * Stores a reference to the scene
  25030. */
  25031. private _scene;
  25032. /**
  25033. * Stores the fill mode state
  25034. */
  25035. private _fillMode;
  25036. /**
  25037. * Specifies if the depth write state should be cached
  25038. */
  25039. private _cachedDepthWriteState;
  25040. /**
  25041. * Specifies if the color write state should be cached
  25042. */
  25043. private _cachedColorWriteState;
  25044. /**
  25045. * Specifies if the depth function state should be cached
  25046. */
  25047. private _cachedDepthFunctionState;
  25048. /**
  25049. * Stores the uniform buffer
  25050. */
  25051. protected _uniformBuffer: UniformBuffer;
  25052. /** @hidden */
  25053. _indexInSceneMaterialArray: number;
  25054. /** @hidden */
  25055. meshMap: Nullable<{
  25056. [id: string]: AbstractMesh | undefined;
  25057. }>;
  25058. /**
  25059. * Creates a material instance
  25060. * @param name defines the name of the material
  25061. * @param scene defines the scene to reference
  25062. * @param doNotAdd specifies if the material should be added to the scene
  25063. */
  25064. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25065. /**
  25066. * Returns a string representation of the current material
  25067. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25068. * @returns a string with material information
  25069. */
  25070. toString(fullDetails?: boolean): string;
  25071. /**
  25072. * Gets the class name of the material
  25073. * @returns a string with the class name of the material
  25074. */
  25075. getClassName(): string;
  25076. /**
  25077. * Specifies if updates for the material been locked
  25078. */
  25079. get isFrozen(): boolean;
  25080. /**
  25081. * Locks updates for the material
  25082. */
  25083. freeze(): void;
  25084. /**
  25085. * Unlocks updates for the material
  25086. */
  25087. unfreeze(): void;
  25088. /**
  25089. * Specifies if the material is ready to be used
  25090. * @param mesh defines the mesh to check
  25091. * @param useInstances specifies if instances should be used
  25092. * @returns a boolean indicating if the material is ready to be used
  25093. */
  25094. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25095. /**
  25096. * Specifies that the submesh is ready to be used
  25097. * @param mesh defines the mesh to check
  25098. * @param subMesh defines which submesh to check
  25099. * @param useInstances specifies that instances should be used
  25100. * @returns a boolean indicating that the submesh is ready or not
  25101. */
  25102. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25103. /**
  25104. * Returns the material effect
  25105. * @returns the effect associated with the material
  25106. */
  25107. getEffect(): Nullable<Effect>;
  25108. /**
  25109. * Returns the current scene
  25110. * @returns a Scene
  25111. */
  25112. getScene(): Scene;
  25113. /**
  25114. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25115. */
  25116. protected _forceAlphaTest: boolean;
  25117. /**
  25118. * The transparency mode of the material.
  25119. */
  25120. protected _transparencyMode: Nullable<number>;
  25121. /**
  25122. * Gets the current transparency mode.
  25123. */
  25124. get transparencyMode(): Nullable<number>;
  25125. /**
  25126. * Sets the transparency mode of the material.
  25127. *
  25128. * | Value | Type | Description |
  25129. * | ----- | ----------------------------------- | ----------- |
  25130. * | 0 | OPAQUE | |
  25131. * | 1 | ALPHATEST | |
  25132. * | 2 | ALPHABLEND | |
  25133. * | 3 | ALPHATESTANDBLEND | |
  25134. *
  25135. */
  25136. set transparencyMode(value: Nullable<number>);
  25137. /**
  25138. * Returns true if alpha blending should be disabled.
  25139. */
  25140. protected get _disableAlphaBlending(): boolean;
  25141. /**
  25142. * Specifies whether or not this material should be rendered in alpha blend mode.
  25143. * @returns a boolean specifying if alpha blending is needed
  25144. */
  25145. needAlphaBlending(): boolean;
  25146. /**
  25147. * Specifies if the mesh will require alpha blending
  25148. * @param mesh defines the mesh to check
  25149. * @returns a boolean specifying if alpha blending is needed for the mesh
  25150. */
  25151. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25152. /**
  25153. * Specifies whether or not this material should be rendered in alpha test mode.
  25154. * @returns a boolean specifying if an alpha test is needed.
  25155. */
  25156. needAlphaTesting(): boolean;
  25157. /**
  25158. * Specifies if material alpha testing should be turned on for the mesh
  25159. * @param mesh defines the mesh to check
  25160. */
  25161. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25162. /**
  25163. * Gets the texture used for the alpha test
  25164. * @returns the texture to use for alpha testing
  25165. */
  25166. getAlphaTestTexture(): Nullable<BaseTexture>;
  25167. /**
  25168. * Marks the material to indicate that it needs to be re-calculated
  25169. */
  25170. markDirty(): void;
  25171. /** @hidden */
  25172. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25173. /**
  25174. * Binds the material to the mesh
  25175. * @param world defines the world transformation matrix
  25176. * @param mesh defines the mesh to bind the material to
  25177. */
  25178. bind(world: Matrix, mesh?: Mesh): void;
  25179. /**
  25180. * Binds the submesh to the material
  25181. * @param world defines the world transformation matrix
  25182. * @param mesh defines the mesh containing the submesh
  25183. * @param subMesh defines the submesh to bind the material to
  25184. */
  25185. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25186. /**
  25187. * Binds the world matrix to the material
  25188. * @param world defines the world transformation matrix
  25189. */
  25190. bindOnlyWorldMatrix(world: Matrix): void;
  25191. /**
  25192. * Binds the scene's uniform buffer to the effect.
  25193. * @param effect defines the effect to bind to the scene uniform buffer
  25194. * @param sceneUbo defines the uniform buffer storing scene data
  25195. */
  25196. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25197. /**
  25198. * Binds the view matrix to the effect
  25199. * @param effect defines the effect to bind the view matrix to
  25200. */
  25201. bindView(effect: Effect): void;
  25202. /**
  25203. * Binds the view projection matrix to the effect
  25204. * @param effect defines the effect to bind the view projection matrix to
  25205. */
  25206. bindViewProjection(effect: Effect): void;
  25207. /**
  25208. * Processes to execute after binding the material to a mesh
  25209. * @param mesh defines the rendered mesh
  25210. */
  25211. protected _afterBind(mesh?: Mesh): void;
  25212. /**
  25213. * Unbinds the material from the mesh
  25214. */
  25215. unbind(): void;
  25216. /**
  25217. * Gets the active textures from the material
  25218. * @returns an array of textures
  25219. */
  25220. getActiveTextures(): BaseTexture[];
  25221. /**
  25222. * Specifies if the material uses a texture
  25223. * @param texture defines the texture to check against the material
  25224. * @returns a boolean specifying if the material uses the texture
  25225. */
  25226. hasTexture(texture: BaseTexture): boolean;
  25227. /**
  25228. * Makes a duplicate of the material, and gives it a new name
  25229. * @param name defines the new name for the duplicated material
  25230. * @returns the cloned material
  25231. */
  25232. clone(name: string): Nullable<Material>;
  25233. /**
  25234. * Gets the meshes bound to the material
  25235. * @returns an array of meshes bound to the material
  25236. */
  25237. getBindedMeshes(): AbstractMesh[];
  25238. /**
  25239. * Force shader compilation
  25240. * @param mesh defines the mesh associated with this material
  25241. * @param onCompiled defines a function to execute once the material is compiled
  25242. * @param options defines the options to configure the compilation
  25243. * @param onError defines a function to execute if the material fails compiling
  25244. */
  25245. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25246. /**
  25247. * Force shader compilation
  25248. * @param mesh defines the mesh that will use this material
  25249. * @param options defines additional options for compiling the shaders
  25250. * @returns a promise that resolves when the compilation completes
  25251. */
  25252. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25253. private static readonly _AllDirtyCallBack;
  25254. private static readonly _ImageProcessingDirtyCallBack;
  25255. private static readonly _TextureDirtyCallBack;
  25256. private static readonly _FresnelDirtyCallBack;
  25257. private static readonly _MiscDirtyCallBack;
  25258. private static readonly _PrePassDirtyCallBack;
  25259. private static readonly _LightsDirtyCallBack;
  25260. private static readonly _AttributeDirtyCallBack;
  25261. private static _FresnelAndMiscDirtyCallBack;
  25262. private static _TextureAndMiscDirtyCallBack;
  25263. private static readonly _DirtyCallbackArray;
  25264. private static readonly _RunDirtyCallBacks;
  25265. /**
  25266. * Marks a define in the material to indicate that it needs to be re-computed
  25267. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25268. */
  25269. markAsDirty(flag: number): void;
  25270. /**
  25271. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25272. * @param func defines a function which checks material defines against the submeshes
  25273. */
  25274. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25275. /**
  25276. * Indicates that the scene should check if the rendering now needs a prepass
  25277. */
  25278. protected _markScenePrePassDirty(): void;
  25279. /**
  25280. * Indicates that we need to re-calculated for all submeshes
  25281. */
  25282. protected _markAllSubMeshesAsAllDirty(): void;
  25283. /**
  25284. * Indicates that image processing needs to be re-calculated for all submeshes
  25285. */
  25286. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25287. /**
  25288. * Indicates that textures need to be re-calculated for all submeshes
  25289. */
  25290. protected _markAllSubMeshesAsTexturesDirty(): void;
  25291. /**
  25292. * Indicates that fresnel needs to be re-calculated for all submeshes
  25293. */
  25294. protected _markAllSubMeshesAsFresnelDirty(): void;
  25295. /**
  25296. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25297. */
  25298. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25299. /**
  25300. * Indicates that lights need to be re-calculated for all submeshes
  25301. */
  25302. protected _markAllSubMeshesAsLightsDirty(): void;
  25303. /**
  25304. * Indicates that attributes need to be re-calculated for all submeshes
  25305. */
  25306. protected _markAllSubMeshesAsAttributesDirty(): void;
  25307. /**
  25308. * Indicates that misc needs to be re-calculated for all submeshes
  25309. */
  25310. protected _markAllSubMeshesAsMiscDirty(): void;
  25311. /**
  25312. * Indicates that prepass needs to be re-calculated for all submeshes
  25313. */
  25314. protected _markAllSubMeshesAsPrePassDirty(): void;
  25315. /**
  25316. * Indicates that textures and misc need to be re-calculated for all submeshes
  25317. */
  25318. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25319. /**
  25320. * Sets the required values to the prepass renderer.
  25321. * @param prePassRenderer defines the prepass renderer to setup.
  25322. * @returns true if the pre pass is needed.
  25323. */
  25324. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  25325. /**
  25326. * Disposes the material
  25327. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25328. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25329. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25330. */
  25331. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25332. /** @hidden */
  25333. private releaseVertexArrayObject;
  25334. /**
  25335. * Serializes this material
  25336. * @returns the serialized material object
  25337. */
  25338. serialize(): any;
  25339. /**
  25340. * Creates a material from parsed material data
  25341. * @param parsedMaterial defines parsed material data
  25342. * @param scene defines the hosting scene
  25343. * @param rootUrl defines the root URL to use to load textures
  25344. * @returns a new material
  25345. */
  25346. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25347. }
  25348. }
  25349. declare module BABYLON {
  25350. /**
  25351. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25352. * separate meshes. This can be use to improve performances.
  25353. * @see https://doc.babylonjs.com/how_to/multi_materials
  25354. */
  25355. export class MultiMaterial extends Material {
  25356. private _subMaterials;
  25357. /**
  25358. * Gets or Sets the list of Materials used within the multi material.
  25359. * They need to be ordered according to the submeshes order in the associated mesh
  25360. */
  25361. get subMaterials(): Nullable<Material>[];
  25362. set subMaterials(value: Nullable<Material>[]);
  25363. /**
  25364. * Function used to align with Node.getChildren()
  25365. * @returns the list of Materials used within the multi material
  25366. */
  25367. getChildren(): Nullable<Material>[];
  25368. /**
  25369. * Instantiates a new Multi Material
  25370. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25371. * separate meshes. This can be use to improve performances.
  25372. * @see https://doc.babylonjs.com/how_to/multi_materials
  25373. * @param name Define the name in the scene
  25374. * @param scene Define the scene the material belongs to
  25375. */
  25376. constructor(name: string, scene: Scene);
  25377. private _hookArray;
  25378. /**
  25379. * Get one of the submaterial by its index in the submaterials array
  25380. * @param index The index to look the sub material at
  25381. * @returns The Material if the index has been defined
  25382. */
  25383. getSubMaterial(index: number): Nullable<Material>;
  25384. /**
  25385. * Get the list of active textures for the whole sub materials list.
  25386. * @returns All the textures that will be used during the rendering
  25387. */
  25388. getActiveTextures(): BaseTexture[];
  25389. /**
  25390. * Gets the current class name of the material e.g. "MultiMaterial"
  25391. * Mainly use in serialization.
  25392. * @returns the class name
  25393. */
  25394. getClassName(): string;
  25395. /**
  25396. * Checks if the material is ready to render the requested sub mesh
  25397. * @param mesh Define the mesh the submesh belongs to
  25398. * @param subMesh Define the sub mesh to look readyness for
  25399. * @param useInstances Define whether or not the material is used with instances
  25400. * @returns true if ready, otherwise false
  25401. */
  25402. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25403. /**
  25404. * Clones the current material and its related sub materials
  25405. * @param name Define the name of the newly cloned material
  25406. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25407. * @returns the cloned material
  25408. */
  25409. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25410. /**
  25411. * Serializes the materials into a JSON representation.
  25412. * @returns the JSON representation
  25413. */
  25414. serialize(): any;
  25415. /**
  25416. * Dispose the material and release its associated resources
  25417. * @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)
  25418. * @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)
  25419. * @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)
  25420. */
  25421. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25422. /**
  25423. * Creates a MultiMaterial from parsed MultiMaterial data.
  25424. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25425. * @param scene defines the hosting scene
  25426. * @returns a new MultiMaterial
  25427. */
  25428. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25429. }
  25430. }
  25431. declare module BABYLON {
  25432. /**
  25433. * Defines a subdivision inside a mesh
  25434. */
  25435. export class SubMesh implements ICullable {
  25436. /** the material index to use */
  25437. materialIndex: number;
  25438. /** vertex index start */
  25439. verticesStart: number;
  25440. /** vertices count */
  25441. verticesCount: number;
  25442. /** index start */
  25443. indexStart: number;
  25444. /** indices count */
  25445. indexCount: number;
  25446. /** @hidden */
  25447. _materialDefines: Nullable<MaterialDefines>;
  25448. /** @hidden */
  25449. _materialEffect: Nullable<Effect>;
  25450. /** @hidden */
  25451. _effectOverride: Nullable<Effect>;
  25452. /**
  25453. * Gets material defines used by the effect associated to the sub mesh
  25454. */
  25455. get materialDefines(): Nullable<MaterialDefines>;
  25456. /**
  25457. * Sets material defines used by the effect associated to the sub mesh
  25458. */
  25459. set materialDefines(defines: Nullable<MaterialDefines>);
  25460. /**
  25461. * Gets associated effect
  25462. */
  25463. get effect(): Nullable<Effect>;
  25464. /**
  25465. * Sets associated effect (effect used to render this submesh)
  25466. * @param effect defines the effect to associate with
  25467. * @param defines defines the set of defines used to compile this effect
  25468. */
  25469. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25470. /** @hidden */
  25471. _linesIndexCount: number;
  25472. private _mesh;
  25473. private _renderingMesh;
  25474. private _boundingInfo;
  25475. private _linesIndexBuffer;
  25476. /** @hidden */
  25477. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25478. /** @hidden */
  25479. _trianglePlanes: Plane[];
  25480. /** @hidden */
  25481. _lastColliderTransformMatrix: Nullable<Matrix>;
  25482. /** @hidden */
  25483. _renderId: number;
  25484. /** @hidden */
  25485. _alphaIndex: number;
  25486. /** @hidden */
  25487. _distanceToCamera: number;
  25488. /** @hidden */
  25489. _id: number;
  25490. private _currentMaterial;
  25491. /**
  25492. * Add a new submesh to a mesh
  25493. * @param materialIndex defines the material index to use
  25494. * @param verticesStart defines vertex index start
  25495. * @param verticesCount defines vertices count
  25496. * @param indexStart defines index start
  25497. * @param indexCount defines indices count
  25498. * @param mesh defines the parent mesh
  25499. * @param renderingMesh defines an optional rendering mesh
  25500. * @param createBoundingBox defines if bounding box should be created for this submesh
  25501. * @returns the new submesh
  25502. */
  25503. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25504. /**
  25505. * Creates a new submesh
  25506. * @param materialIndex defines the material index to use
  25507. * @param verticesStart defines vertex index start
  25508. * @param verticesCount defines vertices count
  25509. * @param indexStart defines index start
  25510. * @param indexCount defines indices count
  25511. * @param mesh defines the parent mesh
  25512. * @param renderingMesh defines an optional rendering mesh
  25513. * @param createBoundingBox defines if bounding box should be created for this submesh
  25514. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25515. */
  25516. constructor(
  25517. /** the material index to use */
  25518. materialIndex: number,
  25519. /** vertex index start */
  25520. verticesStart: number,
  25521. /** vertices count */
  25522. verticesCount: number,
  25523. /** index start */
  25524. indexStart: number,
  25525. /** indices count */
  25526. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25527. /**
  25528. * Returns true if this submesh covers the entire parent mesh
  25529. * @ignorenaming
  25530. */
  25531. get IsGlobal(): boolean;
  25532. /**
  25533. * Returns the submesh BoudingInfo object
  25534. * @returns current bounding info (or mesh's one if the submesh is global)
  25535. */
  25536. getBoundingInfo(): BoundingInfo;
  25537. /**
  25538. * Sets the submesh BoundingInfo
  25539. * @param boundingInfo defines the new bounding info to use
  25540. * @returns the SubMesh
  25541. */
  25542. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25543. /**
  25544. * Returns the mesh of the current submesh
  25545. * @return the parent mesh
  25546. */
  25547. getMesh(): AbstractMesh;
  25548. /**
  25549. * Returns the rendering mesh of the submesh
  25550. * @returns the rendering mesh (could be different from parent mesh)
  25551. */
  25552. getRenderingMesh(): Mesh;
  25553. /**
  25554. * Returns the replacement mesh of the submesh
  25555. * @returns the replacement mesh (could be different from parent mesh)
  25556. */
  25557. getReplacementMesh(): Nullable<AbstractMesh>;
  25558. /**
  25559. * Returns the effective mesh of the submesh
  25560. * @returns the effective mesh (could be different from parent mesh)
  25561. */
  25562. getEffectiveMesh(): AbstractMesh;
  25563. /**
  25564. * Returns the submesh material
  25565. * @returns null or the current material
  25566. */
  25567. getMaterial(): Nullable<Material>;
  25568. private _IsMultiMaterial;
  25569. /**
  25570. * Sets a new updated BoundingInfo object to the submesh
  25571. * @param data defines an optional position array to use to determine the bounding info
  25572. * @returns the SubMesh
  25573. */
  25574. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25575. /** @hidden */
  25576. _checkCollision(collider: Collider): boolean;
  25577. /**
  25578. * Updates the submesh BoundingInfo
  25579. * @param world defines the world matrix to use to update the bounding info
  25580. * @returns the submesh
  25581. */
  25582. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25583. /**
  25584. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25585. * @param frustumPlanes defines the frustum planes
  25586. * @returns true if the submesh is intersecting with the frustum
  25587. */
  25588. isInFrustum(frustumPlanes: Plane[]): boolean;
  25589. /**
  25590. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25591. * @param frustumPlanes defines the frustum planes
  25592. * @returns true if the submesh is inside the frustum
  25593. */
  25594. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25595. /**
  25596. * Renders the submesh
  25597. * @param enableAlphaMode defines if alpha needs to be used
  25598. * @returns the submesh
  25599. */
  25600. render(enableAlphaMode: boolean): SubMesh;
  25601. /**
  25602. * @hidden
  25603. */
  25604. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25605. /**
  25606. * Checks if the submesh intersects with a ray
  25607. * @param ray defines the ray to test
  25608. * @returns true is the passed ray intersects the submesh bounding box
  25609. */
  25610. canIntersects(ray: Ray): boolean;
  25611. /**
  25612. * Intersects current submesh with a ray
  25613. * @param ray defines the ray to test
  25614. * @param positions defines mesh's positions array
  25615. * @param indices defines mesh's indices array
  25616. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25618. * @returns intersection info or null if no intersection
  25619. */
  25620. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25621. /** @hidden */
  25622. private _intersectLines;
  25623. /** @hidden */
  25624. private _intersectUnIndexedLines;
  25625. /** @hidden */
  25626. private _intersectTriangles;
  25627. /** @hidden */
  25628. private _intersectUnIndexedTriangles;
  25629. /** @hidden */
  25630. _rebuild(): void;
  25631. /**
  25632. * Creates a new submesh from the passed mesh
  25633. * @param newMesh defines the new hosting mesh
  25634. * @param newRenderingMesh defines an optional rendering mesh
  25635. * @returns the new submesh
  25636. */
  25637. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25638. /**
  25639. * Release associated resources
  25640. */
  25641. dispose(): void;
  25642. /**
  25643. * Gets the class name
  25644. * @returns the string "SubMesh".
  25645. */
  25646. getClassName(): string;
  25647. /**
  25648. * Creates a new submesh from indices data
  25649. * @param materialIndex the index of the main mesh material
  25650. * @param startIndex the index where to start the copy in the mesh indices array
  25651. * @param indexCount the number of indices to copy then from the startIndex
  25652. * @param mesh the main mesh to create the submesh from
  25653. * @param renderingMesh the optional rendering mesh
  25654. * @returns a new submesh
  25655. */
  25656. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25657. }
  25658. }
  25659. declare module BABYLON {
  25660. /**
  25661. * Class used to represent data loading progression
  25662. */
  25663. export class SceneLoaderFlags {
  25664. private static _ForceFullSceneLoadingForIncremental;
  25665. private static _ShowLoadingScreen;
  25666. private static _CleanBoneMatrixWeights;
  25667. private static _loggingLevel;
  25668. /**
  25669. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25670. */
  25671. static get ForceFullSceneLoadingForIncremental(): boolean;
  25672. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25673. /**
  25674. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25675. */
  25676. static get ShowLoadingScreen(): boolean;
  25677. static set ShowLoadingScreen(value: boolean);
  25678. /**
  25679. * Defines the current logging level (while loading the scene)
  25680. * @ignorenaming
  25681. */
  25682. static get loggingLevel(): number;
  25683. static set loggingLevel(value: number);
  25684. /**
  25685. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25686. */
  25687. static get CleanBoneMatrixWeights(): boolean;
  25688. static set CleanBoneMatrixWeights(value: boolean);
  25689. }
  25690. }
  25691. declare module BABYLON {
  25692. /**
  25693. * Class used to store geometry data (vertex buffers + index buffer)
  25694. */
  25695. export class Geometry implements IGetSetVerticesData {
  25696. /**
  25697. * Gets or sets the ID of the geometry
  25698. */
  25699. id: string;
  25700. /**
  25701. * Gets or sets the unique ID of the geometry
  25702. */
  25703. uniqueId: number;
  25704. /**
  25705. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25706. */
  25707. delayLoadState: number;
  25708. /**
  25709. * Gets the file containing the data to load when running in delay load state
  25710. */
  25711. delayLoadingFile: Nullable<string>;
  25712. /**
  25713. * Callback called when the geometry is updated
  25714. */
  25715. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25716. private _scene;
  25717. private _engine;
  25718. private _meshes;
  25719. private _totalVertices;
  25720. /** @hidden */
  25721. _indices: IndicesArray;
  25722. /** @hidden */
  25723. _vertexBuffers: {
  25724. [key: string]: VertexBuffer;
  25725. };
  25726. private _isDisposed;
  25727. private _extend;
  25728. private _boundingBias;
  25729. /** @hidden */
  25730. _delayInfo: Array<string>;
  25731. private _indexBuffer;
  25732. private _indexBufferIsUpdatable;
  25733. /** @hidden */
  25734. _boundingInfo: Nullable<BoundingInfo>;
  25735. /** @hidden */
  25736. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25737. /** @hidden */
  25738. _softwareSkinningFrameId: number;
  25739. private _vertexArrayObjects;
  25740. private _updatable;
  25741. /** @hidden */
  25742. _positions: Nullable<Vector3[]>;
  25743. /**
  25744. * 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
  25745. */
  25746. get boundingBias(): Vector2;
  25747. /**
  25748. * 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
  25749. */
  25750. set boundingBias(value: Vector2);
  25751. /**
  25752. * Static function used to attach a new empty geometry to a mesh
  25753. * @param mesh defines the mesh to attach the geometry to
  25754. * @returns the new Geometry
  25755. */
  25756. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25757. /** Get the list of meshes using this geometry */
  25758. get meshes(): Mesh[];
  25759. /**
  25760. * 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
  25761. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25762. */
  25763. useBoundingInfoFromGeometry: boolean;
  25764. /**
  25765. * Creates a new geometry
  25766. * @param id defines the unique ID
  25767. * @param scene defines the hosting scene
  25768. * @param vertexData defines the VertexData used to get geometry data
  25769. * @param updatable defines if geometry must be updatable (false by default)
  25770. * @param mesh defines the mesh that will be associated with the geometry
  25771. */
  25772. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25773. /**
  25774. * Gets the current extend of the geometry
  25775. */
  25776. get extend(): {
  25777. minimum: Vector3;
  25778. maximum: Vector3;
  25779. };
  25780. /**
  25781. * Gets the hosting scene
  25782. * @returns the hosting Scene
  25783. */
  25784. getScene(): Scene;
  25785. /**
  25786. * Gets the hosting engine
  25787. * @returns the hosting Engine
  25788. */
  25789. getEngine(): Engine;
  25790. /**
  25791. * Defines if the geometry is ready to use
  25792. * @returns true if the geometry is ready to be used
  25793. */
  25794. isReady(): boolean;
  25795. /**
  25796. * Gets a value indicating that the geometry should not be serialized
  25797. */
  25798. get doNotSerialize(): boolean;
  25799. /** @hidden */
  25800. _rebuild(): void;
  25801. /**
  25802. * Affects all geometry data in one call
  25803. * @param vertexData defines the geometry data
  25804. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25805. */
  25806. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25807. /**
  25808. * Set specific vertex data
  25809. * @param kind defines the data kind (Position, normal, etc...)
  25810. * @param data defines the vertex data to use
  25811. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25812. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25813. */
  25814. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25815. /**
  25816. * Removes a specific vertex data
  25817. * @param kind defines the data kind (Position, normal, etc...)
  25818. */
  25819. removeVerticesData(kind: string): void;
  25820. /**
  25821. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25822. * @param buffer defines the vertex buffer to use
  25823. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25824. */
  25825. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25826. /**
  25827. * Update a specific vertex buffer
  25828. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25829. * It will do nothing if the buffer is not updatable
  25830. * @param kind defines the data kind (Position, normal, etc...)
  25831. * @param data defines the data to use
  25832. * @param offset defines the offset in the target buffer where to store the data
  25833. * @param useBytes set to true if the offset is in bytes
  25834. */
  25835. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25836. /**
  25837. * Update a specific vertex buffer
  25838. * This function will create a new buffer if the current one is not updatable
  25839. * @param kind defines the data kind (Position, normal, etc...)
  25840. * @param data defines the data to use
  25841. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25842. */
  25843. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25844. private _updateBoundingInfo;
  25845. /** @hidden */
  25846. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25847. /**
  25848. * Gets total number of vertices
  25849. * @returns the total number of vertices
  25850. */
  25851. getTotalVertices(): number;
  25852. /**
  25853. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25854. * @param kind defines the data kind (Position, normal, etc...)
  25855. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25856. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25857. * @returns a float array containing vertex data
  25858. */
  25859. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25860. /**
  25861. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25862. * @param kind defines the data kind (Position, normal, etc...)
  25863. * @returns true if the vertex buffer with the specified kind is updatable
  25864. */
  25865. isVertexBufferUpdatable(kind: string): boolean;
  25866. /**
  25867. * Gets a specific vertex buffer
  25868. * @param kind defines the data kind (Position, normal, etc...)
  25869. * @returns a VertexBuffer
  25870. */
  25871. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25872. /**
  25873. * Returns all vertex buffers
  25874. * @return an object holding all vertex buffers indexed by kind
  25875. */
  25876. getVertexBuffers(): Nullable<{
  25877. [key: string]: VertexBuffer;
  25878. }>;
  25879. /**
  25880. * Gets a boolean indicating if specific vertex buffer is present
  25881. * @param kind defines the data kind (Position, normal, etc...)
  25882. * @returns true if data is present
  25883. */
  25884. isVerticesDataPresent(kind: string): boolean;
  25885. /**
  25886. * Gets a list of all attached data kinds (Position, normal, etc...)
  25887. * @returns a list of string containing all kinds
  25888. */
  25889. getVerticesDataKinds(): string[];
  25890. /**
  25891. * Update index buffer
  25892. * @param indices defines the indices to store in the index buffer
  25893. * @param offset defines the offset in the target buffer where to store the data
  25894. * @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)
  25895. */
  25896. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25897. /**
  25898. * Creates a new index buffer
  25899. * @param indices defines the indices to store in the index buffer
  25900. * @param totalVertices defines the total number of vertices (could be null)
  25901. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25902. */
  25903. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25904. /**
  25905. * Return the total number of indices
  25906. * @returns the total number of indices
  25907. */
  25908. getTotalIndices(): number;
  25909. /**
  25910. * Gets the index buffer array
  25911. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25912. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25913. * @returns the index buffer array
  25914. */
  25915. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25916. /**
  25917. * Gets the index buffer
  25918. * @return the index buffer
  25919. */
  25920. getIndexBuffer(): Nullable<DataBuffer>;
  25921. /** @hidden */
  25922. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25923. /**
  25924. * Release the associated resources for a specific mesh
  25925. * @param mesh defines the source mesh
  25926. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25927. */
  25928. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25929. /**
  25930. * Apply current geometry to a given mesh
  25931. * @param mesh defines the mesh to apply geometry to
  25932. */
  25933. applyToMesh(mesh: Mesh): void;
  25934. private _updateExtend;
  25935. private _applyToMesh;
  25936. private notifyUpdate;
  25937. /**
  25938. * Load the geometry if it was flagged as delay loaded
  25939. * @param scene defines the hosting scene
  25940. * @param onLoaded defines a callback called when the geometry is loaded
  25941. */
  25942. load(scene: Scene, onLoaded?: () => void): void;
  25943. private _queueLoad;
  25944. /**
  25945. * Invert the geometry to move from a right handed system to a left handed one.
  25946. */
  25947. toLeftHanded(): void;
  25948. /** @hidden */
  25949. _resetPointsArrayCache(): void;
  25950. /** @hidden */
  25951. _generatePointsArray(): boolean;
  25952. /**
  25953. * Gets a value indicating if the geometry is disposed
  25954. * @returns true if the geometry was disposed
  25955. */
  25956. isDisposed(): boolean;
  25957. private _disposeVertexArrayObjects;
  25958. /**
  25959. * Free all associated resources
  25960. */
  25961. dispose(): void;
  25962. /**
  25963. * Clone the current geometry into a new geometry
  25964. * @param id defines the unique ID of the new geometry
  25965. * @returns a new geometry object
  25966. */
  25967. copy(id: string): Geometry;
  25968. /**
  25969. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25970. * @return a JSON representation of the current geometry data (without the vertices data)
  25971. */
  25972. serialize(): any;
  25973. private toNumberArray;
  25974. /**
  25975. * Serialize all vertices data into a JSON oject
  25976. * @returns a JSON representation of the current geometry data
  25977. */
  25978. serializeVerticeData(): any;
  25979. /**
  25980. * Extracts a clone of a mesh geometry
  25981. * @param mesh defines the source mesh
  25982. * @param id defines the unique ID of the new geometry object
  25983. * @returns the new geometry object
  25984. */
  25985. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25986. /**
  25987. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25988. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25989. * Be aware Math.random() could cause collisions, but:
  25990. * "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"
  25991. * @returns a string containing a new GUID
  25992. */
  25993. static RandomId(): string;
  25994. /** @hidden */
  25995. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25996. private static _CleanMatricesWeights;
  25997. /**
  25998. * Create a new geometry from persisted data (Using .babylon file format)
  25999. * @param parsedVertexData defines the persisted data
  26000. * @param scene defines the hosting scene
  26001. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26002. * @returns the new geometry object
  26003. */
  26004. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26005. }
  26006. }
  26007. declare module BABYLON {
  26008. /**
  26009. * Define an interface for all classes that will get and set the data on vertices
  26010. */
  26011. export interface IGetSetVerticesData {
  26012. /**
  26013. * Gets a boolean indicating if specific vertex data is present
  26014. * @param kind defines the vertex data kind to use
  26015. * @returns true is data kind is present
  26016. */
  26017. isVerticesDataPresent(kind: string): boolean;
  26018. /**
  26019. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26020. * @param kind defines the data kind (Position, normal, etc...)
  26021. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26022. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26023. * @returns a float array containing vertex data
  26024. */
  26025. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26026. /**
  26027. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26028. * @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.
  26029. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26030. * @returns the indices array or an empty array if the mesh has no geometry
  26031. */
  26032. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26033. /**
  26034. * Set specific vertex data
  26035. * @param kind defines the data kind (Position, normal, etc...)
  26036. * @param data defines the vertex data to use
  26037. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26038. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26039. */
  26040. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26041. /**
  26042. * Update a specific associated vertex buffer
  26043. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26044. * - VertexBuffer.PositionKind
  26045. * - VertexBuffer.UVKind
  26046. * - VertexBuffer.UV2Kind
  26047. * - VertexBuffer.UV3Kind
  26048. * - VertexBuffer.UV4Kind
  26049. * - VertexBuffer.UV5Kind
  26050. * - VertexBuffer.UV6Kind
  26051. * - VertexBuffer.ColorKind
  26052. * - VertexBuffer.MatricesIndicesKind
  26053. * - VertexBuffer.MatricesIndicesExtraKind
  26054. * - VertexBuffer.MatricesWeightsKind
  26055. * - VertexBuffer.MatricesWeightsExtraKind
  26056. * @param data defines the data source
  26057. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26058. * @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)
  26059. */
  26060. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26061. /**
  26062. * Creates a new index buffer
  26063. * @param indices defines the indices to store in the index buffer
  26064. * @param totalVertices defines the total number of vertices (could be null)
  26065. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26066. */
  26067. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26068. }
  26069. /**
  26070. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26071. */
  26072. export class VertexData {
  26073. /**
  26074. * Mesh side orientation : usually the external or front surface
  26075. */
  26076. static readonly FRONTSIDE: number;
  26077. /**
  26078. * Mesh side orientation : usually the internal or back surface
  26079. */
  26080. static readonly BACKSIDE: number;
  26081. /**
  26082. * Mesh side orientation : both internal and external or front and back surfaces
  26083. */
  26084. static readonly DOUBLESIDE: number;
  26085. /**
  26086. * Mesh side orientation : by default, `FRONTSIDE`
  26087. */
  26088. static readonly DEFAULTSIDE: number;
  26089. /**
  26090. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26091. */
  26092. positions: Nullable<FloatArray>;
  26093. /**
  26094. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26095. */
  26096. normals: Nullable<FloatArray>;
  26097. /**
  26098. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26099. */
  26100. tangents: Nullable<FloatArray>;
  26101. /**
  26102. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26103. */
  26104. uvs: Nullable<FloatArray>;
  26105. /**
  26106. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26107. */
  26108. uvs2: Nullable<FloatArray>;
  26109. /**
  26110. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26111. */
  26112. uvs3: Nullable<FloatArray>;
  26113. /**
  26114. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26115. */
  26116. uvs4: Nullable<FloatArray>;
  26117. /**
  26118. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26119. */
  26120. uvs5: Nullable<FloatArray>;
  26121. /**
  26122. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26123. */
  26124. uvs6: Nullable<FloatArray>;
  26125. /**
  26126. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  26127. */
  26128. colors: Nullable<FloatArray>;
  26129. /**
  26130. * 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).
  26131. */
  26132. matricesIndices: Nullable<FloatArray>;
  26133. /**
  26134. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26135. */
  26136. matricesWeights: Nullable<FloatArray>;
  26137. /**
  26138. * An array extending the number of possible indices
  26139. */
  26140. matricesIndicesExtra: Nullable<FloatArray>;
  26141. /**
  26142. * An array extending the number of possible weights when the number of indices is extended
  26143. */
  26144. matricesWeightsExtra: Nullable<FloatArray>;
  26145. /**
  26146. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26147. */
  26148. indices: Nullable<IndicesArray>;
  26149. /**
  26150. * Uses the passed data array to set the set the values for the specified kind of data
  26151. * @param data a linear array of floating numbers
  26152. * @param kind the type of data that is being set, eg positions, colors etc
  26153. */
  26154. set(data: FloatArray, kind: string): void;
  26155. /**
  26156. * Associates the vertexData to the passed Mesh.
  26157. * Sets it as updatable or not (default `false`)
  26158. * @param mesh the mesh the vertexData is applied to
  26159. * @param updatable when used and having the value true allows new data to update the vertexData
  26160. * @returns the VertexData
  26161. */
  26162. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26163. /**
  26164. * Associates the vertexData to the passed Geometry.
  26165. * Sets it as updatable or not (default `false`)
  26166. * @param geometry the geometry the vertexData is applied to
  26167. * @param updatable when used and having the value true allows new data to update the vertexData
  26168. * @returns VertexData
  26169. */
  26170. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26171. /**
  26172. * Updates the associated mesh
  26173. * @param mesh the mesh to be updated
  26174. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26175. * @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
  26176. * @returns VertexData
  26177. */
  26178. updateMesh(mesh: Mesh): VertexData;
  26179. /**
  26180. * Updates the associated geometry
  26181. * @param geometry the geometry to be updated
  26182. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26183. * @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
  26184. * @returns VertexData.
  26185. */
  26186. updateGeometry(geometry: Geometry): VertexData;
  26187. private _applyTo;
  26188. private _update;
  26189. /**
  26190. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26191. * @param matrix the transforming matrix
  26192. * @returns the VertexData
  26193. */
  26194. transform(matrix: Matrix): VertexData;
  26195. /**
  26196. * Merges the passed VertexData into the current one
  26197. * @param other the VertexData to be merged into the current one
  26198. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26199. * @returns the modified VertexData
  26200. */
  26201. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26202. private _mergeElement;
  26203. private _validate;
  26204. /**
  26205. * Serializes the VertexData
  26206. * @returns a serialized object
  26207. */
  26208. serialize(): any;
  26209. /**
  26210. * Extracts the vertexData from a mesh
  26211. * @param mesh the mesh from which to extract the VertexData
  26212. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26213. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26214. * @returns the object VertexData associated to the passed mesh
  26215. */
  26216. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26217. /**
  26218. * Extracts the vertexData from the geometry
  26219. * @param geometry the geometry from which to extract the VertexData
  26220. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26221. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26222. * @returns the object VertexData associated to the passed mesh
  26223. */
  26224. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26225. private static _ExtractFrom;
  26226. /**
  26227. * Creates the VertexData for a Ribbon
  26228. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26229. * * pathArray array of paths, each of which an array of successive Vector3
  26230. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26231. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26232. * * 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
  26233. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26234. * * 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)
  26235. * * 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)
  26236. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26237. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26238. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26239. * @returns the VertexData of the ribbon
  26240. */
  26241. static CreateRibbon(options: {
  26242. pathArray: Vector3[][];
  26243. closeArray?: boolean;
  26244. closePath?: boolean;
  26245. offset?: number;
  26246. sideOrientation?: number;
  26247. frontUVs?: Vector4;
  26248. backUVs?: Vector4;
  26249. invertUV?: boolean;
  26250. uvs?: Vector2[];
  26251. colors?: Color4[];
  26252. }): VertexData;
  26253. /**
  26254. * Creates the VertexData for a box
  26255. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26256. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26257. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26258. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26259. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26260. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26261. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26262. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26263. * * 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)
  26264. * * 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)
  26265. * @returns the VertexData of the box
  26266. */
  26267. static CreateBox(options: {
  26268. size?: number;
  26269. width?: number;
  26270. height?: number;
  26271. depth?: number;
  26272. faceUV?: Vector4[];
  26273. faceColors?: Color4[];
  26274. sideOrientation?: number;
  26275. frontUVs?: Vector4;
  26276. backUVs?: Vector4;
  26277. }): VertexData;
  26278. /**
  26279. * Creates the VertexData for a tiled box
  26280. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26281. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26282. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26283. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26284. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26285. * @returns the VertexData of the box
  26286. */
  26287. static CreateTiledBox(options: {
  26288. pattern?: number;
  26289. width?: number;
  26290. height?: number;
  26291. depth?: number;
  26292. tileSize?: number;
  26293. tileWidth?: number;
  26294. tileHeight?: number;
  26295. alignHorizontal?: number;
  26296. alignVertical?: number;
  26297. faceUV?: Vector4[];
  26298. faceColors?: Color4[];
  26299. sideOrientation?: number;
  26300. }): VertexData;
  26301. /**
  26302. * Creates the VertexData for a tiled plane
  26303. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26304. * * pattern a limited pattern arrangement depending on the number
  26305. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26306. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26307. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26308. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26309. * * 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)
  26310. * * 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)
  26311. * @returns the VertexData of the tiled plane
  26312. */
  26313. static CreateTiledPlane(options: {
  26314. pattern?: number;
  26315. tileSize?: number;
  26316. tileWidth?: number;
  26317. tileHeight?: number;
  26318. size?: number;
  26319. width?: number;
  26320. height?: number;
  26321. alignHorizontal?: number;
  26322. alignVertical?: number;
  26323. sideOrientation?: number;
  26324. frontUVs?: Vector4;
  26325. backUVs?: Vector4;
  26326. }): VertexData;
  26327. /**
  26328. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26329. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26330. * * segments sets the number of horizontal strips optional, default 32
  26331. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26332. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26333. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26334. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26335. * * 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
  26336. * * 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
  26337. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26338. * * 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)
  26339. * * 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)
  26340. * @returns the VertexData of the ellipsoid
  26341. */
  26342. static CreateSphere(options: {
  26343. segments?: number;
  26344. diameter?: number;
  26345. diameterX?: number;
  26346. diameterY?: number;
  26347. diameterZ?: number;
  26348. arc?: number;
  26349. slice?: number;
  26350. sideOrientation?: number;
  26351. frontUVs?: Vector4;
  26352. backUVs?: Vector4;
  26353. }): VertexData;
  26354. /**
  26355. * Creates the VertexData for a cylinder, cone or prism
  26356. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26357. * * height sets the height (y direction) of the cylinder, optional, default 2
  26358. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26359. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26360. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26361. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26362. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26363. * * 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
  26364. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26365. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26366. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26367. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26368. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26369. * * 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)
  26370. * * 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)
  26371. * @returns the VertexData of the cylinder, cone or prism
  26372. */
  26373. static CreateCylinder(options: {
  26374. height?: number;
  26375. diameterTop?: number;
  26376. diameterBottom?: number;
  26377. diameter?: number;
  26378. tessellation?: number;
  26379. subdivisions?: number;
  26380. arc?: number;
  26381. faceColors?: Color4[];
  26382. faceUV?: Vector4[];
  26383. hasRings?: boolean;
  26384. enclose?: boolean;
  26385. sideOrientation?: number;
  26386. frontUVs?: Vector4;
  26387. backUVs?: Vector4;
  26388. }): VertexData;
  26389. /**
  26390. * Creates the VertexData for a torus
  26391. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26392. * * diameter the diameter of the torus, optional default 1
  26393. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26394. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26395. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26396. * * 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)
  26397. * * 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)
  26398. * @returns the VertexData of the torus
  26399. */
  26400. static CreateTorus(options: {
  26401. diameter?: number;
  26402. thickness?: number;
  26403. tessellation?: number;
  26404. sideOrientation?: number;
  26405. frontUVs?: Vector4;
  26406. backUVs?: Vector4;
  26407. }): VertexData;
  26408. /**
  26409. * Creates the VertexData of the LineSystem
  26410. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26411. * - lines an array of lines, each line being an array of successive Vector3
  26412. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26413. * @returns the VertexData of the LineSystem
  26414. */
  26415. static CreateLineSystem(options: {
  26416. lines: Vector3[][];
  26417. colors?: Nullable<Color4[][]>;
  26418. }): VertexData;
  26419. /**
  26420. * Create the VertexData for a DashedLines
  26421. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26422. * - points an array successive Vector3
  26423. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26424. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26425. * - dashNb the intended total number of dashes, optional, default 200
  26426. * @returns the VertexData for the DashedLines
  26427. */
  26428. static CreateDashedLines(options: {
  26429. points: Vector3[];
  26430. dashSize?: number;
  26431. gapSize?: number;
  26432. dashNb?: number;
  26433. }): VertexData;
  26434. /**
  26435. * Creates the VertexData for a Ground
  26436. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26437. * - width the width (x direction) of the ground, optional, default 1
  26438. * - height the height (z direction) of the ground, optional, default 1
  26439. * - subdivisions the number of subdivisions per side, optional, default 1
  26440. * @returns the VertexData of the Ground
  26441. */
  26442. static CreateGround(options: {
  26443. width?: number;
  26444. height?: number;
  26445. subdivisions?: number;
  26446. subdivisionsX?: number;
  26447. subdivisionsY?: number;
  26448. }): VertexData;
  26449. /**
  26450. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26451. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26452. * * xmin the ground minimum X coordinate, optional, default -1
  26453. * * zmin the ground minimum Z coordinate, optional, default -1
  26454. * * xmax the ground maximum X coordinate, optional, default 1
  26455. * * zmax the ground maximum Z coordinate, optional, default 1
  26456. * * 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}
  26457. * * 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}
  26458. * @returns the VertexData of the TiledGround
  26459. */
  26460. static CreateTiledGround(options: {
  26461. xmin: number;
  26462. zmin: number;
  26463. xmax: number;
  26464. zmax: number;
  26465. subdivisions?: {
  26466. w: number;
  26467. h: number;
  26468. };
  26469. precision?: {
  26470. w: number;
  26471. h: number;
  26472. };
  26473. }): VertexData;
  26474. /**
  26475. * Creates the VertexData of the Ground designed from a heightmap
  26476. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26477. * * width the width (x direction) of the ground
  26478. * * height the height (z direction) of the ground
  26479. * * subdivisions the number of subdivisions per side
  26480. * * minHeight the minimum altitude on the ground, optional, default 0
  26481. * * maxHeight the maximum altitude on the ground, optional default 1
  26482. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26483. * * buffer the array holding the image color data
  26484. * * bufferWidth the width of image
  26485. * * bufferHeight the height of image
  26486. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26487. * @returns the VertexData of the Ground designed from a heightmap
  26488. */
  26489. static CreateGroundFromHeightMap(options: {
  26490. width: number;
  26491. height: number;
  26492. subdivisions: number;
  26493. minHeight: number;
  26494. maxHeight: number;
  26495. colorFilter: Color3;
  26496. buffer: Uint8Array;
  26497. bufferWidth: number;
  26498. bufferHeight: number;
  26499. alphaFilter: number;
  26500. }): VertexData;
  26501. /**
  26502. * Creates the VertexData for a Plane
  26503. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26504. * * size sets the width and height of the plane to the value of size, optional default 1
  26505. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26506. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26507. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26508. * * 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)
  26509. * * 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)
  26510. * @returns the VertexData of the box
  26511. */
  26512. static CreatePlane(options: {
  26513. size?: number;
  26514. width?: number;
  26515. height?: number;
  26516. sideOrientation?: number;
  26517. frontUVs?: Vector4;
  26518. backUVs?: Vector4;
  26519. }): VertexData;
  26520. /**
  26521. * Creates the VertexData of the Disc or regular Polygon
  26522. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26523. * * radius the radius of the disc, optional default 0.5
  26524. * * tessellation the number of polygon sides, optional, default 64
  26525. * * 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
  26526. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26527. * * 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)
  26528. * * 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)
  26529. * @returns the VertexData of the box
  26530. */
  26531. static CreateDisc(options: {
  26532. radius?: number;
  26533. tessellation?: number;
  26534. arc?: number;
  26535. sideOrientation?: number;
  26536. frontUVs?: Vector4;
  26537. backUVs?: Vector4;
  26538. }): VertexData;
  26539. /**
  26540. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26541. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26542. * @param polygon a mesh built from polygonTriangulation.build()
  26543. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26544. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26545. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26546. * @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)
  26547. * @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)
  26548. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26549. * @returns the VertexData of the Polygon
  26550. */
  26551. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26552. /**
  26553. * Creates the VertexData of the IcoSphere
  26554. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26555. * * radius the radius of the IcoSphere, optional default 1
  26556. * * radiusX allows stretching in the x direction, optional, default radius
  26557. * * radiusY allows stretching in the y direction, optional, default radius
  26558. * * radiusZ allows stretching in the z direction, optional, default radius
  26559. * * flat when true creates a flat shaded mesh, optional, default true
  26560. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26561. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26562. * * 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)
  26563. * * 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)
  26564. * @returns the VertexData of the IcoSphere
  26565. */
  26566. static CreateIcoSphere(options: {
  26567. radius?: number;
  26568. radiusX?: number;
  26569. radiusY?: number;
  26570. radiusZ?: number;
  26571. flat?: boolean;
  26572. subdivisions?: number;
  26573. sideOrientation?: number;
  26574. frontUVs?: Vector4;
  26575. backUVs?: Vector4;
  26576. }): VertexData;
  26577. /**
  26578. * Creates the VertexData for a Polyhedron
  26579. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26580. * * type provided types are:
  26581. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26582. * * 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)
  26583. * * size the size of the IcoSphere, optional default 1
  26584. * * sizeX allows stretching in the x direction, optional, default size
  26585. * * sizeY allows stretching in the y direction, optional, default size
  26586. * * sizeZ allows stretching in the z direction, optional, default size
  26587. * * 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
  26588. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26589. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26590. * * flat when true creates a flat shaded mesh, optional, default true
  26591. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26593. * * 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)
  26594. * * 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)
  26595. * @returns the VertexData of the Polyhedron
  26596. */
  26597. static CreatePolyhedron(options: {
  26598. type?: number;
  26599. size?: number;
  26600. sizeX?: number;
  26601. sizeY?: number;
  26602. sizeZ?: number;
  26603. custom?: any;
  26604. faceUV?: Vector4[];
  26605. faceColors?: Color4[];
  26606. flat?: boolean;
  26607. sideOrientation?: number;
  26608. frontUVs?: Vector4;
  26609. backUVs?: Vector4;
  26610. }): VertexData;
  26611. /**
  26612. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  26613. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  26614. * @returns the VertexData of the Capsule
  26615. */
  26616. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  26617. /**
  26618. * Creates the VertexData for a TorusKnot
  26619. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26620. * * radius the radius of the torus knot, optional, default 2
  26621. * * tube the thickness of the tube, optional, default 0.5
  26622. * * radialSegments the number of sides on each tube segments, optional, default 32
  26623. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26624. * * p the number of windings around the z axis, optional, default 2
  26625. * * q the number of windings around the x axis, optional, default 3
  26626. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26627. * * 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)
  26628. * * 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)
  26629. * @returns the VertexData of the Torus Knot
  26630. */
  26631. static CreateTorusKnot(options: {
  26632. radius?: number;
  26633. tube?: number;
  26634. radialSegments?: number;
  26635. tubularSegments?: number;
  26636. p?: number;
  26637. q?: number;
  26638. sideOrientation?: number;
  26639. frontUVs?: Vector4;
  26640. backUVs?: Vector4;
  26641. }): VertexData;
  26642. /**
  26643. * Compute normals for given positions and indices
  26644. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26645. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26646. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26647. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26648. * * facetNormals : optional array of facet normals (vector3)
  26649. * * facetPositions : optional array of facet positions (vector3)
  26650. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26651. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26652. * * bInfo : optional bounding info, required for facetPartitioning computation
  26653. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26654. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26655. * * useRightHandedSystem: optional boolean to for right handed system computation
  26656. * * depthSort : optional boolean to enable the facet depth sort computation
  26657. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26658. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26659. */
  26660. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26661. facetNormals?: any;
  26662. facetPositions?: any;
  26663. facetPartitioning?: any;
  26664. ratio?: number;
  26665. bInfo?: any;
  26666. bbSize?: Vector3;
  26667. subDiv?: any;
  26668. useRightHandedSystem?: boolean;
  26669. depthSort?: boolean;
  26670. distanceTo?: Vector3;
  26671. depthSortedFacets?: any;
  26672. }): void;
  26673. /** @hidden */
  26674. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26675. /**
  26676. * Applies VertexData created from the imported parameters to the geometry
  26677. * @param parsedVertexData the parsed data from an imported file
  26678. * @param geometry the geometry to apply the VertexData to
  26679. */
  26680. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26681. }
  26682. }
  26683. declare module BABYLON {
  26684. /**
  26685. * Defines a target to use with MorphTargetManager
  26686. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26687. */
  26688. export class MorphTarget implements IAnimatable {
  26689. /** defines the name of the target */
  26690. name: string;
  26691. /**
  26692. * Gets or sets the list of animations
  26693. */
  26694. animations: Animation[];
  26695. private _scene;
  26696. private _positions;
  26697. private _normals;
  26698. private _tangents;
  26699. private _uvs;
  26700. private _influence;
  26701. private _uniqueId;
  26702. /**
  26703. * Observable raised when the influence changes
  26704. */
  26705. onInfluenceChanged: Observable<boolean>;
  26706. /** @hidden */
  26707. _onDataLayoutChanged: Observable<void>;
  26708. /**
  26709. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26710. */
  26711. get influence(): number;
  26712. set influence(influence: number);
  26713. /**
  26714. * Gets or sets the id of the morph Target
  26715. */
  26716. id: string;
  26717. private _animationPropertiesOverride;
  26718. /**
  26719. * Gets or sets the animation properties override
  26720. */
  26721. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26722. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26723. /**
  26724. * Creates a new MorphTarget
  26725. * @param name defines the name of the target
  26726. * @param influence defines the influence to use
  26727. * @param scene defines the scene the morphtarget belongs to
  26728. */
  26729. constructor(
  26730. /** defines the name of the target */
  26731. name: string, influence?: number, scene?: Nullable<Scene>);
  26732. /**
  26733. * Gets the unique ID of this manager
  26734. */
  26735. get uniqueId(): number;
  26736. /**
  26737. * Gets a boolean defining if the target contains position data
  26738. */
  26739. get hasPositions(): boolean;
  26740. /**
  26741. * Gets a boolean defining if the target contains normal data
  26742. */
  26743. get hasNormals(): boolean;
  26744. /**
  26745. * Gets a boolean defining if the target contains tangent data
  26746. */
  26747. get hasTangents(): boolean;
  26748. /**
  26749. * Gets a boolean defining if the target contains texture coordinates data
  26750. */
  26751. get hasUVs(): boolean;
  26752. /**
  26753. * Affects position data to this target
  26754. * @param data defines the position data to use
  26755. */
  26756. setPositions(data: Nullable<FloatArray>): void;
  26757. /**
  26758. * Gets the position data stored in this target
  26759. * @returns a FloatArray containing the position data (or null if not present)
  26760. */
  26761. getPositions(): Nullable<FloatArray>;
  26762. /**
  26763. * Affects normal data to this target
  26764. * @param data defines the normal data to use
  26765. */
  26766. setNormals(data: Nullable<FloatArray>): void;
  26767. /**
  26768. * Gets the normal data stored in this target
  26769. * @returns a FloatArray containing the normal data (or null if not present)
  26770. */
  26771. getNormals(): Nullable<FloatArray>;
  26772. /**
  26773. * Affects tangent data to this target
  26774. * @param data defines the tangent data to use
  26775. */
  26776. setTangents(data: Nullable<FloatArray>): void;
  26777. /**
  26778. * Gets the tangent data stored in this target
  26779. * @returns a FloatArray containing the tangent data (or null if not present)
  26780. */
  26781. getTangents(): Nullable<FloatArray>;
  26782. /**
  26783. * Affects texture coordinates data to this target
  26784. * @param data defines the texture coordinates data to use
  26785. */
  26786. setUVs(data: Nullable<FloatArray>): void;
  26787. /**
  26788. * Gets the texture coordinates data stored in this target
  26789. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26790. */
  26791. getUVs(): Nullable<FloatArray>;
  26792. /**
  26793. * Clone the current target
  26794. * @returns a new MorphTarget
  26795. */
  26796. clone(): MorphTarget;
  26797. /**
  26798. * Serializes the current target into a Serialization object
  26799. * @returns the serialized object
  26800. */
  26801. serialize(): any;
  26802. /**
  26803. * Returns the string "MorphTarget"
  26804. * @returns "MorphTarget"
  26805. */
  26806. getClassName(): string;
  26807. /**
  26808. * Creates a new target from serialized data
  26809. * @param serializationObject defines the serialized data to use
  26810. * @returns a new MorphTarget
  26811. */
  26812. static Parse(serializationObject: any): MorphTarget;
  26813. /**
  26814. * Creates a MorphTarget from mesh data
  26815. * @param mesh defines the source mesh
  26816. * @param name defines the name to use for the new target
  26817. * @param influence defines the influence to attach to the target
  26818. * @returns a new MorphTarget
  26819. */
  26820. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26821. }
  26822. }
  26823. declare module BABYLON {
  26824. /**
  26825. * This class is used to deform meshes using morphing between different targets
  26826. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26827. */
  26828. export class MorphTargetManager {
  26829. private _targets;
  26830. private _targetInfluenceChangedObservers;
  26831. private _targetDataLayoutChangedObservers;
  26832. private _activeTargets;
  26833. private _scene;
  26834. private _influences;
  26835. private _supportsNormals;
  26836. private _supportsTangents;
  26837. private _supportsUVs;
  26838. private _vertexCount;
  26839. private _uniqueId;
  26840. private _tempInfluences;
  26841. /**
  26842. * Gets or sets a boolean indicating if normals must be morphed
  26843. */
  26844. enableNormalMorphing: boolean;
  26845. /**
  26846. * Gets or sets a boolean indicating if tangents must be morphed
  26847. */
  26848. enableTangentMorphing: boolean;
  26849. /**
  26850. * Gets or sets a boolean indicating if UV must be morphed
  26851. */
  26852. enableUVMorphing: boolean;
  26853. /**
  26854. * Creates a new MorphTargetManager
  26855. * @param scene defines the current scene
  26856. */
  26857. constructor(scene?: Nullable<Scene>);
  26858. /**
  26859. * Gets the unique ID of this manager
  26860. */
  26861. get uniqueId(): number;
  26862. /**
  26863. * Gets the number of vertices handled by this manager
  26864. */
  26865. get vertexCount(): number;
  26866. /**
  26867. * Gets a boolean indicating if this manager supports morphing of normals
  26868. */
  26869. get supportsNormals(): boolean;
  26870. /**
  26871. * Gets a boolean indicating if this manager supports morphing of tangents
  26872. */
  26873. get supportsTangents(): boolean;
  26874. /**
  26875. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26876. */
  26877. get supportsUVs(): boolean;
  26878. /**
  26879. * Gets the number of targets stored in this manager
  26880. */
  26881. get numTargets(): number;
  26882. /**
  26883. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26884. */
  26885. get numInfluencers(): number;
  26886. /**
  26887. * Gets the list of influences (one per target)
  26888. */
  26889. get influences(): Float32Array;
  26890. /**
  26891. * Gets the active target at specified index. An active target is a target with an influence > 0
  26892. * @param index defines the index to check
  26893. * @returns the requested target
  26894. */
  26895. getActiveTarget(index: number): MorphTarget;
  26896. /**
  26897. * Gets the target at specified index
  26898. * @param index defines the index to check
  26899. * @returns the requested target
  26900. */
  26901. getTarget(index: number): MorphTarget;
  26902. /**
  26903. * Add a new target to this manager
  26904. * @param target defines the target to add
  26905. */
  26906. addTarget(target: MorphTarget): void;
  26907. /**
  26908. * Removes a target from the manager
  26909. * @param target defines the target to remove
  26910. */
  26911. removeTarget(target: MorphTarget): void;
  26912. /**
  26913. * Clone the current manager
  26914. * @returns a new MorphTargetManager
  26915. */
  26916. clone(): MorphTargetManager;
  26917. /**
  26918. * Serializes the current manager into a Serialization object
  26919. * @returns the serialized object
  26920. */
  26921. serialize(): any;
  26922. private _syncActiveTargets;
  26923. /**
  26924. * Syncrhonize the targets with all the meshes using this morph target manager
  26925. */
  26926. synchronize(): void;
  26927. /**
  26928. * Creates a new MorphTargetManager from serialized data
  26929. * @param serializationObject defines the serialized data
  26930. * @param scene defines the hosting scene
  26931. * @returns the new MorphTargetManager
  26932. */
  26933. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26934. }
  26935. }
  26936. declare module BABYLON {
  26937. /**
  26938. * Class used to represent a specific level of detail of a mesh
  26939. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26940. */
  26941. export class MeshLODLevel {
  26942. /** Defines the distance where this level should start being displayed */
  26943. distance: number;
  26944. /** Defines the mesh to use to render this level */
  26945. mesh: Nullable<Mesh>;
  26946. /**
  26947. * Creates a new LOD level
  26948. * @param distance defines the distance where this level should star being displayed
  26949. * @param mesh defines the mesh to use to render this level
  26950. */
  26951. constructor(
  26952. /** Defines the distance where this level should start being displayed */
  26953. distance: number,
  26954. /** Defines the mesh to use to render this level */
  26955. mesh: Nullable<Mesh>);
  26956. }
  26957. }
  26958. declare module BABYLON {
  26959. /**
  26960. * Helper class used to generate a canvas to manipulate images
  26961. */
  26962. export class CanvasGenerator {
  26963. /**
  26964. * Create a new canvas (or offscreen canvas depending on the context)
  26965. * @param width defines the expected width
  26966. * @param height defines the expected height
  26967. * @return a new canvas or offscreen canvas
  26968. */
  26969. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26970. }
  26971. }
  26972. declare module BABYLON {
  26973. /**
  26974. * Mesh representing the gorund
  26975. */
  26976. export class GroundMesh extends Mesh {
  26977. /** If octree should be generated */
  26978. generateOctree: boolean;
  26979. private _heightQuads;
  26980. /** @hidden */
  26981. _subdivisionsX: number;
  26982. /** @hidden */
  26983. _subdivisionsY: number;
  26984. /** @hidden */
  26985. _width: number;
  26986. /** @hidden */
  26987. _height: number;
  26988. /** @hidden */
  26989. _minX: number;
  26990. /** @hidden */
  26991. _maxX: number;
  26992. /** @hidden */
  26993. _minZ: number;
  26994. /** @hidden */
  26995. _maxZ: number;
  26996. constructor(name: string, scene: Scene);
  26997. /**
  26998. * "GroundMesh"
  26999. * @returns "GroundMesh"
  27000. */
  27001. getClassName(): string;
  27002. /**
  27003. * The minimum of x and y subdivisions
  27004. */
  27005. get subdivisions(): number;
  27006. /**
  27007. * X subdivisions
  27008. */
  27009. get subdivisionsX(): number;
  27010. /**
  27011. * Y subdivisions
  27012. */
  27013. get subdivisionsY(): number;
  27014. /**
  27015. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27016. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27017. * @param chunksCount the number of subdivisions for x and y
  27018. * @param octreeBlocksSize (Default: 32)
  27019. */
  27020. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27021. /**
  27022. * Returns a height (y) value in the Worl system :
  27023. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27024. * @param x x coordinate
  27025. * @param z z coordinate
  27026. * @returns the ground y position if (x, z) are outside the ground surface.
  27027. */
  27028. getHeightAtCoordinates(x: number, z: number): number;
  27029. /**
  27030. * Returns a normalized vector (Vector3) orthogonal to the ground
  27031. * at the ground coordinates (x, z) expressed in the World system.
  27032. * @param x x coordinate
  27033. * @param z z coordinate
  27034. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27035. */
  27036. getNormalAtCoordinates(x: number, z: number): Vector3;
  27037. /**
  27038. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27039. * at the ground coordinates (x, z) expressed in the World system.
  27040. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27041. * @param x x coordinate
  27042. * @param z z coordinate
  27043. * @param ref vector to store the result
  27044. * @returns the GroundMesh.
  27045. */
  27046. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27047. /**
  27048. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27049. * if the ground has been updated.
  27050. * This can be used in the render loop.
  27051. * @returns the GroundMesh.
  27052. */
  27053. updateCoordinateHeights(): GroundMesh;
  27054. private _getFacetAt;
  27055. private _initHeightQuads;
  27056. private _computeHeightQuads;
  27057. /**
  27058. * Serializes this ground mesh
  27059. * @param serializationObject object to write serialization to
  27060. */
  27061. serialize(serializationObject: any): void;
  27062. /**
  27063. * Parses a serialized ground mesh
  27064. * @param parsedMesh the serialized mesh
  27065. * @param scene the scene to create the ground mesh in
  27066. * @returns the created ground mesh
  27067. */
  27068. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27069. }
  27070. }
  27071. declare module BABYLON {
  27072. /**
  27073. * Interface for Physics-Joint data
  27074. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27075. */
  27076. export interface PhysicsJointData {
  27077. /**
  27078. * The main pivot of the joint
  27079. */
  27080. mainPivot?: Vector3;
  27081. /**
  27082. * The connected pivot of the joint
  27083. */
  27084. connectedPivot?: Vector3;
  27085. /**
  27086. * The main axis of the joint
  27087. */
  27088. mainAxis?: Vector3;
  27089. /**
  27090. * The connected axis of the joint
  27091. */
  27092. connectedAxis?: Vector3;
  27093. /**
  27094. * The collision of the joint
  27095. */
  27096. collision?: boolean;
  27097. /**
  27098. * Native Oimo/Cannon/Energy data
  27099. */
  27100. nativeParams?: any;
  27101. }
  27102. /**
  27103. * This is a holder class for the physics joint created by the physics plugin
  27104. * It holds a set of functions to control the underlying joint
  27105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27106. */
  27107. export class PhysicsJoint {
  27108. /**
  27109. * The type of the physics joint
  27110. */
  27111. type: number;
  27112. /**
  27113. * The data for the physics joint
  27114. */
  27115. jointData: PhysicsJointData;
  27116. private _physicsJoint;
  27117. protected _physicsPlugin: IPhysicsEnginePlugin;
  27118. /**
  27119. * Initializes the physics joint
  27120. * @param type The type of the physics joint
  27121. * @param jointData The data for the physics joint
  27122. */
  27123. constructor(
  27124. /**
  27125. * The type of the physics joint
  27126. */
  27127. type: number,
  27128. /**
  27129. * The data for the physics joint
  27130. */
  27131. jointData: PhysicsJointData);
  27132. /**
  27133. * Gets the physics joint
  27134. */
  27135. get physicsJoint(): any;
  27136. /**
  27137. * Sets the physics joint
  27138. */
  27139. set physicsJoint(newJoint: any);
  27140. /**
  27141. * Sets the physics plugin
  27142. */
  27143. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27144. /**
  27145. * Execute a function that is physics-plugin specific.
  27146. * @param {Function} func the function that will be executed.
  27147. * It accepts two parameters: the physics world and the physics joint
  27148. */
  27149. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27150. /**
  27151. * Distance-Joint type
  27152. */
  27153. static DistanceJoint: number;
  27154. /**
  27155. * Hinge-Joint type
  27156. */
  27157. static HingeJoint: number;
  27158. /**
  27159. * Ball-and-Socket joint type
  27160. */
  27161. static BallAndSocketJoint: number;
  27162. /**
  27163. * Wheel-Joint type
  27164. */
  27165. static WheelJoint: number;
  27166. /**
  27167. * Slider-Joint type
  27168. */
  27169. static SliderJoint: number;
  27170. /**
  27171. * Prismatic-Joint type
  27172. */
  27173. static PrismaticJoint: number;
  27174. /**
  27175. * Universal-Joint type
  27176. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27177. */
  27178. static UniversalJoint: number;
  27179. /**
  27180. * Hinge-Joint 2 type
  27181. */
  27182. static Hinge2Joint: number;
  27183. /**
  27184. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27185. */
  27186. static PointToPointJoint: number;
  27187. /**
  27188. * Spring-Joint type
  27189. */
  27190. static SpringJoint: number;
  27191. /**
  27192. * Lock-Joint type
  27193. */
  27194. static LockJoint: number;
  27195. }
  27196. /**
  27197. * A class representing a physics distance joint
  27198. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27199. */
  27200. export class DistanceJoint extends PhysicsJoint {
  27201. /**
  27202. *
  27203. * @param jointData The data for the Distance-Joint
  27204. */
  27205. constructor(jointData: DistanceJointData);
  27206. /**
  27207. * Update the predefined distance.
  27208. * @param maxDistance The maximum preferred distance
  27209. * @param minDistance The minimum preferred distance
  27210. */
  27211. updateDistance(maxDistance: number, minDistance?: number): void;
  27212. }
  27213. /**
  27214. * Represents a Motor-Enabled Joint
  27215. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27216. */
  27217. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27218. /**
  27219. * Initializes the Motor-Enabled Joint
  27220. * @param type The type of the joint
  27221. * @param jointData The physica joint data for the joint
  27222. */
  27223. constructor(type: number, jointData: PhysicsJointData);
  27224. /**
  27225. * Set the motor values.
  27226. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27227. * @param force the force to apply
  27228. * @param maxForce max force for this motor.
  27229. */
  27230. setMotor(force?: number, maxForce?: number): void;
  27231. /**
  27232. * Set the motor's limits.
  27233. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27234. * @param upperLimit The upper limit of the motor
  27235. * @param lowerLimit The lower limit of the motor
  27236. */
  27237. setLimit(upperLimit: number, lowerLimit?: number): void;
  27238. }
  27239. /**
  27240. * This class represents a single physics Hinge-Joint
  27241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27242. */
  27243. export class HingeJoint extends MotorEnabledJoint {
  27244. /**
  27245. * Initializes the Hinge-Joint
  27246. * @param jointData The joint data for the Hinge-Joint
  27247. */
  27248. constructor(jointData: PhysicsJointData);
  27249. /**
  27250. * Set the motor values.
  27251. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27252. * @param {number} force the force to apply
  27253. * @param {number} maxForce max force for this motor.
  27254. */
  27255. setMotor(force?: number, maxForce?: number): void;
  27256. /**
  27257. * Set the motor's limits.
  27258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27259. * @param upperLimit The upper limit of the motor
  27260. * @param lowerLimit The lower limit of the motor
  27261. */
  27262. setLimit(upperLimit: number, lowerLimit?: number): void;
  27263. }
  27264. /**
  27265. * This class represents a dual hinge physics joint (same as wheel joint)
  27266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27267. */
  27268. export class Hinge2Joint extends MotorEnabledJoint {
  27269. /**
  27270. * Initializes the Hinge2-Joint
  27271. * @param jointData The joint data for the Hinge2-Joint
  27272. */
  27273. constructor(jointData: PhysicsJointData);
  27274. /**
  27275. * Set the motor values.
  27276. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27277. * @param {number} targetSpeed the speed the motor is to reach
  27278. * @param {number} maxForce max force for this motor.
  27279. * @param {motorIndex} the motor's index, 0 or 1.
  27280. */
  27281. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27282. /**
  27283. * Set the motor limits.
  27284. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27285. * @param {number} upperLimit the upper limit
  27286. * @param {number} lowerLimit lower limit
  27287. * @param {motorIndex} the motor's index, 0 or 1.
  27288. */
  27289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27290. }
  27291. /**
  27292. * Interface for a motor enabled joint
  27293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27294. */
  27295. export interface IMotorEnabledJoint {
  27296. /**
  27297. * Physics joint
  27298. */
  27299. physicsJoint: any;
  27300. /**
  27301. * Sets the motor of the motor-enabled joint
  27302. * @param force The force of the motor
  27303. * @param maxForce The maximum force of the motor
  27304. * @param motorIndex The index of the motor
  27305. */
  27306. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27307. /**
  27308. * Sets the limit of the motor
  27309. * @param upperLimit The upper limit of the motor
  27310. * @param lowerLimit The lower limit of the motor
  27311. * @param motorIndex The index of the motor
  27312. */
  27313. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27314. }
  27315. /**
  27316. * Joint data for a Distance-Joint
  27317. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27318. */
  27319. export interface DistanceJointData extends PhysicsJointData {
  27320. /**
  27321. * Max distance the 2 joint objects can be apart
  27322. */
  27323. maxDistance: number;
  27324. }
  27325. /**
  27326. * Joint data from a spring joint
  27327. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27328. */
  27329. export interface SpringJointData extends PhysicsJointData {
  27330. /**
  27331. * Length of the spring
  27332. */
  27333. length: number;
  27334. /**
  27335. * Stiffness of the spring
  27336. */
  27337. stiffness: number;
  27338. /**
  27339. * Damping of the spring
  27340. */
  27341. damping: number;
  27342. /** this callback will be called when applying the force to the impostors. */
  27343. forceApplicationCallback: () => void;
  27344. }
  27345. }
  27346. declare module BABYLON {
  27347. /**
  27348. * Holds the data for the raycast result
  27349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27350. */
  27351. export class PhysicsRaycastResult {
  27352. private _hasHit;
  27353. private _hitDistance;
  27354. private _hitNormalWorld;
  27355. private _hitPointWorld;
  27356. private _rayFromWorld;
  27357. private _rayToWorld;
  27358. /**
  27359. * Gets if there was a hit
  27360. */
  27361. get hasHit(): boolean;
  27362. /**
  27363. * Gets the distance from the hit
  27364. */
  27365. get hitDistance(): number;
  27366. /**
  27367. * Gets the hit normal/direction in the world
  27368. */
  27369. get hitNormalWorld(): Vector3;
  27370. /**
  27371. * Gets the hit point in the world
  27372. */
  27373. get hitPointWorld(): Vector3;
  27374. /**
  27375. * Gets the ray "start point" of the ray in the world
  27376. */
  27377. get rayFromWorld(): Vector3;
  27378. /**
  27379. * Gets the ray "end point" of the ray in the world
  27380. */
  27381. get rayToWorld(): Vector3;
  27382. /**
  27383. * Sets the hit data (normal & point in world space)
  27384. * @param hitNormalWorld defines the normal in world space
  27385. * @param hitPointWorld defines the point in world space
  27386. */
  27387. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27388. /**
  27389. * Sets the distance from the start point to the hit point
  27390. * @param distance
  27391. */
  27392. setHitDistance(distance: number): void;
  27393. /**
  27394. * Calculates the distance manually
  27395. */
  27396. calculateHitDistance(): void;
  27397. /**
  27398. * Resets all the values to default
  27399. * @param from The from point on world space
  27400. * @param to The to point on world space
  27401. */
  27402. reset(from?: Vector3, to?: Vector3): void;
  27403. }
  27404. /**
  27405. * Interface for the size containing width and height
  27406. */
  27407. interface IXYZ {
  27408. /**
  27409. * X
  27410. */
  27411. x: number;
  27412. /**
  27413. * Y
  27414. */
  27415. y: number;
  27416. /**
  27417. * Z
  27418. */
  27419. z: number;
  27420. }
  27421. }
  27422. declare module BABYLON {
  27423. /**
  27424. * Interface used to describe a physics joint
  27425. */
  27426. export interface PhysicsImpostorJoint {
  27427. /** Defines the main impostor to which the joint is linked */
  27428. mainImpostor: PhysicsImpostor;
  27429. /** Defines the impostor that is connected to the main impostor using this joint */
  27430. connectedImpostor: PhysicsImpostor;
  27431. /** Defines the joint itself */
  27432. joint: PhysicsJoint;
  27433. }
  27434. /** @hidden */
  27435. export interface IPhysicsEnginePlugin {
  27436. world: any;
  27437. name: string;
  27438. setGravity(gravity: Vector3): void;
  27439. setTimeStep(timeStep: number): void;
  27440. getTimeStep(): number;
  27441. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27442. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27443. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27444. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27445. removePhysicsBody(impostor: PhysicsImpostor): void;
  27446. generateJoint(joint: PhysicsImpostorJoint): void;
  27447. removeJoint(joint: PhysicsImpostorJoint): void;
  27448. isSupported(): boolean;
  27449. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27450. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27451. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27452. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27453. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27454. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27455. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27456. getBodyMass(impostor: PhysicsImpostor): number;
  27457. getBodyFriction(impostor: PhysicsImpostor): number;
  27458. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27459. getBodyRestitution(impostor: PhysicsImpostor): number;
  27460. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27461. getBodyPressure?(impostor: PhysicsImpostor): number;
  27462. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27463. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27464. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27465. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27466. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27467. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27468. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27469. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27470. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27471. sleepBody(impostor: PhysicsImpostor): void;
  27472. wakeUpBody(impostor: PhysicsImpostor): void;
  27473. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27474. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27475. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27476. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27477. getRadius(impostor: PhysicsImpostor): number;
  27478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27479. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27480. dispose(): void;
  27481. }
  27482. /**
  27483. * Interface used to define a physics engine
  27484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27485. */
  27486. export interface IPhysicsEngine {
  27487. /**
  27488. * Gets the gravity vector used by the simulation
  27489. */
  27490. gravity: Vector3;
  27491. /**
  27492. * Sets the gravity vector used by the simulation
  27493. * @param gravity defines the gravity vector to use
  27494. */
  27495. setGravity(gravity: Vector3): void;
  27496. /**
  27497. * Set the time step of the physics engine.
  27498. * Default is 1/60.
  27499. * To slow it down, enter 1/600 for example.
  27500. * To speed it up, 1/30
  27501. * @param newTimeStep the new timestep to apply to this world.
  27502. */
  27503. setTimeStep(newTimeStep: number): void;
  27504. /**
  27505. * Get the time step of the physics engine.
  27506. * @returns the current time step
  27507. */
  27508. getTimeStep(): number;
  27509. /**
  27510. * Set the sub time step of the physics engine.
  27511. * Default is 0 meaning there is no sub steps
  27512. * To increase physics resolution precision, set a small value (like 1 ms)
  27513. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27514. */
  27515. setSubTimeStep(subTimeStep: number): void;
  27516. /**
  27517. * Get the sub time step of the physics engine.
  27518. * @returns the current sub time step
  27519. */
  27520. getSubTimeStep(): number;
  27521. /**
  27522. * Release all resources
  27523. */
  27524. dispose(): void;
  27525. /**
  27526. * Gets the name of the current physics plugin
  27527. * @returns the name of the plugin
  27528. */
  27529. getPhysicsPluginName(): string;
  27530. /**
  27531. * Adding a new impostor for the impostor tracking.
  27532. * This will be done by the impostor itself.
  27533. * @param impostor the impostor to add
  27534. */
  27535. addImpostor(impostor: PhysicsImpostor): void;
  27536. /**
  27537. * Remove an impostor from the engine.
  27538. * This impostor and its mesh will not longer be updated by the physics engine.
  27539. * @param impostor the impostor to remove
  27540. */
  27541. removeImpostor(impostor: PhysicsImpostor): void;
  27542. /**
  27543. * Add a joint to the physics engine
  27544. * @param mainImpostor defines the main impostor to which the joint is added.
  27545. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27546. * @param joint defines the joint that will connect both impostors.
  27547. */
  27548. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27549. /**
  27550. * Removes a joint from the simulation
  27551. * @param mainImpostor defines the impostor used with the joint
  27552. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27553. * @param joint defines the joint to remove
  27554. */
  27555. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27556. /**
  27557. * Gets the current plugin used to run the simulation
  27558. * @returns current plugin
  27559. */
  27560. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27561. /**
  27562. * Gets the list of physic impostors
  27563. * @returns an array of PhysicsImpostor
  27564. */
  27565. getImpostors(): Array<PhysicsImpostor>;
  27566. /**
  27567. * Gets the impostor for a physics enabled object
  27568. * @param object defines the object impersonated by the impostor
  27569. * @returns the PhysicsImpostor or null if not found
  27570. */
  27571. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27572. /**
  27573. * Gets the impostor for a physics body object
  27574. * @param body defines physics body used by the impostor
  27575. * @returns the PhysicsImpostor or null if not found
  27576. */
  27577. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27578. /**
  27579. * Does a raycast in the physics world
  27580. * @param from when should the ray start?
  27581. * @param to when should the ray end?
  27582. * @returns PhysicsRaycastResult
  27583. */
  27584. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27585. /**
  27586. * Called by the scene. No need to call it.
  27587. * @param delta defines the timespam between frames
  27588. */
  27589. _step(delta: number): void;
  27590. }
  27591. }
  27592. declare module BABYLON {
  27593. /**
  27594. * The interface for the physics imposter parameters
  27595. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27596. */
  27597. export interface PhysicsImpostorParameters {
  27598. /**
  27599. * The mass of the physics imposter
  27600. */
  27601. mass: number;
  27602. /**
  27603. * The friction of the physics imposter
  27604. */
  27605. friction?: number;
  27606. /**
  27607. * The coefficient of restitution of the physics imposter
  27608. */
  27609. restitution?: number;
  27610. /**
  27611. * The native options of the physics imposter
  27612. */
  27613. nativeOptions?: any;
  27614. /**
  27615. * Specifies if the parent should be ignored
  27616. */
  27617. ignoreParent?: boolean;
  27618. /**
  27619. * Specifies if bi-directional transformations should be disabled
  27620. */
  27621. disableBidirectionalTransformation?: boolean;
  27622. /**
  27623. * The pressure inside the physics imposter, soft object only
  27624. */
  27625. pressure?: number;
  27626. /**
  27627. * The stiffness the physics imposter, soft object only
  27628. */
  27629. stiffness?: number;
  27630. /**
  27631. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27632. */
  27633. velocityIterations?: number;
  27634. /**
  27635. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27636. */
  27637. positionIterations?: number;
  27638. /**
  27639. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27640. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27641. * Add to fix multiple points
  27642. */
  27643. fixedPoints?: number;
  27644. /**
  27645. * The collision margin around a soft object
  27646. */
  27647. margin?: number;
  27648. /**
  27649. * The collision margin around a soft object
  27650. */
  27651. damping?: number;
  27652. /**
  27653. * The path for a rope based on an extrusion
  27654. */
  27655. path?: any;
  27656. /**
  27657. * The shape of an extrusion used for a rope based on an extrusion
  27658. */
  27659. shape?: any;
  27660. }
  27661. /**
  27662. * Interface for a physics-enabled object
  27663. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27664. */
  27665. export interface IPhysicsEnabledObject {
  27666. /**
  27667. * The position of the physics-enabled object
  27668. */
  27669. position: Vector3;
  27670. /**
  27671. * The rotation of the physics-enabled object
  27672. */
  27673. rotationQuaternion: Nullable<Quaternion>;
  27674. /**
  27675. * The scale of the physics-enabled object
  27676. */
  27677. scaling: Vector3;
  27678. /**
  27679. * The rotation of the physics-enabled object
  27680. */
  27681. rotation?: Vector3;
  27682. /**
  27683. * The parent of the physics-enabled object
  27684. */
  27685. parent?: any;
  27686. /**
  27687. * The bounding info of the physics-enabled object
  27688. * @returns The bounding info of the physics-enabled object
  27689. */
  27690. getBoundingInfo(): BoundingInfo;
  27691. /**
  27692. * Computes the world matrix
  27693. * @param force Specifies if the world matrix should be computed by force
  27694. * @returns A world matrix
  27695. */
  27696. computeWorldMatrix(force: boolean): Matrix;
  27697. /**
  27698. * Gets the world matrix
  27699. * @returns A world matrix
  27700. */
  27701. getWorldMatrix?(): Matrix;
  27702. /**
  27703. * Gets the child meshes
  27704. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27705. * @returns An array of abstract meshes
  27706. */
  27707. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27708. /**
  27709. * Gets the vertex data
  27710. * @param kind The type of vertex data
  27711. * @returns A nullable array of numbers, or a float32 array
  27712. */
  27713. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27714. /**
  27715. * Gets the indices from the mesh
  27716. * @returns A nullable array of index arrays
  27717. */
  27718. getIndices?(): Nullable<IndicesArray>;
  27719. /**
  27720. * Gets the scene from the mesh
  27721. * @returns the indices array or null
  27722. */
  27723. getScene?(): Scene;
  27724. /**
  27725. * Gets the absolute position from the mesh
  27726. * @returns the absolute position
  27727. */
  27728. getAbsolutePosition(): Vector3;
  27729. /**
  27730. * Gets the absolute pivot point from the mesh
  27731. * @returns the absolute pivot point
  27732. */
  27733. getAbsolutePivotPoint(): Vector3;
  27734. /**
  27735. * Rotates the mesh
  27736. * @param axis The axis of rotation
  27737. * @param amount The amount of rotation
  27738. * @param space The space of the rotation
  27739. * @returns The rotation transform node
  27740. */
  27741. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27742. /**
  27743. * Translates the mesh
  27744. * @param axis The axis of translation
  27745. * @param distance The distance of translation
  27746. * @param space The space of the translation
  27747. * @returns The transform node
  27748. */
  27749. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27750. /**
  27751. * Sets the absolute position of the mesh
  27752. * @param absolutePosition The absolute position of the mesh
  27753. * @returns The transform node
  27754. */
  27755. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27756. /**
  27757. * Gets the class name of the mesh
  27758. * @returns The class name
  27759. */
  27760. getClassName(): string;
  27761. }
  27762. /**
  27763. * Represents a physics imposter
  27764. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27765. */
  27766. export class PhysicsImpostor {
  27767. /**
  27768. * The physics-enabled object used as the physics imposter
  27769. */
  27770. object: IPhysicsEnabledObject;
  27771. /**
  27772. * The type of the physics imposter
  27773. */
  27774. type: number;
  27775. private _options;
  27776. private _scene?;
  27777. /**
  27778. * The default object size of the imposter
  27779. */
  27780. static DEFAULT_OBJECT_SIZE: Vector3;
  27781. /**
  27782. * The identity quaternion of the imposter
  27783. */
  27784. static IDENTITY_QUATERNION: Quaternion;
  27785. /** @hidden */
  27786. _pluginData: any;
  27787. private _physicsEngine;
  27788. private _physicsBody;
  27789. private _bodyUpdateRequired;
  27790. private _onBeforePhysicsStepCallbacks;
  27791. private _onAfterPhysicsStepCallbacks;
  27792. /** @hidden */
  27793. _onPhysicsCollideCallbacks: Array<{
  27794. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27795. otherImpostors: Array<PhysicsImpostor>;
  27796. }>;
  27797. private _deltaPosition;
  27798. private _deltaRotation;
  27799. private _deltaRotationConjugated;
  27800. /** @hidden */
  27801. _isFromLine: boolean;
  27802. private _parent;
  27803. private _isDisposed;
  27804. private static _tmpVecs;
  27805. private static _tmpQuat;
  27806. /**
  27807. * Specifies if the physics imposter is disposed
  27808. */
  27809. get isDisposed(): boolean;
  27810. /**
  27811. * Gets the mass of the physics imposter
  27812. */
  27813. get mass(): number;
  27814. set mass(value: number);
  27815. /**
  27816. * Gets the coefficient of friction
  27817. */
  27818. get friction(): number;
  27819. /**
  27820. * Sets the coefficient of friction
  27821. */
  27822. set friction(value: number);
  27823. /**
  27824. * Gets the coefficient of restitution
  27825. */
  27826. get restitution(): number;
  27827. /**
  27828. * Sets the coefficient of restitution
  27829. */
  27830. set restitution(value: number);
  27831. /**
  27832. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27833. */
  27834. get pressure(): number;
  27835. /**
  27836. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27837. */
  27838. set pressure(value: number);
  27839. /**
  27840. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27841. */
  27842. get stiffness(): number;
  27843. /**
  27844. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27845. */
  27846. set stiffness(value: number);
  27847. /**
  27848. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27849. */
  27850. get velocityIterations(): number;
  27851. /**
  27852. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27853. */
  27854. set velocityIterations(value: number);
  27855. /**
  27856. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27857. */
  27858. get positionIterations(): number;
  27859. /**
  27860. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27861. */
  27862. set positionIterations(value: number);
  27863. /**
  27864. * The unique id of the physics imposter
  27865. * set by the physics engine when adding this impostor to the array
  27866. */
  27867. uniqueId: number;
  27868. /**
  27869. * @hidden
  27870. */
  27871. soft: boolean;
  27872. /**
  27873. * @hidden
  27874. */
  27875. segments: number;
  27876. private _joints;
  27877. /**
  27878. * Initializes the physics imposter
  27879. * @param object The physics-enabled object used as the physics imposter
  27880. * @param type The type of the physics imposter
  27881. * @param _options The options for the physics imposter
  27882. * @param _scene The Babylon scene
  27883. */
  27884. constructor(
  27885. /**
  27886. * The physics-enabled object used as the physics imposter
  27887. */
  27888. object: IPhysicsEnabledObject,
  27889. /**
  27890. * The type of the physics imposter
  27891. */
  27892. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27893. /**
  27894. * This function will completly initialize this impostor.
  27895. * It will create a new body - but only if this mesh has no parent.
  27896. * If it has, this impostor will not be used other than to define the impostor
  27897. * of the child mesh.
  27898. * @hidden
  27899. */
  27900. _init(): void;
  27901. private _getPhysicsParent;
  27902. /**
  27903. * Should a new body be generated.
  27904. * @returns boolean specifying if body initialization is required
  27905. */
  27906. isBodyInitRequired(): boolean;
  27907. /**
  27908. * Sets the updated scaling
  27909. * @param updated Specifies if the scaling is updated
  27910. */
  27911. setScalingUpdated(): void;
  27912. /**
  27913. * Force a regeneration of this or the parent's impostor's body.
  27914. * Use under cautious - This will remove all joints already implemented.
  27915. */
  27916. forceUpdate(): void;
  27917. /**
  27918. * Gets the body that holds this impostor. Either its own, or its parent.
  27919. */
  27920. get physicsBody(): any;
  27921. /**
  27922. * Get the parent of the physics imposter
  27923. * @returns Physics imposter or null
  27924. */
  27925. get parent(): Nullable<PhysicsImpostor>;
  27926. /**
  27927. * Sets the parent of the physics imposter
  27928. */
  27929. set parent(value: Nullable<PhysicsImpostor>);
  27930. /**
  27931. * Set the physics body. Used mainly by the physics engine/plugin
  27932. */
  27933. set physicsBody(physicsBody: any);
  27934. /**
  27935. * Resets the update flags
  27936. */
  27937. resetUpdateFlags(): void;
  27938. /**
  27939. * Gets the object extend size
  27940. * @returns the object extend size
  27941. */
  27942. getObjectExtendSize(): Vector3;
  27943. /**
  27944. * Gets the object center
  27945. * @returns The object center
  27946. */
  27947. getObjectCenter(): Vector3;
  27948. /**
  27949. * Get a specific parameter from the options parameters
  27950. * @param paramName The object parameter name
  27951. * @returns The object parameter
  27952. */
  27953. getParam(paramName: string): any;
  27954. /**
  27955. * Sets a specific parameter in the options given to the physics plugin
  27956. * @param paramName The parameter name
  27957. * @param value The value of the parameter
  27958. */
  27959. setParam(paramName: string, value: number): void;
  27960. /**
  27961. * Specifically change the body's mass option. Won't recreate the physics body object
  27962. * @param mass The mass of the physics imposter
  27963. */
  27964. setMass(mass: number): void;
  27965. /**
  27966. * Gets the linear velocity
  27967. * @returns linear velocity or null
  27968. */
  27969. getLinearVelocity(): Nullable<Vector3>;
  27970. /**
  27971. * Sets the linear velocity
  27972. * @param velocity linear velocity or null
  27973. */
  27974. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27975. /**
  27976. * Gets the angular velocity
  27977. * @returns angular velocity or null
  27978. */
  27979. getAngularVelocity(): Nullable<Vector3>;
  27980. /**
  27981. * Sets the angular velocity
  27982. * @param velocity The velocity or null
  27983. */
  27984. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27985. /**
  27986. * Execute a function with the physics plugin native code
  27987. * Provide a function the will have two variables - the world object and the physics body object
  27988. * @param func The function to execute with the physics plugin native code
  27989. */
  27990. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27991. /**
  27992. * Register a function that will be executed before the physics world is stepping forward
  27993. * @param func The function to execute before the physics world is stepped forward
  27994. */
  27995. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27996. /**
  27997. * Unregister a function that will be executed before the physics world is stepping forward
  27998. * @param func The function to execute before the physics world is stepped forward
  27999. */
  28000. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28001. /**
  28002. * Register a function that will be executed after the physics step
  28003. * @param func The function to execute after physics step
  28004. */
  28005. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28006. /**
  28007. * Unregisters a function that will be executed after the physics step
  28008. * @param func The function to execute after physics step
  28009. */
  28010. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28011. /**
  28012. * register a function that will be executed when this impostor collides against a different body
  28013. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28014. * @param func Callback that is executed on collision
  28015. */
  28016. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28017. /**
  28018. * Unregisters the physics imposter on contact
  28019. * @param collideAgainst The physics object to collide against
  28020. * @param func Callback to execute on collision
  28021. */
  28022. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28023. private _tmpQuat;
  28024. private _tmpQuat2;
  28025. /**
  28026. * Get the parent rotation
  28027. * @returns The parent rotation
  28028. */
  28029. getParentsRotation(): Quaternion;
  28030. /**
  28031. * this function is executed by the physics engine.
  28032. */
  28033. beforeStep: () => void;
  28034. /**
  28035. * this function is executed by the physics engine
  28036. */
  28037. afterStep: () => void;
  28038. /**
  28039. * Legacy collision detection event support
  28040. */
  28041. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28042. /**
  28043. * event and body object due to cannon's event-based architecture.
  28044. */
  28045. onCollide: (e: {
  28046. body: any;
  28047. }) => void;
  28048. /**
  28049. * Apply a force
  28050. * @param force The force to apply
  28051. * @param contactPoint The contact point for the force
  28052. * @returns The physics imposter
  28053. */
  28054. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28055. /**
  28056. * Apply an impulse
  28057. * @param force The impulse force
  28058. * @param contactPoint The contact point for the impulse force
  28059. * @returns The physics imposter
  28060. */
  28061. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28062. /**
  28063. * A help function to create a joint
  28064. * @param otherImpostor A physics imposter used to create a joint
  28065. * @param jointType The type of joint
  28066. * @param jointData The data for the joint
  28067. * @returns The physics imposter
  28068. */
  28069. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28070. /**
  28071. * Add a joint to this impostor with a different impostor
  28072. * @param otherImpostor A physics imposter used to add a joint
  28073. * @param joint The joint to add
  28074. * @returns The physics imposter
  28075. */
  28076. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28077. /**
  28078. * Add an anchor to a cloth impostor
  28079. * @param otherImpostor rigid impostor to anchor to
  28080. * @param width ratio across width from 0 to 1
  28081. * @param height ratio up height from 0 to 1
  28082. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28083. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28084. * @returns impostor the soft imposter
  28085. */
  28086. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28087. /**
  28088. * Add a hook to a rope impostor
  28089. * @param otherImpostor rigid impostor to anchor to
  28090. * @param length ratio across rope from 0 to 1
  28091. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28092. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  28093. * @returns impostor the rope imposter
  28094. */
  28095. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28096. /**
  28097. * Will keep this body still, in a sleep mode.
  28098. * @returns the physics imposter
  28099. */
  28100. sleep(): PhysicsImpostor;
  28101. /**
  28102. * Wake the body up.
  28103. * @returns The physics imposter
  28104. */
  28105. wakeUp(): PhysicsImpostor;
  28106. /**
  28107. * Clones the physics imposter
  28108. * @param newObject The physics imposter clones to this physics-enabled object
  28109. * @returns A nullable physics imposter
  28110. */
  28111. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28112. /**
  28113. * Disposes the physics imposter
  28114. */
  28115. dispose(): void;
  28116. /**
  28117. * Sets the delta position
  28118. * @param position The delta position amount
  28119. */
  28120. setDeltaPosition(position: Vector3): void;
  28121. /**
  28122. * Sets the delta rotation
  28123. * @param rotation The delta rotation amount
  28124. */
  28125. setDeltaRotation(rotation: Quaternion): void;
  28126. /**
  28127. * Gets the box size of the physics imposter and stores the result in the input parameter
  28128. * @param result Stores the box size
  28129. * @returns The physics imposter
  28130. */
  28131. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28132. /**
  28133. * Gets the radius of the physics imposter
  28134. * @returns Radius of the physics imposter
  28135. */
  28136. getRadius(): number;
  28137. /**
  28138. * Sync a bone with this impostor
  28139. * @param bone The bone to sync to the impostor.
  28140. * @param boneMesh The mesh that the bone is influencing.
  28141. * @param jointPivot The pivot of the joint / bone in local space.
  28142. * @param distToJoint Optional distance from the impostor to the joint.
  28143. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28144. */
  28145. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28146. /**
  28147. * Sync impostor to a bone
  28148. * @param bone The bone that the impostor will be synced to.
  28149. * @param boneMesh The mesh that the bone is influencing.
  28150. * @param jointPivot The pivot of the joint / bone in local space.
  28151. * @param distToJoint Optional distance from the impostor to the joint.
  28152. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28153. * @param boneAxis Optional vector3 axis the bone is aligned with
  28154. */
  28155. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28156. /**
  28157. * No-Imposter type
  28158. */
  28159. static NoImpostor: number;
  28160. /**
  28161. * Sphere-Imposter type
  28162. */
  28163. static SphereImpostor: number;
  28164. /**
  28165. * Box-Imposter type
  28166. */
  28167. static BoxImpostor: number;
  28168. /**
  28169. * Plane-Imposter type
  28170. */
  28171. static PlaneImpostor: number;
  28172. /**
  28173. * Mesh-imposter type
  28174. */
  28175. static MeshImpostor: number;
  28176. /**
  28177. * Capsule-Impostor type (Ammo.js plugin only)
  28178. */
  28179. static CapsuleImpostor: number;
  28180. /**
  28181. * Cylinder-Imposter type
  28182. */
  28183. static CylinderImpostor: number;
  28184. /**
  28185. * Particle-Imposter type
  28186. */
  28187. static ParticleImpostor: number;
  28188. /**
  28189. * Heightmap-Imposter type
  28190. */
  28191. static HeightmapImpostor: number;
  28192. /**
  28193. * ConvexHull-Impostor type (Ammo.js plugin only)
  28194. */
  28195. static ConvexHullImpostor: number;
  28196. /**
  28197. * Custom-Imposter type (Ammo.js plugin only)
  28198. */
  28199. static CustomImpostor: number;
  28200. /**
  28201. * Rope-Imposter type
  28202. */
  28203. static RopeImpostor: number;
  28204. /**
  28205. * Cloth-Imposter type
  28206. */
  28207. static ClothImpostor: number;
  28208. /**
  28209. * Softbody-Imposter type
  28210. */
  28211. static SoftbodyImpostor: number;
  28212. }
  28213. }
  28214. declare module BABYLON {
  28215. /**
  28216. * @hidden
  28217. **/
  28218. export class _CreationDataStorage {
  28219. closePath?: boolean;
  28220. closeArray?: boolean;
  28221. idx: number[];
  28222. dashSize: number;
  28223. gapSize: number;
  28224. path3D: Path3D;
  28225. pathArray: Vector3[][];
  28226. arc: number;
  28227. radius: number;
  28228. cap: number;
  28229. tessellation: number;
  28230. }
  28231. /**
  28232. * @hidden
  28233. **/
  28234. class _InstanceDataStorage {
  28235. visibleInstances: any;
  28236. batchCache: _InstancesBatch;
  28237. instancesBufferSize: number;
  28238. instancesBuffer: Nullable<Buffer>;
  28239. instancesData: Float32Array;
  28240. overridenInstanceCount: number;
  28241. isFrozen: boolean;
  28242. previousBatch: Nullable<_InstancesBatch>;
  28243. hardwareInstancedRendering: boolean;
  28244. sideOrientation: number;
  28245. manualUpdate: boolean;
  28246. previousRenderId: number;
  28247. }
  28248. /**
  28249. * @hidden
  28250. **/
  28251. export class _InstancesBatch {
  28252. mustReturn: boolean;
  28253. visibleInstances: Nullable<InstancedMesh[]>[];
  28254. renderSelf: boolean[];
  28255. hardwareInstancedRendering: boolean[];
  28256. }
  28257. /**
  28258. * @hidden
  28259. **/
  28260. class _ThinInstanceDataStorage {
  28261. instancesCount: number;
  28262. matrixBuffer: Nullable<Buffer>;
  28263. matrixBufferSize: number;
  28264. matrixData: Nullable<Float32Array>;
  28265. boundingVectors: Array<Vector3>;
  28266. worldMatrices: Nullable<Matrix[]>;
  28267. }
  28268. /**
  28269. * Class used to represent renderable models
  28270. */
  28271. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28272. /**
  28273. * Mesh side orientation : usually the external or front surface
  28274. */
  28275. static readonly FRONTSIDE: number;
  28276. /**
  28277. * Mesh side orientation : usually the internal or back surface
  28278. */
  28279. static readonly BACKSIDE: number;
  28280. /**
  28281. * Mesh side orientation : both internal and external or front and back surfaces
  28282. */
  28283. static readonly DOUBLESIDE: number;
  28284. /**
  28285. * Mesh side orientation : by default, `FRONTSIDE`
  28286. */
  28287. static readonly DEFAULTSIDE: number;
  28288. /**
  28289. * Mesh cap setting : no cap
  28290. */
  28291. static readonly NO_CAP: number;
  28292. /**
  28293. * Mesh cap setting : one cap at the beginning of the mesh
  28294. */
  28295. static readonly CAP_START: number;
  28296. /**
  28297. * Mesh cap setting : one cap at the end of the mesh
  28298. */
  28299. static readonly CAP_END: number;
  28300. /**
  28301. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28302. */
  28303. static readonly CAP_ALL: number;
  28304. /**
  28305. * Mesh pattern setting : no flip or rotate
  28306. */
  28307. static readonly NO_FLIP: number;
  28308. /**
  28309. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28310. */
  28311. static readonly FLIP_TILE: number;
  28312. /**
  28313. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28314. */
  28315. static readonly ROTATE_TILE: number;
  28316. /**
  28317. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28318. */
  28319. static readonly FLIP_ROW: number;
  28320. /**
  28321. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28322. */
  28323. static readonly ROTATE_ROW: number;
  28324. /**
  28325. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28326. */
  28327. static readonly FLIP_N_ROTATE_TILE: number;
  28328. /**
  28329. * Mesh pattern setting : rotate pattern and rotate
  28330. */
  28331. static readonly FLIP_N_ROTATE_ROW: number;
  28332. /**
  28333. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28334. */
  28335. static readonly CENTER: number;
  28336. /**
  28337. * Mesh tile positioning : part tiles on left
  28338. */
  28339. static readonly LEFT: number;
  28340. /**
  28341. * Mesh tile positioning : part tiles on right
  28342. */
  28343. static readonly RIGHT: number;
  28344. /**
  28345. * Mesh tile positioning : part tiles on top
  28346. */
  28347. static readonly TOP: number;
  28348. /**
  28349. * Mesh tile positioning : part tiles on bottom
  28350. */
  28351. static readonly BOTTOM: number;
  28352. /**
  28353. * Gets the default side orientation.
  28354. * @param orientation the orientation to value to attempt to get
  28355. * @returns the default orientation
  28356. * @hidden
  28357. */
  28358. static _GetDefaultSideOrientation(orientation?: number): number;
  28359. private _internalMeshDataInfo;
  28360. get computeBonesUsingShaders(): boolean;
  28361. set computeBonesUsingShaders(value: boolean);
  28362. /**
  28363. * An event triggered before rendering the mesh
  28364. */
  28365. get onBeforeRenderObservable(): Observable<Mesh>;
  28366. /**
  28367. * An event triggered before binding the mesh
  28368. */
  28369. get onBeforeBindObservable(): Observable<Mesh>;
  28370. /**
  28371. * An event triggered after rendering the mesh
  28372. */
  28373. get onAfterRenderObservable(): Observable<Mesh>;
  28374. /**
  28375. * An event triggered before drawing the mesh
  28376. */
  28377. get onBeforeDrawObservable(): Observable<Mesh>;
  28378. private _onBeforeDrawObserver;
  28379. /**
  28380. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28381. */
  28382. set onBeforeDraw(callback: () => void);
  28383. get hasInstances(): boolean;
  28384. get hasThinInstances(): boolean;
  28385. /**
  28386. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28387. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28388. */
  28389. delayLoadState: number;
  28390. /**
  28391. * Gets the list of instances created from this mesh
  28392. * it is not supposed to be modified manually.
  28393. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28394. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28395. */
  28396. instances: InstancedMesh[];
  28397. /**
  28398. * Gets the file containing delay loading data for this mesh
  28399. */
  28400. delayLoadingFile: string;
  28401. /** @hidden */
  28402. _binaryInfo: any;
  28403. /**
  28404. * User defined function used to change how LOD level selection is done
  28405. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28406. */
  28407. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28408. /**
  28409. * Gets or sets the morph target manager
  28410. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28411. */
  28412. get morphTargetManager(): Nullable<MorphTargetManager>;
  28413. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28414. /** @hidden */
  28415. _creationDataStorage: Nullable<_CreationDataStorage>;
  28416. /** @hidden */
  28417. _geometry: Nullable<Geometry>;
  28418. /** @hidden */
  28419. _delayInfo: Array<string>;
  28420. /** @hidden */
  28421. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28422. /** @hidden */
  28423. _instanceDataStorage: _InstanceDataStorage;
  28424. /** @hidden */
  28425. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28426. private _effectiveMaterial;
  28427. /** @hidden */
  28428. _shouldGenerateFlatShading: boolean;
  28429. /** @hidden */
  28430. _originalBuilderSideOrientation: number;
  28431. /**
  28432. * Use this property to change the original side orientation defined at construction time
  28433. */
  28434. overrideMaterialSideOrientation: Nullable<number>;
  28435. /**
  28436. * Gets the source mesh (the one used to clone this one from)
  28437. */
  28438. get source(): Nullable<Mesh>;
  28439. /**
  28440. * Gets the list of clones of this mesh
  28441. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  28442. * Note that useClonedMeshMap=true is the default setting
  28443. */
  28444. get cloneMeshMap(): Nullable<{
  28445. [id: string]: Mesh | undefined;
  28446. }>;
  28447. /**
  28448. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28449. */
  28450. get isUnIndexed(): boolean;
  28451. set isUnIndexed(value: boolean);
  28452. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28453. get worldMatrixInstancedBuffer(): Float32Array;
  28454. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28455. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28456. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28457. /**
  28458. * @constructor
  28459. * @param name The value used by scene.getMeshByName() to do a lookup.
  28460. * @param scene The scene to add this mesh to.
  28461. * @param parent The parent of this mesh, if it has one
  28462. * @param source An optional Mesh from which geometry is shared, cloned.
  28463. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28464. * When false, achieved by calling a clone(), also passing False.
  28465. * This will make creation of children, recursive.
  28466. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28467. */
  28468. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28469. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28470. doNotInstantiate: boolean;
  28471. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28472. /**
  28473. * Gets the class name
  28474. * @returns the string "Mesh".
  28475. */
  28476. getClassName(): string;
  28477. /** @hidden */
  28478. get _isMesh(): boolean;
  28479. /**
  28480. * Returns a description of this mesh
  28481. * @param fullDetails define if full details about this mesh must be used
  28482. * @returns a descriptive string representing this mesh
  28483. */
  28484. toString(fullDetails?: boolean): string;
  28485. /** @hidden */
  28486. _unBindEffect(): void;
  28487. /**
  28488. * Gets a boolean indicating if this mesh has LOD
  28489. */
  28490. get hasLODLevels(): boolean;
  28491. /**
  28492. * Gets the list of MeshLODLevel associated with the current mesh
  28493. * @returns an array of MeshLODLevel
  28494. */
  28495. getLODLevels(): MeshLODLevel[];
  28496. private _sortLODLevels;
  28497. /**
  28498. * Add a mesh as LOD level triggered at the given distance.
  28499. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28500. * @param distance The distance from the center of the object to show this level
  28501. * @param mesh The mesh to be added as LOD level (can be null)
  28502. * @return This mesh (for chaining)
  28503. */
  28504. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28505. /**
  28506. * Returns the LOD level mesh at the passed distance or null if not found.
  28507. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28508. * @param distance The distance from the center of the object to show this level
  28509. * @returns a Mesh or `null`
  28510. */
  28511. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28512. /**
  28513. * Remove a mesh from the LOD array
  28514. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28515. * @param mesh defines the mesh to be removed
  28516. * @return This mesh (for chaining)
  28517. */
  28518. removeLODLevel(mesh: Mesh): Mesh;
  28519. /**
  28520. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28522. * @param camera defines the camera to use to compute distance
  28523. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28524. * @return This mesh (for chaining)
  28525. */
  28526. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28527. /**
  28528. * Gets the mesh internal Geometry object
  28529. */
  28530. get geometry(): Nullable<Geometry>;
  28531. /**
  28532. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28533. * @returns the total number of vertices
  28534. */
  28535. getTotalVertices(): number;
  28536. /**
  28537. * Returns the content of an associated vertex buffer
  28538. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28539. * - VertexBuffer.PositionKind
  28540. * - VertexBuffer.UVKind
  28541. * - VertexBuffer.UV2Kind
  28542. * - VertexBuffer.UV3Kind
  28543. * - VertexBuffer.UV4Kind
  28544. * - VertexBuffer.UV5Kind
  28545. * - VertexBuffer.UV6Kind
  28546. * - VertexBuffer.ColorKind
  28547. * - VertexBuffer.MatricesIndicesKind
  28548. * - VertexBuffer.MatricesIndicesExtraKind
  28549. * - VertexBuffer.MatricesWeightsKind
  28550. * - VertexBuffer.MatricesWeightsExtraKind
  28551. * @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
  28552. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28553. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28554. */
  28555. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28556. /**
  28557. * Returns the mesh VertexBuffer object from the requested `kind`
  28558. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28559. * - VertexBuffer.PositionKind
  28560. * - VertexBuffer.NormalKind
  28561. * - VertexBuffer.UVKind
  28562. * - VertexBuffer.UV2Kind
  28563. * - VertexBuffer.UV3Kind
  28564. * - VertexBuffer.UV4Kind
  28565. * - VertexBuffer.UV5Kind
  28566. * - VertexBuffer.UV6Kind
  28567. * - VertexBuffer.ColorKind
  28568. * - VertexBuffer.MatricesIndicesKind
  28569. * - VertexBuffer.MatricesIndicesExtraKind
  28570. * - VertexBuffer.MatricesWeightsKind
  28571. * - VertexBuffer.MatricesWeightsExtraKind
  28572. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28573. */
  28574. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28575. /**
  28576. * Tests if a specific vertex buffer is associated with this mesh
  28577. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28578. * - VertexBuffer.PositionKind
  28579. * - VertexBuffer.NormalKind
  28580. * - VertexBuffer.UVKind
  28581. * - VertexBuffer.UV2Kind
  28582. * - VertexBuffer.UV3Kind
  28583. * - VertexBuffer.UV4Kind
  28584. * - VertexBuffer.UV5Kind
  28585. * - VertexBuffer.UV6Kind
  28586. * - VertexBuffer.ColorKind
  28587. * - VertexBuffer.MatricesIndicesKind
  28588. * - VertexBuffer.MatricesIndicesExtraKind
  28589. * - VertexBuffer.MatricesWeightsKind
  28590. * - VertexBuffer.MatricesWeightsExtraKind
  28591. * @returns a boolean
  28592. */
  28593. isVerticesDataPresent(kind: string): boolean;
  28594. /**
  28595. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28596. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28597. * - VertexBuffer.PositionKind
  28598. * - VertexBuffer.UVKind
  28599. * - VertexBuffer.UV2Kind
  28600. * - VertexBuffer.UV3Kind
  28601. * - VertexBuffer.UV4Kind
  28602. * - VertexBuffer.UV5Kind
  28603. * - VertexBuffer.UV6Kind
  28604. * - VertexBuffer.ColorKind
  28605. * - VertexBuffer.MatricesIndicesKind
  28606. * - VertexBuffer.MatricesIndicesExtraKind
  28607. * - VertexBuffer.MatricesWeightsKind
  28608. * - VertexBuffer.MatricesWeightsExtraKind
  28609. * @returns a boolean
  28610. */
  28611. isVertexBufferUpdatable(kind: string): boolean;
  28612. /**
  28613. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28614. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28615. * - VertexBuffer.PositionKind
  28616. * - VertexBuffer.NormalKind
  28617. * - VertexBuffer.UVKind
  28618. * - VertexBuffer.UV2Kind
  28619. * - VertexBuffer.UV3Kind
  28620. * - VertexBuffer.UV4Kind
  28621. * - VertexBuffer.UV5Kind
  28622. * - VertexBuffer.UV6Kind
  28623. * - VertexBuffer.ColorKind
  28624. * - VertexBuffer.MatricesIndicesKind
  28625. * - VertexBuffer.MatricesIndicesExtraKind
  28626. * - VertexBuffer.MatricesWeightsKind
  28627. * - VertexBuffer.MatricesWeightsExtraKind
  28628. * @returns an array of strings
  28629. */
  28630. getVerticesDataKinds(): string[];
  28631. /**
  28632. * Returns a positive integer : the total number of indices in this mesh geometry.
  28633. * @returns the numner of indices or zero if the mesh has no geometry.
  28634. */
  28635. getTotalIndices(): number;
  28636. /**
  28637. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28638. * @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.
  28639. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28640. * @returns the indices array or an empty array if the mesh has no geometry
  28641. */
  28642. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28643. get isBlocked(): boolean;
  28644. /**
  28645. * Determine if the current mesh is ready to be rendered
  28646. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28647. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28648. * @returns true if all associated assets are ready (material, textures, shaders)
  28649. */
  28650. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28651. /**
  28652. * 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.
  28653. */
  28654. get areNormalsFrozen(): boolean;
  28655. /**
  28656. * 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.
  28657. * @returns the current mesh
  28658. */
  28659. freezeNormals(): Mesh;
  28660. /**
  28661. * 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
  28662. * @returns the current mesh
  28663. */
  28664. unfreezeNormals(): Mesh;
  28665. /**
  28666. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28667. */
  28668. set overridenInstanceCount(count: number);
  28669. /** @hidden */
  28670. _preActivate(): Mesh;
  28671. /** @hidden */
  28672. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28673. /** @hidden */
  28674. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28675. protected _afterComputeWorldMatrix(): void;
  28676. /** @hidden */
  28677. _postActivate(): void;
  28678. /**
  28679. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28680. * This means the mesh underlying bounding box and sphere are recomputed.
  28681. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28682. * @returns the current mesh
  28683. */
  28684. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28685. /** @hidden */
  28686. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28687. /**
  28688. * This function will subdivide the mesh into multiple submeshes
  28689. * @param count defines the expected number of submeshes
  28690. */
  28691. subdivide(count: number): void;
  28692. /**
  28693. * Copy a FloatArray into a specific associated vertex buffer
  28694. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28695. * - VertexBuffer.PositionKind
  28696. * - VertexBuffer.UVKind
  28697. * - VertexBuffer.UV2Kind
  28698. * - VertexBuffer.UV3Kind
  28699. * - VertexBuffer.UV4Kind
  28700. * - VertexBuffer.UV5Kind
  28701. * - VertexBuffer.UV6Kind
  28702. * - VertexBuffer.ColorKind
  28703. * - VertexBuffer.MatricesIndicesKind
  28704. * - VertexBuffer.MatricesIndicesExtraKind
  28705. * - VertexBuffer.MatricesWeightsKind
  28706. * - VertexBuffer.MatricesWeightsExtraKind
  28707. * @param data defines the data source
  28708. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28709. * @param stride defines the data stride size (can be null)
  28710. * @returns the current mesh
  28711. */
  28712. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28713. /**
  28714. * Delete a vertex buffer associated with this mesh
  28715. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28716. * - VertexBuffer.PositionKind
  28717. * - VertexBuffer.UVKind
  28718. * - VertexBuffer.UV2Kind
  28719. * - VertexBuffer.UV3Kind
  28720. * - VertexBuffer.UV4Kind
  28721. * - VertexBuffer.UV5Kind
  28722. * - VertexBuffer.UV6Kind
  28723. * - VertexBuffer.ColorKind
  28724. * - VertexBuffer.MatricesIndicesKind
  28725. * - VertexBuffer.MatricesIndicesExtraKind
  28726. * - VertexBuffer.MatricesWeightsKind
  28727. * - VertexBuffer.MatricesWeightsExtraKind
  28728. */
  28729. removeVerticesData(kind: string): void;
  28730. /**
  28731. * Flags an associated vertex buffer as updatable
  28732. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28733. * - VertexBuffer.PositionKind
  28734. * - VertexBuffer.UVKind
  28735. * - VertexBuffer.UV2Kind
  28736. * - VertexBuffer.UV3Kind
  28737. * - VertexBuffer.UV4Kind
  28738. * - VertexBuffer.UV5Kind
  28739. * - VertexBuffer.UV6Kind
  28740. * - VertexBuffer.ColorKind
  28741. * - VertexBuffer.MatricesIndicesKind
  28742. * - VertexBuffer.MatricesIndicesExtraKind
  28743. * - VertexBuffer.MatricesWeightsKind
  28744. * - VertexBuffer.MatricesWeightsExtraKind
  28745. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28746. */
  28747. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28748. /**
  28749. * Sets the mesh global Vertex Buffer
  28750. * @param buffer defines the buffer to use
  28751. * @returns the current mesh
  28752. */
  28753. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28754. /**
  28755. * Update a specific associated vertex buffer
  28756. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28757. * - VertexBuffer.PositionKind
  28758. * - VertexBuffer.UVKind
  28759. * - VertexBuffer.UV2Kind
  28760. * - VertexBuffer.UV3Kind
  28761. * - VertexBuffer.UV4Kind
  28762. * - VertexBuffer.UV5Kind
  28763. * - VertexBuffer.UV6Kind
  28764. * - VertexBuffer.ColorKind
  28765. * - VertexBuffer.MatricesIndicesKind
  28766. * - VertexBuffer.MatricesIndicesExtraKind
  28767. * - VertexBuffer.MatricesWeightsKind
  28768. * - VertexBuffer.MatricesWeightsExtraKind
  28769. * @param data defines the data source
  28770. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28771. * @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)
  28772. * @returns the current mesh
  28773. */
  28774. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28775. /**
  28776. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28777. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28778. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28779. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28780. * @returns the current mesh
  28781. */
  28782. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28783. /**
  28784. * Creates a un-shared specific occurence of the geometry for the mesh.
  28785. * @returns the current mesh
  28786. */
  28787. makeGeometryUnique(): Mesh;
  28788. /**
  28789. * Set the index buffer of this mesh
  28790. * @param indices defines the source data
  28791. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28792. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28793. * @returns the current mesh
  28794. */
  28795. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28796. /**
  28797. * Update the current index buffer
  28798. * @param indices defines the source data
  28799. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28800. * @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)
  28801. * @returns the current mesh
  28802. */
  28803. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28804. /**
  28805. * Invert the geometry to move from a right handed system to a left handed one.
  28806. * @returns the current mesh
  28807. */
  28808. toLeftHanded(): Mesh;
  28809. /** @hidden */
  28810. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28811. /** @hidden */
  28812. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28813. /**
  28814. * Registers for this mesh a javascript function called just before the rendering process
  28815. * @param func defines the function to call before rendering this mesh
  28816. * @returns the current mesh
  28817. */
  28818. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28819. /**
  28820. * Disposes a previously registered javascript function called before the rendering
  28821. * @param func defines the function to remove
  28822. * @returns the current mesh
  28823. */
  28824. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28825. /**
  28826. * Registers for this mesh a javascript function called just after the rendering is complete
  28827. * @param func defines the function to call after rendering this mesh
  28828. * @returns the current mesh
  28829. */
  28830. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28831. /**
  28832. * Disposes a previously registered javascript function called after the rendering.
  28833. * @param func defines the function to remove
  28834. * @returns the current mesh
  28835. */
  28836. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28837. /** @hidden */
  28838. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28839. /** @hidden */
  28840. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28841. /** @hidden */
  28842. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28843. /** @hidden */
  28844. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28845. /** @hidden */
  28846. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28847. /** @hidden */
  28848. _rebuild(): void;
  28849. /** @hidden */
  28850. _freeze(): void;
  28851. /** @hidden */
  28852. _unFreeze(): void;
  28853. /**
  28854. * 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
  28855. * @param subMesh defines the subMesh to render
  28856. * @param enableAlphaMode defines if alpha mode can be changed
  28857. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28858. * @returns the current mesh
  28859. */
  28860. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28861. private _onBeforeDraw;
  28862. /**
  28863. * Renormalize the mesh and patch it up if there are no weights
  28864. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28865. * However in the case of zero weights then we set just a single influence to 1.
  28866. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28867. */
  28868. cleanMatrixWeights(): void;
  28869. private normalizeSkinFourWeights;
  28870. private normalizeSkinWeightsAndExtra;
  28871. /**
  28872. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28873. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28874. * the user know there was an issue with importing the mesh
  28875. * @returns a validation object with skinned, valid and report string
  28876. */
  28877. validateSkinning(): {
  28878. skinned: boolean;
  28879. valid: boolean;
  28880. report: string;
  28881. };
  28882. /** @hidden */
  28883. _checkDelayState(): Mesh;
  28884. private _queueLoad;
  28885. /**
  28886. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28887. * A mesh is in the frustum if its bounding box intersects the frustum
  28888. * @param frustumPlanes defines the frustum to test
  28889. * @returns true if the mesh is in the frustum planes
  28890. */
  28891. isInFrustum(frustumPlanes: Plane[]): boolean;
  28892. /**
  28893. * Sets the mesh material by the material or multiMaterial `id` property
  28894. * @param id is a string identifying the material or the multiMaterial
  28895. * @returns the current mesh
  28896. */
  28897. setMaterialByID(id: string): Mesh;
  28898. /**
  28899. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28900. * @returns an array of IAnimatable
  28901. */
  28902. getAnimatables(): IAnimatable[];
  28903. /**
  28904. * Modifies the mesh geometry according to the passed transformation matrix.
  28905. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28906. * The mesh normals are modified using the same transformation.
  28907. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28908. * @param transform defines the transform matrix to use
  28909. * @see https://doc.babylonjs.com/resources/baking_transformations
  28910. * @returns the current mesh
  28911. */
  28912. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28913. /**
  28914. * Modifies the mesh geometry according to its own current World Matrix.
  28915. * The mesh World Matrix is then reset.
  28916. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28917. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28918. * @see https://doc.babylonjs.com/resources/baking_transformations
  28919. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28920. * @returns the current mesh
  28921. */
  28922. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28923. /** @hidden */
  28924. get _positions(): Nullable<Vector3[]>;
  28925. /** @hidden */
  28926. _resetPointsArrayCache(): Mesh;
  28927. /** @hidden */
  28928. _generatePointsArray(): boolean;
  28929. /**
  28930. * Returns a new Mesh object generated from the current mesh properties.
  28931. * This method must not get confused with createInstance()
  28932. * @param name is a string, the name given to the new mesh
  28933. * @param newParent can be any Node object (default `null`)
  28934. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28935. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28936. * @returns a new mesh
  28937. */
  28938. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28939. /**
  28940. * Releases resources associated with this mesh.
  28941. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28942. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28943. */
  28944. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28945. /** @hidden */
  28946. _disposeInstanceSpecificData(): void;
  28947. /** @hidden */
  28948. _disposeThinInstanceSpecificData(): void;
  28949. /**
  28950. * Modifies the mesh geometry according to a displacement map.
  28951. * 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.
  28952. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28953. * @param url is a string, the URL from the image file is to be downloaded.
  28954. * @param minHeight is the lower limit of the displacement.
  28955. * @param maxHeight is the upper limit of the displacement.
  28956. * @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.
  28957. * @param uvOffset is an optional vector2 used to offset UV.
  28958. * @param uvScale is an optional vector2 used to scale UV.
  28959. * @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.
  28960. * @returns the Mesh.
  28961. */
  28962. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28963. /**
  28964. * Modifies the mesh geometry according to a displacementMap buffer.
  28965. * 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.
  28966. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28967. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28968. * @param heightMapWidth is the width of the buffer image.
  28969. * @param heightMapHeight is the height of the buffer image.
  28970. * @param minHeight is the lower limit of the displacement.
  28971. * @param maxHeight is the upper limit of the displacement.
  28972. * @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.
  28973. * @param uvOffset is an optional vector2 used to offset UV.
  28974. * @param uvScale is an optional vector2 used to scale UV.
  28975. * @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.
  28976. * @returns the Mesh.
  28977. */
  28978. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28979. /**
  28980. * Modify the mesh to get a flat shading rendering.
  28981. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28982. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28983. * @returns current mesh
  28984. */
  28985. convertToFlatShadedMesh(): Mesh;
  28986. /**
  28987. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28988. * In other words, more vertices, no more indices and a single bigger VBO.
  28989. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28990. * @returns current mesh
  28991. */
  28992. convertToUnIndexedMesh(): Mesh;
  28993. /**
  28994. * Inverses facet orientations.
  28995. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28996. * @param flipNormals will also inverts the normals
  28997. * @returns current mesh
  28998. */
  28999. flipFaces(flipNormals?: boolean): Mesh;
  29000. /**
  29001. * Increase the number of facets and hence vertices in a mesh
  29002. * Vertex normals are interpolated from existing vertex normals
  29003. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29004. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29005. */
  29006. increaseVertices(numberPerEdge: number): void;
  29007. /**
  29008. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29009. * This will undo any application of covertToFlatShadedMesh
  29010. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29011. */
  29012. forceSharedVertices(): void;
  29013. /** @hidden */
  29014. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29015. /** @hidden */
  29016. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29017. /**
  29018. * Creates a new InstancedMesh object from the mesh model.
  29019. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29020. * @param name defines the name of the new instance
  29021. * @returns a new InstancedMesh
  29022. */
  29023. createInstance(name: string): InstancedMesh;
  29024. /**
  29025. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29026. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29027. * @returns the current mesh
  29028. */
  29029. synchronizeInstances(): Mesh;
  29030. /**
  29031. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29032. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29033. * This should be used together with the simplification to avoid disappearing triangles.
  29034. * @param successCallback an optional success callback to be called after the optimization finished.
  29035. * @returns the current mesh
  29036. */
  29037. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29038. /**
  29039. * Serialize current mesh
  29040. * @param serializationObject defines the object which will receive the serialization data
  29041. */
  29042. serialize(serializationObject: any): void;
  29043. /** @hidden */
  29044. _syncGeometryWithMorphTargetManager(): void;
  29045. /** @hidden */
  29046. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29047. /**
  29048. * Returns a new Mesh object parsed from the source provided.
  29049. * @param parsedMesh is the source
  29050. * @param scene defines the hosting scene
  29051. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29052. * @returns a new Mesh
  29053. */
  29054. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29055. /**
  29056. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29057. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29058. * @param name defines the name of the mesh to create
  29059. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29060. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29061. * @param closePath creates a seam between the first and the last points of each path of the path array
  29062. * @param offset is taken in account only if the `pathArray` is containing a single path
  29063. * @param scene defines the hosting scene
  29064. * @param updatable defines if the mesh must be flagged as updatable
  29065. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29066. * @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)
  29067. * @returns a new Mesh
  29068. */
  29069. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29070. /**
  29071. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  29072. * @param name defines the name of the mesh to create
  29073. * @param radius sets the radius size (float) of the polygon (default 0.5)
  29074. * @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
  29075. * @param scene defines the hosting scene
  29076. * @param updatable defines if the mesh must be flagged as updatable
  29077. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29078. * @returns a new Mesh
  29079. */
  29080. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29081. /**
  29082. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  29083. * @param name defines the name of the mesh to create
  29084. * @param size sets the size (float) of each box side (default 1)
  29085. * @param scene defines the hosting scene
  29086. * @param updatable defines if the mesh must be flagged as updatable
  29087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29088. * @returns a new Mesh
  29089. */
  29090. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29091. /**
  29092. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29093. * @param name defines the name of the mesh to create
  29094. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29095. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29096. * @param scene defines the hosting scene
  29097. * @param updatable defines if the mesh must be flagged as updatable
  29098. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29099. * @returns a new Mesh
  29100. */
  29101. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29102. /**
  29103. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29104. * @param name defines the name of the mesh to create
  29105. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29106. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29107. * @param scene defines the hosting scene
  29108. * @returns a new Mesh
  29109. */
  29110. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29111. /**
  29112. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29113. * @param name defines the name of the mesh to create
  29114. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29115. * @param diameterTop set the top cap diameter (floats, default 1)
  29116. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29117. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29118. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29119. * @param scene defines the hosting scene
  29120. * @param updatable defines if the mesh must be flagged as updatable
  29121. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29122. * @returns a new Mesh
  29123. */
  29124. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29125. /**
  29126. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29127. * @param name defines the name of the mesh to create
  29128. * @param diameter sets the diameter size (float) of the torus (default 1)
  29129. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29130. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29131. * @param scene defines the hosting scene
  29132. * @param updatable defines if the mesh must be flagged as updatable
  29133. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29134. * @returns a new Mesh
  29135. */
  29136. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29137. /**
  29138. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29139. * @param name defines the name of the mesh to create
  29140. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29141. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29142. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29143. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29144. * @param p the number of windings on X axis (positive integers, default 2)
  29145. * @param q the number of windings on Y axis (positive integers, default 3)
  29146. * @param scene defines the hosting scene
  29147. * @param updatable defines if the mesh must be flagged as updatable
  29148. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29149. * @returns a new Mesh
  29150. */
  29151. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29152. /**
  29153. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29154. * @param name defines the name of the mesh to create
  29155. * @param points is an array successive Vector3
  29156. * @param scene defines the hosting scene
  29157. * @param updatable defines if the mesh must be flagged as updatable
  29158. * @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).
  29159. * @returns a new Mesh
  29160. */
  29161. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29162. /**
  29163. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29164. * @param name defines the name of the mesh to create
  29165. * @param points is an array successive Vector3
  29166. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29167. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29168. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29169. * @param scene defines the hosting scene
  29170. * @param updatable defines if the mesh must be flagged as updatable
  29171. * @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)
  29172. * @returns a new Mesh
  29173. */
  29174. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29175. /**
  29176. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29177. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29178. * 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.
  29179. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29180. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29181. * Remember you can only change the shape positions, not their number when updating a polygon.
  29182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29183. * @param name defines the name of the mesh to create
  29184. * @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
  29185. * @param scene defines the hosting scene
  29186. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29187. * @param updatable defines if the mesh must be flagged as updatable
  29188. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29189. * @param earcutInjection can be used to inject your own earcut reference
  29190. * @returns a new Mesh
  29191. */
  29192. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29193. /**
  29194. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29195. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29196. * @param name defines the name of the mesh to create
  29197. * @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
  29198. * @param depth defines the height of extrusion
  29199. * @param scene defines the hosting scene
  29200. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29201. * @param updatable defines if the mesh must be flagged as updatable
  29202. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29203. * @param earcutInjection can be used to inject your own earcut reference
  29204. * @returns a new Mesh
  29205. */
  29206. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29207. /**
  29208. * Creates an extruded shape mesh.
  29209. * 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
  29210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29211. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29212. * @param name defines the name of the mesh to create
  29213. * @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
  29214. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29215. * @param scale is the value to scale the shape
  29216. * @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
  29217. * @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
  29218. * @param scene defines the hosting scene
  29219. * @param updatable defines if the mesh must be flagged as updatable
  29220. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29221. * @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)
  29222. * @returns a new Mesh
  29223. */
  29224. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29225. /**
  29226. * Creates an custom extruded shape mesh.
  29227. * The custom extrusion is a parametric shape.
  29228. * It has no predefined shape. Its final shape will depend on the input parameters.
  29229. * Please consider using the same method from the MeshBuilder class instead
  29230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29231. * @param name defines the name of the mesh to create
  29232. * @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
  29233. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29234. * @param scaleFunction is a custom Javascript function called on each path point
  29235. * @param rotationFunction is a custom Javascript function called on each path point
  29236. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29237. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29238. * @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
  29239. * @param scene defines the hosting scene
  29240. * @param updatable defines if the mesh must be flagged as updatable
  29241. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29242. * @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)
  29243. * @returns a new Mesh
  29244. */
  29245. 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;
  29246. /**
  29247. * Creates lathe mesh.
  29248. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29249. * Please consider using the same method from the MeshBuilder class instead
  29250. * @param name defines the name of the mesh to create
  29251. * @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
  29252. * @param radius is the radius value of the lathe
  29253. * @param tessellation is the side number of the lathe.
  29254. * @param scene defines the hosting scene
  29255. * @param updatable defines if the mesh must be flagged as updatable
  29256. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29257. * @returns a new Mesh
  29258. */
  29259. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29260. /**
  29261. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29262. * @param name defines the name of the mesh to create
  29263. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29264. * @param scene defines the hosting scene
  29265. * @param updatable defines if the mesh must be flagged as updatable
  29266. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29267. * @returns a new Mesh
  29268. */
  29269. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29270. /**
  29271. * Creates a ground mesh.
  29272. * Please consider using the same method from the MeshBuilder class instead
  29273. * @param name defines the name of the mesh to create
  29274. * @param width set the width of the ground
  29275. * @param height set the height of the ground
  29276. * @param subdivisions sets the number of subdivisions per side
  29277. * @param scene defines the hosting scene
  29278. * @param updatable defines if the mesh must be flagged as updatable
  29279. * @returns a new Mesh
  29280. */
  29281. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29282. /**
  29283. * Creates a tiled ground mesh.
  29284. * Please consider using the same method from the MeshBuilder class instead
  29285. * @param name defines the name of the mesh to create
  29286. * @param xmin set the ground minimum X coordinate
  29287. * @param zmin set the ground minimum Y coordinate
  29288. * @param xmax set the ground maximum X coordinate
  29289. * @param zmax set the ground maximum Z coordinate
  29290. * @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
  29291. * @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
  29292. * @param scene defines the hosting scene
  29293. * @param updatable defines if the mesh must be flagged as updatable
  29294. * @returns a new Mesh
  29295. */
  29296. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29297. w: number;
  29298. h: number;
  29299. }, precision: {
  29300. w: number;
  29301. h: number;
  29302. }, scene: Scene, updatable?: boolean): Mesh;
  29303. /**
  29304. * Creates a ground mesh from a height map.
  29305. * Please consider using the same method from the MeshBuilder class instead
  29306. * @see https://doc.babylonjs.com/babylon101/height_map
  29307. * @param name defines the name of the mesh to create
  29308. * @param url sets the URL of the height map image resource
  29309. * @param width set the ground width size
  29310. * @param height set the ground height size
  29311. * @param subdivisions sets the number of subdivision per side
  29312. * @param minHeight is the minimum altitude on the ground
  29313. * @param maxHeight is the maximum altitude on the ground
  29314. * @param scene defines the hosting scene
  29315. * @param updatable defines if the mesh must be flagged as updatable
  29316. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29317. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29318. * @returns a new Mesh
  29319. */
  29320. 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;
  29321. /**
  29322. * Creates a tube mesh.
  29323. * The tube is a parametric shape.
  29324. * It has no predefined shape. Its final shape will depend on the input parameters.
  29325. * Please consider using the same method from the MeshBuilder class instead
  29326. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29327. * @param name defines the name of the mesh to create
  29328. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29329. * @param radius sets the tube radius size
  29330. * @param tessellation is the number of sides on the tubular surface
  29331. * @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
  29332. * @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
  29333. * @param scene defines the hosting scene
  29334. * @param updatable defines if the mesh must be flagged as updatable
  29335. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29336. * @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)
  29337. * @returns a new Mesh
  29338. */
  29339. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29340. (i: number, distance: number): number;
  29341. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29342. /**
  29343. * Creates a polyhedron mesh.
  29344. * Please consider using the same method from the MeshBuilder class instead.
  29345. * * 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
  29346. * * The parameter `size` (positive float, default 1) sets the polygon size
  29347. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29348. * * 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`
  29349. * * 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
  29350. * * 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)`)
  29351. * * 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
  29352. * * 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
  29353. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29354. * * 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
  29355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29356. * @param name defines the name of the mesh to create
  29357. * @param options defines the options used to create the mesh
  29358. * @param scene defines the hosting scene
  29359. * @returns a new Mesh
  29360. */
  29361. static CreatePolyhedron(name: string, options: {
  29362. type?: number;
  29363. size?: number;
  29364. sizeX?: number;
  29365. sizeY?: number;
  29366. sizeZ?: number;
  29367. custom?: any;
  29368. faceUV?: Vector4[];
  29369. faceColors?: Color4[];
  29370. updatable?: boolean;
  29371. sideOrientation?: number;
  29372. }, scene: Scene): Mesh;
  29373. /**
  29374. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29375. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29376. * * 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`)
  29377. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29378. * * 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
  29379. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29380. * * 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
  29381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29382. * @param name defines the name of the mesh
  29383. * @param options defines the options used to create the mesh
  29384. * @param scene defines the hosting scene
  29385. * @returns a new Mesh
  29386. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29387. */
  29388. static CreateIcoSphere(name: string, options: {
  29389. radius?: number;
  29390. flat?: boolean;
  29391. subdivisions?: number;
  29392. sideOrientation?: number;
  29393. updatable?: boolean;
  29394. }, scene: Scene): Mesh;
  29395. /**
  29396. * Creates a decal mesh.
  29397. * Please consider using the same method from the MeshBuilder class instead.
  29398. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29399. * @param name defines the name of the mesh
  29400. * @param sourceMesh defines the mesh receiving the decal
  29401. * @param position sets the position of the decal in world coordinates
  29402. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29403. * @param size sets the decal scaling
  29404. * @param angle sets the angle to rotate the decal
  29405. * @returns a new Mesh
  29406. */
  29407. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29408. /** Creates a Capsule Mesh
  29409. * @param name defines the name of the mesh.
  29410. * @param options the constructors options used to shape the mesh.
  29411. * @param scene defines the scene the mesh is scoped to.
  29412. * @returns the capsule mesh
  29413. * @see https://doc.babylonjs.com/how_to/capsule_shape
  29414. */
  29415. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  29416. /**
  29417. * Prepare internal position array for software CPU skinning
  29418. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29419. */
  29420. setPositionsForCPUSkinning(): Float32Array;
  29421. /**
  29422. * Prepare internal normal array for software CPU skinning
  29423. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29424. */
  29425. setNormalsForCPUSkinning(): Float32Array;
  29426. /**
  29427. * Updates the vertex buffer by applying transformation from the bones
  29428. * @param skeleton defines the skeleton to apply to current mesh
  29429. * @returns the current mesh
  29430. */
  29431. applySkeleton(skeleton: Skeleton): Mesh;
  29432. /**
  29433. * 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
  29434. * @param meshes defines the list of meshes to scan
  29435. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29436. */
  29437. static MinMax(meshes: AbstractMesh[]): {
  29438. min: Vector3;
  29439. max: Vector3;
  29440. };
  29441. /**
  29442. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29443. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29444. * @returns a vector3
  29445. */
  29446. static Center(meshesOrMinMaxVector: {
  29447. min: Vector3;
  29448. max: Vector3;
  29449. } | AbstractMesh[]): Vector3;
  29450. /**
  29451. * Merge the array of meshes into a single mesh for performance reasons.
  29452. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29453. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29454. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29455. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29456. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29457. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29458. * @returns a new mesh
  29459. */
  29460. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29461. /** @hidden */
  29462. addInstance(instance: InstancedMesh): void;
  29463. /** @hidden */
  29464. removeInstance(instance: InstancedMesh): void;
  29465. }
  29466. }
  29467. declare module BABYLON {
  29468. /**
  29469. * This is the base class of all the camera used in the application.
  29470. * @see https://doc.babylonjs.com/features/cameras
  29471. */
  29472. export class Camera extends Node {
  29473. /** @hidden */
  29474. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29475. /**
  29476. * This is the default projection mode used by the cameras.
  29477. * It helps recreating a feeling of perspective and better appreciate depth.
  29478. * This is the best way to simulate real life cameras.
  29479. */
  29480. static readonly PERSPECTIVE_CAMERA: number;
  29481. /**
  29482. * This helps creating camera with an orthographic mode.
  29483. * 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.
  29484. */
  29485. static readonly ORTHOGRAPHIC_CAMERA: number;
  29486. /**
  29487. * This is the default FOV mode for perspective cameras.
  29488. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29489. */
  29490. static readonly FOVMODE_VERTICAL_FIXED: number;
  29491. /**
  29492. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29493. */
  29494. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29495. /**
  29496. * This specifies ther is no need for a camera rig.
  29497. * Basically only one eye is rendered corresponding to the camera.
  29498. */
  29499. static readonly RIG_MODE_NONE: number;
  29500. /**
  29501. * Simulates a camera Rig with one blue eye and one red eye.
  29502. * This can be use with 3d blue and red glasses.
  29503. */
  29504. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29505. /**
  29506. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29507. */
  29508. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29509. /**
  29510. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29511. */
  29512. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29513. /**
  29514. * Defines that both eyes of the camera will be rendered over under each other.
  29515. */
  29516. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29517. /**
  29518. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29519. */
  29520. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29521. /**
  29522. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29523. */
  29524. static readonly RIG_MODE_VR: number;
  29525. /**
  29526. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29527. */
  29528. static readonly RIG_MODE_WEBVR: number;
  29529. /**
  29530. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29531. */
  29532. static readonly RIG_MODE_CUSTOM: number;
  29533. /**
  29534. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29535. */
  29536. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29537. /**
  29538. * Define the input manager associated with the camera.
  29539. */
  29540. inputs: CameraInputsManager<Camera>;
  29541. /** @hidden */
  29542. _position: Vector3;
  29543. /**
  29544. * Define the current local position of the camera in the scene
  29545. */
  29546. get position(): Vector3;
  29547. set position(newPosition: Vector3);
  29548. protected _upVector: Vector3;
  29549. /**
  29550. * The vector the camera should consider as up.
  29551. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29552. */
  29553. set upVector(vec: Vector3);
  29554. get upVector(): Vector3;
  29555. /**
  29556. * Define the current limit on the left side for an orthographic camera
  29557. * In scene unit
  29558. */
  29559. orthoLeft: Nullable<number>;
  29560. /**
  29561. * Define the current limit on the right side for an orthographic camera
  29562. * In scene unit
  29563. */
  29564. orthoRight: Nullable<number>;
  29565. /**
  29566. * Define the current limit on the bottom side for an orthographic camera
  29567. * In scene unit
  29568. */
  29569. orthoBottom: Nullable<number>;
  29570. /**
  29571. * Define the current limit on the top side for an orthographic camera
  29572. * In scene unit
  29573. */
  29574. orthoTop: Nullable<number>;
  29575. /**
  29576. * Field Of View is set in Radians. (default is 0.8)
  29577. */
  29578. fov: number;
  29579. /**
  29580. * Define the minimum distance the camera can see from.
  29581. * This is important to note that the depth buffer are not infinite and the closer it starts
  29582. * the more your scene might encounter depth fighting issue.
  29583. */
  29584. minZ: number;
  29585. /**
  29586. * Define the maximum distance the camera can see to.
  29587. * This is important to note that the depth buffer are not infinite and the further it end
  29588. * the more your scene might encounter depth fighting issue.
  29589. */
  29590. maxZ: number;
  29591. /**
  29592. * Define the default inertia of the camera.
  29593. * This helps giving a smooth feeling to the camera movement.
  29594. */
  29595. inertia: number;
  29596. /**
  29597. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29598. */
  29599. mode: number;
  29600. /**
  29601. * Define whether the camera is intermediate.
  29602. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29603. */
  29604. isIntermediate: boolean;
  29605. /**
  29606. * Define the viewport of the camera.
  29607. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29608. */
  29609. viewport: Viewport;
  29610. /**
  29611. * Restricts the camera to viewing objects with the same layerMask.
  29612. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29613. */
  29614. layerMask: number;
  29615. /**
  29616. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29617. */
  29618. fovMode: number;
  29619. /**
  29620. * Rig mode of the camera.
  29621. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29622. * This is normally controlled byt the camera themselves as internal use.
  29623. */
  29624. cameraRigMode: number;
  29625. /**
  29626. * Defines the distance between both "eyes" in case of a RIG
  29627. */
  29628. interaxialDistance: number;
  29629. /**
  29630. * Defines if stereoscopic rendering is done side by side or over under.
  29631. */
  29632. isStereoscopicSideBySide: boolean;
  29633. /**
  29634. * 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
  29635. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29636. * else in the scene. (Eg. security camera)
  29637. *
  29638. * 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)
  29639. */
  29640. customRenderTargets: RenderTargetTexture[];
  29641. /**
  29642. * When set, the camera will render to this render target instead of the default canvas
  29643. *
  29644. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29645. */
  29646. outputRenderTarget: Nullable<RenderTargetTexture>;
  29647. /**
  29648. * Observable triggered when the camera view matrix has changed.
  29649. */
  29650. onViewMatrixChangedObservable: Observable<Camera>;
  29651. /**
  29652. * Observable triggered when the camera Projection matrix has changed.
  29653. */
  29654. onProjectionMatrixChangedObservable: Observable<Camera>;
  29655. /**
  29656. * Observable triggered when the inputs have been processed.
  29657. */
  29658. onAfterCheckInputsObservable: Observable<Camera>;
  29659. /**
  29660. * Observable triggered when reset has been called and applied to the camera.
  29661. */
  29662. onRestoreStateObservable: Observable<Camera>;
  29663. /**
  29664. * Is this camera a part of a rig system?
  29665. */
  29666. isRigCamera: boolean;
  29667. /**
  29668. * If isRigCamera set to true this will be set with the parent camera.
  29669. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29670. */
  29671. rigParent?: Camera;
  29672. /** @hidden */
  29673. _cameraRigParams: any;
  29674. /** @hidden */
  29675. _rigCameras: Camera[];
  29676. /** @hidden */
  29677. _rigPostProcess: Nullable<PostProcess>;
  29678. protected _webvrViewMatrix: Matrix;
  29679. /** @hidden */
  29680. _skipRendering: boolean;
  29681. /** @hidden */
  29682. _projectionMatrix: Matrix;
  29683. /** @hidden */
  29684. _postProcesses: Nullable<PostProcess>[];
  29685. /** @hidden */
  29686. _activeMeshes: SmartArray<AbstractMesh>;
  29687. protected _globalPosition: Vector3;
  29688. /** @hidden */
  29689. _computedViewMatrix: Matrix;
  29690. private _doNotComputeProjectionMatrix;
  29691. private _transformMatrix;
  29692. private _frustumPlanes;
  29693. private _refreshFrustumPlanes;
  29694. private _storedFov;
  29695. private _stateStored;
  29696. /**
  29697. * Instantiates a new camera object.
  29698. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29699. * @see https://doc.babylonjs.com/features/cameras
  29700. * @param name Defines the name of the camera in the scene
  29701. * @param position Defines the position of the camera
  29702. * @param scene Defines the scene the camera belongs too
  29703. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29704. */
  29705. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29706. /**
  29707. * Store current camera state (fov, position, etc..)
  29708. * @returns the camera
  29709. */
  29710. storeState(): Camera;
  29711. /**
  29712. * Restores the camera state values if it has been stored. You must call storeState() first
  29713. */
  29714. protected _restoreStateValues(): boolean;
  29715. /**
  29716. * Restored camera state. You must call storeState() first.
  29717. * @returns true if restored and false otherwise
  29718. */
  29719. restoreState(): boolean;
  29720. /**
  29721. * Gets the class name of the camera.
  29722. * @returns the class name
  29723. */
  29724. getClassName(): string;
  29725. /** @hidden */
  29726. readonly _isCamera: boolean;
  29727. /**
  29728. * Gets a string representation of the camera useful for debug purpose.
  29729. * @param fullDetails Defines that a more verboe level of logging is required
  29730. * @returns the string representation
  29731. */
  29732. toString(fullDetails?: boolean): string;
  29733. /**
  29734. * Gets the current world space position of the camera.
  29735. */
  29736. get globalPosition(): Vector3;
  29737. /**
  29738. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29739. * @returns the active meshe list
  29740. */
  29741. getActiveMeshes(): SmartArray<AbstractMesh>;
  29742. /**
  29743. * Check whether a mesh is part of the current active mesh list of the camera
  29744. * @param mesh Defines the mesh to check
  29745. * @returns true if active, false otherwise
  29746. */
  29747. isActiveMesh(mesh: Mesh): boolean;
  29748. /**
  29749. * Is this camera ready to be used/rendered
  29750. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29751. * @return true if the camera is ready
  29752. */
  29753. isReady(completeCheck?: boolean): boolean;
  29754. /** @hidden */
  29755. _initCache(): void;
  29756. /** @hidden */
  29757. _updateCache(ignoreParentClass?: boolean): void;
  29758. /** @hidden */
  29759. _isSynchronized(): boolean;
  29760. /** @hidden */
  29761. _isSynchronizedViewMatrix(): boolean;
  29762. /** @hidden */
  29763. _isSynchronizedProjectionMatrix(): boolean;
  29764. /**
  29765. * Attach the input controls to a specific dom element to get the input from.
  29766. * @param element Defines the element the controls should be listened from
  29767. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29768. */
  29769. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29770. /**
  29771. * Detach the current controls from the specified dom element.
  29772. * @param element Defines the element to stop listening the inputs from
  29773. */
  29774. detachControl(element: HTMLElement): void;
  29775. /**
  29776. * Update the camera state according to the different inputs gathered during the frame.
  29777. */
  29778. update(): void;
  29779. /** @hidden */
  29780. _checkInputs(): void;
  29781. /** @hidden */
  29782. get rigCameras(): Camera[];
  29783. /**
  29784. * Gets the post process used by the rig cameras
  29785. */
  29786. get rigPostProcess(): Nullable<PostProcess>;
  29787. /**
  29788. * Internal, gets the first post proces.
  29789. * @returns the first post process to be run on this camera.
  29790. */
  29791. _getFirstPostProcess(): Nullable<PostProcess>;
  29792. private _cascadePostProcessesToRigCams;
  29793. /**
  29794. * Attach a post process to the camera.
  29795. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29796. * @param postProcess The post process to attach to the camera
  29797. * @param insertAt The position of the post process in case several of them are in use in the scene
  29798. * @returns the position the post process has been inserted at
  29799. */
  29800. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29801. /**
  29802. * Detach a post process to the camera.
  29803. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29804. * @param postProcess The post process to detach from the camera
  29805. */
  29806. detachPostProcess(postProcess: PostProcess): void;
  29807. /**
  29808. * Gets the current world matrix of the camera
  29809. */
  29810. getWorldMatrix(): Matrix;
  29811. /** @hidden */
  29812. _getViewMatrix(): Matrix;
  29813. /**
  29814. * Gets the current view matrix of the camera.
  29815. * @param force forces the camera to recompute the matrix without looking at the cached state
  29816. * @returns the view matrix
  29817. */
  29818. getViewMatrix(force?: boolean): Matrix;
  29819. /**
  29820. * Freeze the projection matrix.
  29821. * It will prevent the cache check of the camera projection compute and can speed up perf
  29822. * if no parameter of the camera are meant to change
  29823. * @param projection Defines manually a projection if necessary
  29824. */
  29825. freezeProjectionMatrix(projection?: Matrix): void;
  29826. /**
  29827. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29828. */
  29829. unfreezeProjectionMatrix(): void;
  29830. /**
  29831. * Gets the current projection matrix of the camera.
  29832. * @param force forces the camera to recompute the matrix without looking at the cached state
  29833. * @returns the projection matrix
  29834. */
  29835. getProjectionMatrix(force?: boolean): Matrix;
  29836. /**
  29837. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29838. * @returns a Matrix
  29839. */
  29840. getTransformationMatrix(): Matrix;
  29841. private _updateFrustumPlanes;
  29842. /**
  29843. * Checks if a cullable object (mesh...) is in the camera frustum
  29844. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29845. * @param target The object to check
  29846. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29847. * @returns true if the object is in frustum otherwise false
  29848. */
  29849. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29850. /**
  29851. * Checks if a cullable object (mesh...) is in the camera frustum
  29852. * Unlike isInFrustum this cheks the full bounding box
  29853. * @param target The object to check
  29854. * @returns true if the object is in frustum otherwise false
  29855. */
  29856. isCompletelyInFrustum(target: ICullable): boolean;
  29857. /**
  29858. * Gets a ray in the forward direction from the camera.
  29859. * @param length Defines the length of the ray to create
  29860. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29861. * @param origin Defines the start point of the ray which defaults to the camera position
  29862. * @returns the forward ray
  29863. */
  29864. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29865. /**
  29866. * Gets a ray in the forward direction from the camera.
  29867. * @param refRay the ray to (re)use when setting the values
  29868. * @param length Defines the length of the ray to create
  29869. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29870. * @param origin Defines the start point of the ray which defaults to the camera position
  29871. * @returns the forward ray
  29872. */
  29873. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29874. /**
  29875. * Releases resources associated with this node.
  29876. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29877. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29878. */
  29879. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29880. /** @hidden */
  29881. _isLeftCamera: boolean;
  29882. /**
  29883. * Gets the left camera of a rig setup in case of Rigged Camera
  29884. */
  29885. get isLeftCamera(): boolean;
  29886. /** @hidden */
  29887. _isRightCamera: boolean;
  29888. /**
  29889. * Gets the right camera of a rig setup in case of Rigged Camera
  29890. */
  29891. get isRightCamera(): boolean;
  29892. /**
  29893. * Gets the left camera of a rig setup in case of Rigged Camera
  29894. */
  29895. get leftCamera(): Nullable<FreeCamera>;
  29896. /**
  29897. * Gets the right camera of a rig setup in case of Rigged Camera
  29898. */
  29899. get rightCamera(): Nullable<FreeCamera>;
  29900. /**
  29901. * Gets the left camera target of a rig setup in case of Rigged Camera
  29902. * @returns the target position
  29903. */
  29904. getLeftTarget(): Nullable<Vector3>;
  29905. /**
  29906. * Gets the right camera target of a rig setup in case of Rigged Camera
  29907. * @returns the target position
  29908. */
  29909. getRightTarget(): Nullable<Vector3>;
  29910. /**
  29911. * @hidden
  29912. */
  29913. setCameraRigMode(mode: number, rigParams: any): void;
  29914. /** @hidden */
  29915. static _setStereoscopicRigMode(camera: Camera): void;
  29916. /** @hidden */
  29917. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29918. /** @hidden */
  29919. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29920. /** @hidden */
  29921. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29922. /** @hidden */
  29923. _getVRProjectionMatrix(): Matrix;
  29924. protected _updateCameraRotationMatrix(): void;
  29925. protected _updateWebVRCameraRotationMatrix(): void;
  29926. /**
  29927. * This function MUST be overwritten by the different WebVR cameras available.
  29928. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29929. * @hidden
  29930. */
  29931. _getWebVRProjectionMatrix(): Matrix;
  29932. /**
  29933. * This function MUST be overwritten by the different WebVR cameras available.
  29934. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29935. * @hidden
  29936. */
  29937. _getWebVRViewMatrix(): Matrix;
  29938. /** @hidden */
  29939. setCameraRigParameter(name: string, value: any): void;
  29940. /**
  29941. * needs to be overridden by children so sub has required properties to be copied
  29942. * @hidden
  29943. */
  29944. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29945. /**
  29946. * May need to be overridden by children
  29947. * @hidden
  29948. */
  29949. _updateRigCameras(): void;
  29950. /** @hidden */
  29951. _setupInputs(): void;
  29952. /**
  29953. * Serialiaze the camera setup to a json represention
  29954. * @returns the JSON representation
  29955. */
  29956. serialize(): any;
  29957. /**
  29958. * Clones the current camera.
  29959. * @param name The cloned camera name
  29960. * @returns the cloned camera
  29961. */
  29962. clone(name: string): Camera;
  29963. /**
  29964. * Gets the direction of the camera relative to a given local axis.
  29965. * @param localAxis Defines the reference axis to provide a relative direction.
  29966. * @return the direction
  29967. */
  29968. getDirection(localAxis: Vector3): Vector3;
  29969. /**
  29970. * Returns the current camera absolute rotation
  29971. */
  29972. get absoluteRotation(): Quaternion;
  29973. /**
  29974. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29975. * @param localAxis Defines the reference axis to provide a relative direction.
  29976. * @param result Defines the vector to store the result in
  29977. */
  29978. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29979. /**
  29980. * Gets a camera constructor for a given camera type
  29981. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29982. * @param name The name of the camera the result will be able to instantiate
  29983. * @param scene The scene the result will construct the camera in
  29984. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29985. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29986. * @returns a factory method to construc the camera
  29987. */
  29988. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29989. /**
  29990. * Compute the world matrix of the camera.
  29991. * @returns the camera world matrix
  29992. */
  29993. computeWorldMatrix(): Matrix;
  29994. /**
  29995. * Parse a JSON and creates the camera from the parsed information
  29996. * @param parsedCamera The JSON to parse
  29997. * @param scene The scene to instantiate the camera in
  29998. * @returns the newly constructed camera
  29999. */
  30000. static Parse(parsedCamera: any, scene: Scene): Camera;
  30001. }
  30002. }
  30003. declare module BABYLON {
  30004. /**
  30005. * Class containing static functions to help procedurally build meshes
  30006. */
  30007. export class DiscBuilder {
  30008. /**
  30009. * Creates a plane polygonal mesh. By default, this is a disc
  30010. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30011. * * 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
  30012. * * 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
  30013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30014. * * 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
  30015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30016. * @param name defines the name of the mesh
  30017. * @param options defines the options used to create the mesh
  30018. * @param scene defines the hosting scene
  30019. * @returns the plane polygonal mesh
  30020. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30021. */
  30022. static CreateDisc(name: string, options: {
  30023. radius?: number;
  30024. tessellation?: number;
  30025. arc?: number;
  30026. updatable?: boolean;
  30027. sideOrientation?: number;
  30028. frontUVs?: Vector4;
  30029. backUVs?: Vector4;
  30030. }, scene?: Nullable<Scene>): Mesh;
  30031. }
  30032. }
  30033. declare module BABYLON {
  30034. /**
  30035. * Options to be used when creating a FresnelParameters.
  30036. */
  30037. export type IFresnelParametersCreationOptions = {
  30038. /**
  30039. * Define the color used on edges (grazing angle)
  30040. */
  30041. leftColor?: Color3;
  30042. /**
  30043. * Define the color used on center
  30044. */
  30045. rightColor?: Color3;
  30046. /**
  30047. * Define bias applied to computed fresnel term
  30048. */
  30049. bias?: number;
  30050. /**
  30051. * Defined the power exponent applied to fresnel term
  30052. */
  30053. power?: number;
  30054. /**
  30055. * Define if the fresnel effect is enable or not.
  30056. */
  30057. isEnabled?: boolean;
  30058. };
  30059. /**
  30060. * Serialized format for FresnelParameters.
  30061. */
  30062. export type IFresnelParametersSerialized = {
  30063. /**
  30064. * Define the color used on edges (grazing angle) [as an array]
  30065. */
  30066. leftColor: number[];
  30067. /**
  30068. * Define the color used on center [as an array]
  30069. */
  30070. rightColor: number[];
  30071. /**
  30072. * Define bias applied to computed fresnel term
  30073. */
  30074. bias: number;
  30075. /**
  30076. * Defined the power exponent applied to fresnel term
  30077. */
  30078. power?: number;
  30079. /**
  30080. * Define if the fresnel effect is enable or not.
  30081. */
  30082. isEnabled: boolean;
  30083. };
  30084. /**
  30085. * This represents all the required information to add a fresnel effect on a material:
  30086. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30087. */
  30088. export class FresnelParameters {
  30089. private _isEnabled;
  30090. /**
  30091. * Define if the fresnel effect is enable or not.
  30092. */
  30093. get isEnabled(): boolean;
  30094. set isEnabled(value: boolean);
  30095. /**
  30096. * Define the color used on edges (grazing angle)
  30097. */
  30098. leftColor: Color3;
  30099. /**
  30100. * Define the color used on center
  30101. */
  30102. rightColor: Color3;
  30103. /**
  30104. * Define bias applied to computed fresnel term
  30105. */
  30106. bias: number;
  30107. /**
  30108. * Defined the power exponent applied to fresnel term
  30109. */
  30110. power: number;
  30111. /**
  30112. * Creates a new FresnelParameters object.
  30113. *
  30114. * @param options provide your own settings to optionally to override defaults
  30115. */
  30116. constructor(options?: IFresnelParametersCreationOptions);
  30117. /**
  30118. * Clones the current fresnel and its valuues
  30119. * @returns a clone fresnel configuration
  30120. */
  30121. clone(): FresnelParameters;
  30122. /**
  30123. * Determines equality between FresnelParameters objects
  30124. * @param otherFresnelParameters defines the second operand
  30125. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30126. */
  30127. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30128. /**
  30129. * Serializes the current fresnel parameters to a JSON representation.
  30130. * @return the JSON serialization
  30131. */
  30132. serialize(): IFresnelParametersSerialized;
  30133. /**
  30134. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30135. * @param parsedFresnelParameters Define the JSON representation
  30136. * @returns the parsed parameters
  30137. */
  30138. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30139. }
  30140. }
  30141. declare module BABYLON {
  30142. /**
  30143. * This groups all the flags used to control the materials channel.
  30144. */
  30145. export class MaterialFlags {
  30146. private static _DiffuseTextureEnabled;
  30147. /**
  30148. * Are diffuse textures enabled in the application.
  30149. */
  30150. static get DiffuseTextureEnabled(): boolean;
  30151. static set DiffuseTextureEnabled(value: boolean);
  30152. private static _DetailTextureEnabled;
  30153. /**
  30154. * Are detail textures enabled in the application.
  30155. */
  30156. static get DetailTextureEnabled(): boolean;
  30157. static set DetailTextureEnabled(value: boolean);
  30158. private static _AmbientTextureEnabled;
  30159. /**
  30160. * Are ambient textures enabled in the application.
  30161. */
  30162. static get AmbientTextureEnabled(): boolean;
  30163. static set AmbientTextureEnabled(value: boolean);
  30164. private static _OpacityTextureEnabled;
  30165. /**
  30166. * Are opacity textures enabled in the application.
  30167. */
  30168. static get OpacityTextureEnabled(): boolean;
  30169. static set OpacityTextureEnabled(value: boolean);
  30170. private static _ReflectionTextureEnabled;
  30171. /**
  30172. * Are reflection textures enabled in the application.
  30173. */
  30174. static get ReflectionTextureEnabled(): boolean;
  30175. static set ReflectionTextureEnabled(value: boolean);
  30176. private static _EmissiveTextureEnabled;
  30177. /**
  30178. * Are emissive textures enabled in the application.
  30179. */
  30180. static get EmissiveTextureEnabled(): boolean;
  30181. static set EmissiveTextureEnabled(value: boolean);
  30182. private static _SpecularTextureEnabled;
  30183. /**
  30184. * Are specular textures enabled in the application.
  30185. */
  30186. static get SpecularTextureEnabled(): boolean;
  30187. static set SpecularTextureEnabled(value: boolean);
  30188. private static _BumpTextureEnabled;
  30189. /**
  30190. * Are bump textures enabled in the application.
  30191. */
  30192. static get BumpTextureEnabled(): boolean;
  30193. static set BumpTextureEnabled(value: boolean);
  30194. private static _LightmapTextureEnabled;
  30195. /**
  30196. * Are lightmap textures enabled in the application.
  30197. */
  30198. static get LightmapTextureEnabled(): boolean;
  30199. static set LightmapTextureEnabled(value: boolean);
  30200. private static _RefractionTextureEnabled;
  30201. /**
  30202. * Are refraction textures enabled in the application.
  30203. */
  30204. static get RefractionTextureEnabled(): boolean;
  30205. static set RefractionTextureEnabled(value: boolean);
  30206. private static _ColorGradingTextureEnabled;
  30207. /**
  30208. * Are color grading textures enabled in the application.
  30209. */
  30210. static get ColorGradingTextureEnabled(): boolean;
  30211. static set ColorGradingTextureEnabled(value: boolean);
  30212. private static _FresnelEnabled;
  30213. /**
  30214. * Are fresnels enabled in the application.
  30215. */
  30216. static get FresnelEnabled(): boolean;
  30217. static set FresnelEnabled(value: boolean);
  30218. private static _ClearCoatTextureEnabled;
  30219. /**
  30220. * Are clear coat textures enabled in the application.
  30221. */
  30222. static get ClearCoatTextureEnabled(): boolean;
  30223. static set ClearCoatTextureEnabled(value: boolean);
  30224. private static _ClearCoatBumpTextureEnabled;
  30225. /**
  30226. * Are clear coat bump textures enabled in the application.
  30227. */
  30228. static get ClearCoatBumpTextureEnabled(): boolean;
  30229. static set ClearCoatBumpTextureEnabled(value: boolean);
  30230. private static _ClearCoatTintTextureEnabled;
  30231. /**
  30232. * Are clear coat tint textures enabled in the application.
  30233. */
  30234. static get ClearCoatTintTextureEnabled(): boolean;
  30235. static set ClearCoatTintTextureEnabled(value: boolean);
  30236. private static _SheenTextureEnabled;
  30237. /**
  30238. * Are sheen textures enabled in the application.
  30239. */
  30240. static get SheenTextureEnabled(): boolean;
  30241. static set SheenTextureEnabled(value: boolean);
  30242. private static _AnisotropicTextureEnabled;
  30243. /**
  30244. * Are anisotropic textures enabled in the application.
  30245. */
  30246. static get AnisotropicTextureEnabled(): boolean;
  30247. static set AnisotropicTextureEnabled(value: boolean);
  30248. private static _ThicknessTextureEnabled;
  30249. /**
  30250. * Are thickness textures enabled in the application.
  30251. */
  30252. static get ThicknessTextureEnabled(): boolean;
  30253. static set ThicknessTextureEnabled(value: boolean);
  30254. }
  30255. }
  30256. declare module BABYLON {
  30257. /** @hidden */
  30258. export var defaultFragmentDeclaration: {
  30259. name: string;
  30260. shader: string;
  30261. };
  30262. }
  30263. declare module BABYLON {
  30264. /** @hidden */
  30265. export var defaultUboDeclaration: {
  30266. name: string;
  30267. shader: string;
  30268. };
  30269. }
  30270. declare module BABYLON {
  30271. /** @hidden */
  30272. export var prePassDeclaration: {
  30273. name: string;
  30274. shader: string;
  30275. };
  30276. }
  30277. declare module BABYLON {
  30278. /** @hidden */
  30279. export var lightFragmentDeclaration: {
  30280. name: string;
  30281. shader: string;
  30282. };
  30283. }
  30284. declare module BABYLON {
  30285. /** @hidden */
  30286. export var lightUboDeclaration: {
  30287. name: string;
  30288. shader: string;
  30289. };
  30290. }
  30291. declare module BABYLON {
  30292. /** @hidden */
  30293. export var lightsFragmentFunctions: {
  30294. name: string;
  30295. shader: string;
  30296. };
  30297. }
  30298. declare module BABYLON {
  30299. /** @hidden */
  30300. export var shadowsFragmentFunctions: {
  30301. name: string;
  30302. shader: string;
  30303. };
  30304. }
  30305. declare module BABYLON {
  30306. /** @hidden */
  30307. export var fresnelFunction: {
  30308. name: string;
  30309. shader: string;
  30310. };
  30311. }
  30312. declare module BABYLON {
  30313. /** @hidden */
  30314. export var bumpFragmentMainFunctions: {
  30315. name: string;
  30316. shader: string;
  30317. };
  30318. }
  30319. declare module BABYLON {
  30320. /** @hidden */
  30321. export var bumpFragmentFunctions: {
  30322. name: string;
  30323. shader: string;
  30324. };
  30325. }
  30326. declare module BABYLON {
  30327. /** @hidden */
  30328. export var logDepthDeclaration: {
  30329. name: string;
  30330. shader: string;
  30331. };
  30332. }
  30333. declare module BABYLON {
  30334. /** @hidden */
  30335. export var bumpFragment: {
  30336. name: string;
  30337. shader: string;
  30338. };
  30339. }
  30340. declare module BABYLON {
  30341. /** @hidden */
  30342. export var depthPrePass: {
  30343. name: string;
  30344. shader: string;
  30345. };
  30346. }
  30347. declare module BABYLON {
  30348. /** @hidden */
  30349. export var lightFragment: {
  30350. name: string;
  30351. shader: string;
  30352. };
  30353. }
  30354. declare module BABYLON {
  30355. /** @hidden */
  30356. export var logDepthFragment: {
  30357. name: string;
  30358. shader: string;
  30359. };
  30360. }
  30361. declare module BABYLON {
  30362. /** @hidden */
  30363. export var defaultPixelShader: {
  30364. name: string;
  30365. shader: string;
  30366. };
  30367. }
  30368. declare module BABYLON {
  30369. /** @hidden */
  30370. export var defaultVertexDeclaration: {
  30371. name: string;
  30372. shader: string;
  30373. };
  30374. }
  30375. declare module BABYLON {
  30376. /** @hidden */
  30377. export var prePassVertexDeclaration: {
  30378. name: string;
  30379. shader: string;
  30380. };
  30381. }
  30382. declare module BABYLON {
  30383. /** @hidden */
  30384. export var bumpVertexDeclaration: {
  30385. name: string;
  30386. shader: string;
  30387. };
  30388. }
  30389. declare module BABYLON {
  30390. /** @hidden */
  30391. export var prePassVertex: {
  30392. name: string;
  30393. shader: string;
  30394. };
  30395. }
  30396. declare module BABYLON {
  30397. /** @hidden */
  30398. export var bumpVertex: {
  30399. name: string;
  30400. shader: string;
  30401. };
  30402. }
  30403. declare module BABYLON {
  30404. /** @hidden */
  30405. export var fogVertex: {
  30406. name: string;
  30407. shader: string;
  30408. };
  30409. }
  30410. declare module BABYLON {
  30411. /** @hidden */
  30412. export var shadowsVertex: {
  30413. name: string;
  30414. shader: string;
  30415. };
  30416. }
  30417. declare module BABYLON {
  30418. /** @hidden */
  30419. export var pointCloudVertex: {
  30420. name: string;
  30421. shader: string;
  30422. };
  30423. }
  30424. declare module BABYLON {
  30425. /** @hidden */
  30426. export var logDepthVertex: {
  30427. name: string;
  30428. shader: string;
  30429. };
  30430. }
  30431. declare module BABYLON {
  30432. /** @hidden */
  30433. export var defaultVertexShader: {
  30434. name: string;
  30435. shader: string;
  30436. };
  30437. }
  30438. declare module BABYLON {
  30439. /**
  30440. * @hidden
  30441. */
  30442. export interface IMaterialDetailMapDefines {
  30443. DETAIL: boolean;
  30444. DETAILDIRECTUV: number;
  30445. DETAIL_NORMALBLENDMETHOD: number;
  30446. /** @hidden */
  30447. _areTexturesDirty: boolean;
  30448. }
  30449. /**
  30450. * Define the code related to the detail map parameters of a material
  30451. *
  30452. * Inspired from:
  30453. * 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
  30454. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30455. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30456. */
  30457. export class DetailMapConfiguration {
  30458. private _texture;
  30459. /**
  30460. * The detail texture of the material.
  30461. */
  30462. texture: Nullable<BaseTexture>;
  30463. /**
  30464. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30465. * Bigger values mean stronger blending
  30466. */
  30467. diffuseBlendLevel: number;
  30468. /**
  30469. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30470. * Bigger values mean stronger blending. Only used with PBR materials
  30471. */
  30472. roughnessBlendLevel: number;
  30473. /**
  30474. * Defines how strong the bump effect from the detail map is
  30475. * Bigger values mean stronger effect
  30476. */
  30477. bumpLevel: number;
  30478. private _normalBlendMethod;
  30479. /**
  30480. * The method used to blend the bump and detail normals together
  30481. */
  30482. normalBlendMethod: number;
  30483. private _isEnabled;
  30484. /**
  30485. * Enable or disable the detail map on this material
  30486. */
  30487. isEnabled: boolean;
  30488. /** @hidden */
  30489. private _internalMarkAllSubMeshesAsTexturesDirty;
  30490. /** @hidden */
  30491. _markAllSubMeshesAsTexturesDirty(): void;
  30492. /**
  30493. * Instantiate a new detail map
  30494. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30495. */
  30496. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30497. /**
  30498. * Gets whether the submesh is ready to be used or not.
  30499. * @param defines the list of "defines" to update.
  30500. * @param scene defines the scene the material belongs to.
  30501. * @returns - boolean indicating that the submesh is ready or not.
  30502. */
  30503. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30504. /**
  30505. * Update the defines for detail map usage
  30506. * @param defines the list of "defines" to update.
  30507. * @param scene defines the scene the material belongs to.
  30508. */
  30509. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30510. /**
  30511. * Binds the material data.
  30512. * @param uniformBuffer defines the Uniform buffer to fill in.
  30513. * @param scene defines the scene the material belongs to.
  30514. * @param isFrozen defines whether the material is frozen or not.
  30515. */
  30516. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30517. /**
  30518. * Checks to see if a texture is used in the material.
  30519. * @param texture - Base texture to use.
  30520. * @returns - Boolean specifying if a texture is used in the material.
  30521. */
  30522. hasTexture(texture: BaseTexture): boolean;
  30523. /**
  30524. * Returns an array of the actively used textures.
  30525. * @param activeTextures Array of BaseTextures
  30526. */
  30527. getActiveTextures(activeTextures: BaseTexture[]): void;
  30528. /**
  30529. * Returns the animatable textures.
  30530. * @param animatables Array of animatable textures.
  30531. */
  30532. getAnimatables(animatables: IAnimatable[]): void;
  30533. /**
  30534. * Disposes the resources of the material.
  30535. * @param forceDisposeTextures - Forces the disposal of all textures.
  30536. */
  30537. dispose(forceDisposeTextures?: boolean): void;
  30538. /**
  30539. * Get the current class name useful for serialization or dynamic coding.
  30540. * @returns "DetailMap"
  30541. */
  30542. getClassName(): string;
  30543. /**
  30544. * Add the required uniforms to the current list.
  30545. * @param uniforms defines the current uniform list.
  30546. */
  30547. static AddUniforms(uniforms: string[]): void;
  30548. /**
  30549. * Add the required samplers to the current list.
  30550. * @param samplers defines the current sampler list.
  30551. */
  30552. static AddSamplers(samplers: string[]): void;
  30553. /**
  30554. * Add the required uniforms to the current buffer.
  30555. * @param uniformBuffer defines the current uniform buffer.
  30556. */
  30557. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30558. /**
  30559. * Makes a duplicate of the current instance into another one.
  30560. * @param detailMap define the instance where to copy the info
  30561. */
  30562. copyTo(detailMap: DetailMapConfiguration): void;
  30563. /**
  30564. * Serializes this detail map instance
  30565. * @returns - An object with the serialized instance.
  30566. */
  30567. serialize(): any;
  30568. /**
  30569. * Parses a detail map setting from a serialized object.
  30570. * @param source - Serialized object.
  30571. * @param scene Defines the scene we are parsing for
  30572. * @param rootUrl Defines the rootUrl to load from
  30573. */
  30574. parse(source: any, scene: Scene, rootUrl: string): void;
  30575. }
  30576. }
  30577. declare module BABYLON {
  30578. /** @hidden */
  30579. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30580. MAINUV1: boolean;
  30581. MAINUV2: boolean;
  30582. DIFFUSE: boolean;
  30583. DIFFUSEDIRECTUV: number;
  30584. DETAIL: boolean;
  30585. DETAILDIRECTUV: number;
  30586. DETAIL_NORMALBLENDMETHOD: number;
  30587. AMBIENT: boolean;
  30588. AMBIENTDIRECTUV: number;
  30589. OPACITY: boolean;
  30590. OPACITYDIRECTUV: number;
  30591. OPACITYRGB: boolean;
  30592. REFLECTION: boolean;
  30593. EMISSIVE: boolean;
  30594. EMISSIVEDIRECTUV: number;
  30595. SPECULAR: boolean;
  30596. SPECULARDIRECTUV: number;
  30597. BUMP: boolean;
  30598. BUMPDIRECTUV: number;
  30599. PARALLAX: boolean;
  30600. PARALLAXOCCLUSION: boolean;
  30601. SPECULAROVERALPHA: boolean;
  30602. CLIPPLANE: boolean;
  30603. CLIPPLANE2: boolean;
  30604. CLIPPLANE3: boolean;
  30605. CLIPPLANE4: boolean;
  30606. CLIPPLANE5: boolean;
  30607. CLIPPLANE6: boolean;
  30608. ALPHATEST: boolean;
  30609. DEPTHPREPASS: boolean;
  30610. ALPHAFROMDIFFUSE: boolean;
  30611. POINTSIZE: boolean;
  30612. FOG: boolean;
  30613. SPECULARTERM: boolean;
  30614. DIFFUSEFRESNEL: boolean;
  30615. OPACITYFRESNEL: boolean;
  30616. REFLECTIONFRESNEL: boolean;
  30617. REFRACTIONFRESNEL: boolean;
  30618. EMISSIVEFRESNEL: boolean;
  30619. FRESNEL: boolean;
  30620. NORMAL: boolean;
  30621. UV1: boolean;
  30622. UV2: boolean;
  30623. VERTEXCOLOR: boolean;
  30624. VERTEXALPHA: boolean;
  30625. NUM_BONE_INFLUENCERS: number;
  30626. BonesPerMesh: number;
  30627. BONETEXTURE: boolean;
  30628. BONES_VELOCITY_ENABLED: boolean;
  30629. INSTANCES: boolean;
  30630. THIN_INSTANCES: boolean;
  30631. GLOSSINESS: boolean;
  30632. ROUGHNESS: boolean;
  30633. EMISSIVEASILLUMINATION: boolean;
  30634. LINKEMISSIVEWITHDIFFUSE: boolean;
  30635. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30636. LIGHTMAP: boolean;
  30637. LIGHTMAPDIRECTUV: number;
  30638. OBJECTSPACE_NORMALMAP: boolean;
  30639. USELIGHTMAPASSHADOWMAP: boolean;
  30640. REFLECTIONMAP_3D: boolean;
  30641. REFLECTIONMAP_SPHERICAL: boolean;
  30642. REFLECTIONMAP_PLANAR: boolean;
  30643. REFLECTIONMAP_CUBIC: boolean;
  30644. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30645. REFLECTIONMAP_PROJECTION: boolean;
  30646. REFLECTIONMAP_SKYBOX: boolean;
  30647. REFLECTIONMAP_EXPLICIT: boolean;
  30648. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30649. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30650. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30651. INVERTCUBICMAP: boolean;
  30652. LOGARITHMICDEPTH: boolean;
  30653. REFRACTION: boolean;
  30654. REFRACTIONMAP_3D: boolean;
  30655. REFLECTIONOVERALPHA: boolean;
  30656. TWOSIDEDLIGHTING: boolean;
  30657. SHADOWFLOAT: boolean;
  30658. MORPHTARGETS: boolean;
  30659. MORPHTARGETS_NORMAL: boolean;
  30660. MORPHTARGETS_TANGENT: boolean;
  30661. MORPHTARGETS_UV: boolean;
  30662. NUM_MORPH_INFLUENCERS: number;
  30663. NONUNIFORMSCALING: boolean;
  30664. PREMULTIPLYALPHA: boolean;
  30665. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30666. ALPHABLEND: boolean;
  30667. PREPASS: boolean;
  30668. PREPASS_IRRADIANCE: boolean;
  30669. PREPASS_IRRADIANCE_INDEX: number;
  30670. PREPASS_ALBEDO: boolean;
  30671. PREPASS_ALBEDO_INDEX: number;
  30672. PREPASS_DEPTHNORMAL: boolean;
  30673. PREPASS_DEPTHNORMAL_INDEX: number;
  30674. PREPASS_POSITION: boolean;
  30675. PREPASS_POSITION_INDEX: number;
  30676. PREPASS_VELOCITY: boolean;
  30677. PREPASS_VELOCITY_INDEX: number;
  30678. PREPASS_REFLECTIVITY: boolean;
  30679. PREPASS_REFLECTIVITY_INDEX: number;
  30680. SCENE_MRT_COUNT: number;
  30681. RGBDLIGHTMAP: boolean;
  30682. RGBDREFLECTION: boolean;
  30683. RGBDREFRACTION: boolean;
  30684. IMAGEPROCESSING: boolean;
  30685. VIGNETTE: boolean;
  30686. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30687. VIGNETTEBLENDMODEOPAQUE: boolean;
  30688. TONEMAPPING: boolean;
  30689. TONEMAPPING_ACES: boolean;
  30690. CONTRAST: boolean;
  30691. COLORCURVES: boolean;
  30692. COLORGRADING: boolean;
  30693. COLORGRADING3D: boolean;
  30694. SAMPLER3DGREENDEPTH: boolean;
  30695. SAMPLER3DBGRMAP: boolean;
  30696. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30697. MULTIVIEW: boolean;
  30698. /**
  30699. * If the reflection texture on this material is in linear color space
  30700. * @hidden
  30701. */
  30702. IS_REFLECTION_LINEAR: boolean;
  30703. /**
  30704. * If the refraction texture on this material is in linear color space
  30705. * @hidden
  30706. */
  30707. IS_REFRACTION_LINEAR: boolean;
  30708. EXPOSURE: boolean;
  30709. constructor();
  30710. setReflectionMode(modeToEnable: string): void;
  30711. }
  30712. /**
  30713. * This is the default material used in Babylon. It is the best trade off between quality
  30714. * and performances.
  30715. * @see https://doc.babylonjs.com/babylon101/materials
  30716. */
  30717. export class StandardMaterial extends PushMaterial {
  30718. private _diffuseTexture;
  30719. /**
  30720. * The basic texture of the material as viewed under a light.
  30721. */
  30722. diffuseTexture: Nullable<BaseTexture>;
  30723. private _ambientTexture;
  30724. /**
  30725. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30726. */
  30727. ambientTexture: Nullable<BaseTexture>;
  30728. private _opacityTexture;
  30729. /**
  30730. * Define the transparency of the material from a texture.
  30731. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30732. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30733. */
  30734. opacityTexture: Nullable<BaseTexture>;
  30735. private _reflectionTexture;
  30736. /**
  30737. * Define the texture used to display the reflection.
  30738. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30739. */
  30740. reflectionTexture: Nullable<BaseTexture>;
  30741. private _emissiveTexture;
  30742. /**
  30743. * Define texture of the material as if self lit.
  30744. * This will be mixed in the final result even in the absence of light.
  30745. */
  30746. emissiveTexture: Nullable<BaseTexture>;
  30747. private _specularTexture;
  30748. /**
  30749. * Define how the color and intensity of the highlight given by the light in the material.
  30750. */
  30751. specularTexture: Nullable<BaseTexture>;
  30752. private _bumpTexture;
  30753. /**
  30754. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30755. * 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.
  30756. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30757. */
  30758. bumpTexture: Nullable<BaseTexture>;
  30759. private _lightmapTexture;
  30760. /**
  30761. * Complex lighting can be computationally expensive to compute at runtime.
  30762. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30763. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30764. */
  30765. lightmapTexture: Nullable<BaseTexture>;
  30766. private _refractionTexture;
  30767. /**
  30768. * Define the texture used to display the refraction.
  30769. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30770. */
  30771. refractionTexture: Nullable<BaseTexture>;
  30772. /**
  30773. * The color of the material lit by the environmental background lighting.
  30774. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30775. */
  30776. ambientColor: Color3;
  30777. /**
  30778. * The basic color of the material as viewed under a light.
  30779. */
  30780. diffuseColor: Color3;
  30781. /**
  30782. * Define how the color and intensity of the highlight given by the light in the material.
  30783. */
  30784. specularColor: Color3;
  30785. /**
  30786. * Define the color of the material as if self lit.
  30787. * This will be mixed in the final result even in the absence of light.
  30788. */
  30789. emissiveColor: Color3;
  30790. /**
  30791. * Defines how sharp are the highlights in the material.
  30792. * The bigger the value the sharper giving a more glossy feeling to the result.
  30793. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30794. */
  30795. specularPower: number;
  30796. private _useAlphaFromDiffuseTexture;
  30797. /**
  30798. * Does the transparency come from the diffuse texture alpha channel.
  30799. */
  30800. useAlphaFromDiffuseTexture: boolean;
  30801. private _useEmissiveAsIllumination;
  30802. /**
  30803. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30804. */
  30805. useEmissiveAsIllumination: boolean;
  30806. private _linkEmissiveWithDiffuse;
  30807. /**
  30808. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30809. * the emissive level when the final color is close to one.
  30810. */
  30811. linkEmissiveWithDiffuse: boolean;
  30812. private _useSpecularOverAlpha;
  30813. /**
  30814. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30815. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30816. */
  30817. useSpecularOverAlpha: boolean;
  30818. private _useReflectionOverAlpha;
  30819. /**
  30820. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30821. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30822. */
  30823. useReflectionOverAlpha: boolean;
  30824. private _disableLighting;
  30825. /**
  30826. * Does lights from the scene impacts this material.
  30827. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30828. */
  30829. disableLighting: boolean;
  30830. private _useObjectSpaceNormalMap;
  30831. /**
  30832. * Allows using an object space normal map (instead of tangent space).
  30833. */
  30834. useObjectSpaceNormalMap: boolean;
  30835. private _useParallax;
  30836. /**
  30837. * Is parallax enabled or not.
  30838. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30839. */
  30840. useParallax: boolean;
  30841. private _useParallaxOcclusion;
  30842. /**
  30843. * Is parallax occlusion enabled or not.
  30844. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30845. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30846. */
  30847. useParallaxOcclusion: boolean;
  30848. /**
  30849. * 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.
  30850. */
  30851. parallaxScaleBias: number;
  30852. private _roughness;
  30853. /**
  30854. * Helps to define how blurry the reflections should appears in the material.
  30855. */
  30856. roughness: number;
  30857. /**
  30858. * In case of refraction, define the value of the index of refraction.
  30859. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30860. */
  30861. indexOfRefraction: number;
  30862. /**
  30863. * Invert the refraction texture alongside the y axis.
  30864. * It can be useful with procedural textures or probe for instance.
  30865. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30866. */
  30867. invertRefractionY: boolean;
  30868. /**
  30869. * Defines the alpha limits in alpha test mode.
  30870. */
  30871. alphaCutOff: number;
  30872. private _useLightmapAsShadowmap;
  30873. /**
  30874. * In case of light mapping, define whether the map contains light or shadow informations.
  30875. */
  30876. useLightmapAsShadowmap: boolean;
  30877. private _diffuseFresnelParameters;
  30878. /**
  30879. * Define the diffuse fresnel parameters of the material.
  30880. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30881. */
  30882. diffuseFresnelParameters: FresnelParameters;
  30883. private _opacityFresnelParameters;
  30884. /**
  30885. * Define the opacity fresnel parameters of the material.
  30886. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30887. */
  30888. opacityFresnelParameters: FresnelParameters;
  30889. private _reflectionFresnelParameters;
  30890. /**
  30891. * Define the reflection fresnel parameters of the material.
  30892. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30893. */
  30894. reflectionFresnelParameters: FresnelParameters;
  30895. private _refractionFresnelParameters;
  30896. /**
  30897. * Define the refraction fresnel parameters of the material.
  30898. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30899. */
  30900. refractionFresnelParameters: FresnelParameters;
  30901. private _emissiveFresnelParameters;
  30902. /**
  30903. * Define the emissive fresnel parameters of the material.
  30904. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30905. */
  30906. emissiveFresnelParameters: FresnelParameters;
  30907. private _useReflectionFresnelFromSpecular;
  30908. /**
  30909. * If true automatically deducts the fresnels values from the material specularity.
  30910. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30911. */
  30912. useReflectionFresnelFromSpecular: boolean;
  30913. private _useGlossinessFromSpecularMapAlpha;
  30914. /**
  30915. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30916. */
  30917. useGlossinessFromSpecularMapAlpha: boolean;
  30918. private _maxSimultaneousLights;
  30919. /**
  30920. * Defines the maximum number of lights that can be used in the material
  30921. */
  30922. maxSimultaneousLights: number;
  30923. private _invertNormalMapX;
  30924. /**
  30925. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30926. */
  30927. invertNormalMapX: boolean;
  30928. private _invertNormalMapY;
  30929. /**
  30930. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30931. */
  30932. invertNormalMapY: boolean;
  30933. private _twoSidedLighting;
  30934. /**
  30935. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30936. */
  30937. twoSidedLighting: boolean;
  30938. /**
  30939. * Default configuration related to image processing available in the standard Material.
  30940. */
  30941. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30942. /**
  30943. * Gets the image processing configuration used either in this material.
  30944. */
  30945. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30946. /**
  30947. * Sets the Default image processing configuration used either in the this material.
  30948. *
  30949. * If sets to null, the scene one is in use.
  30950. */
  30951. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30952. /**
  30953. * Keep track of the image processing observer to allow dispose and replace.
  30954. */
  30955. private _imageProcessingObserver;
  30956. /**
  30957. * Attaches a new image processing configuration to the Standard Material.
  30958. * @param configuration
  30959. */
  30960. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30961. /**
  30962. * Defines additionnal PrePass parameters for the material.
  30963. */
  30964. readonly prePassConfiguration: PrePassConfiguration;
  30965. /**
  30966. * Gets wether the color curves effect is enabled.
  30967. */
  30968. get cameraColorCurvesEnabled(): boolean;
  30969. /**
  30970. * Sets wether the color curves effect is enabled.
  30971. */
  30972. set cameraColorCurvesEnabled(value: boolean);
  30973. /**
  30974. * Gets wether the color grading effect is enabled.
  30975. */
  30976. get cameraColorGradingEnabled(): boolean;
  30977. /**
  30978. * Gets wether the color grading effect is enabled.
  30979. */
  30980. set cameraColorGradingEnabled(value: boolean);
  30981. /**
  30982. * Gets wether tonemapping is enabled or not.
  30983. */
  30984. get cameraToneMappingEnabled(): boolean;
  30985. /**
  30986. * Sets wether tonemapping is enabled or not
  30987. */
  30988. set cameraToneMappingEnabled(value: boolean);
  30989. /**
  30990. * The camera exposure used on this material.
  30991. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30992. * This corresponds to a photographic exposure.
  30993. */
  30994. get cameraExposure(): number;
  30995. /**
  30996. * The camera exposure used on this material.
  30997. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30998. * This corresponds to a photographic exposure.
  30999. */
  31000. set cameraExposure(value: number);
  31001. /**
  31002. * Gets The camera contrast used on this material.
  31003. */
  31004. get cameraContrast(): number;
  31005. /**
  31006. * Sets The camera contrast used on this material.
  31007. */
  31008. set cameraContrast(value: number);
  31009. /**
  31010. * Gets the Color Grading 2D Lookup Texture.
  31011. */
  31012. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  31013. /**
  31014. * Sets the Color Grading 2D Lookup Texture.
  31015. */
  31016. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  31017. /**
  31018. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31019. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31020. * 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;
  31021. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31022. */
  31023. get cameraColorCurves(): Nullable<ColorCurves>;
  31024. /**
  31025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  31026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  31027. * 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;
  31028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  31029. */
  31030. set cameraColorCurves(value: Nullable<ColorCurves>);
  31031. /**
  31032. * Can this material render to several textures at once
  31033. */
  31034. get canRenderToMRT(): boolean;
  31035. /**
  31036. * Defines the detail map parameters for the material.
  31037. */
  31038. readonly detailMap: DetailMapConfiguration;
  31039. protected _renderTargets: SmartArray<RenderTargetTexture>;
  31040. protected _worldViewProjectionMatrix: Matrix;
  31041. protected _globalAmbientColor: Color3;
  31042. protected _useLogarithmicDepth: boolean;
  31043. protected _rebuildInParallel: boolean;
  31044. /**
  31045. * Instantiates a new standard material.
  31046. * This is the default material used in Babylon. It is the best trade off between quality
  31047. * and performances.
  31048. * @see https://doc.babylonjs.com/babylon101/materials
  31049. * @param name Define the name of the material in the scene
  31050. * @param scene Define the scene the material belong to
  31051. */
  31052. constructor(name: string, scene: Scene);
  31053. /**
  31054. * Gets a boolean indicating that current material needs to register RTT
  31055. */
  31056. get hasRenderTargetTextures(): boolean;
  31057. /**
  31058. * Gets the current class name of the material e.g. "StandardMaterial"
  31059. * Mainly use in serialization.
  31060. * @returns the class name
  31061. */
  31062. getClassName(): string;
  31063. /**
  31064. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31065. * You can try switching to logarithmic depth.
  31066. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31067. */
  31068. get useLogarithmicDepth(): boolean;
  31069. set useLogarithmicDepth(value: boolean);
  31070. /**
  31071. * Specifies if the material will require alpha blending
  31072. * @returns a boolean specifying if alpha blending is needed
  31073. */
  31074. needAlphaBlending(): boolean;
  31075. /**
  31076. * Specifies if this material should be rendered in alpha test mode
  31077. * @returns a boolean specifying if an alpha test is needed.
  31078. */
  31079. needAlphaTesting(): boolean;
  31080. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31081. /**
  31082. * Get the texture used for alpha test purpose.
  31083. * @returns the diffuse texture in case of the standard material.
  31084. */
  31085. getAlphaTestTexture(): Nullable<BaseTexture>;
  31086. /**
  31087. * Get if the submesh is ready to be used and all its information available.
  31088. * Child classes can use it to update shaders
  31089. * @param mesh defines the mesh to check
  31090. * @param subMesh defines which submesh to check
  31091. * @param useInstances specifies that instances should be used
  31092. * @returns a boolean indicating that the submesh is ready or not
  31093. */
  31094. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31095. /**
  31096. * Builds the material UBO layouts.
  31097. * Used internally during the effect preparation.
  31098. */
  31099. buildUniformLayout(): void;
  31100. /**
  31101. * Unbinds the material from the mesh
  31102. */
  31103. unbind(): void;
  31104. /**
  31105. * Binds the submesh to this material by preparing the effect and shader to draw
  31106. * @param world defines the world transformation matrix
  31107. * @param mesh defines the mesh containing the submesh
  31108. * @param subMesh defines the submesh to bind the material to
  31109. */
  31110. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31111. /**
  31112. * Get the list of animatables in the material.
  31113. * @returns the list of animatables object used in the material
  31114. */
  31115. getAnimatables(): IAnimatable[];
  31116. /**
  31117. * Gets the active textures from the material
  31118. * @returns an array of textures
  31119. */
  31120. getActiveTextures(): BaseTexture[];
  31121. /**
  31122. * Specifies if the material uses a texture
  31123. * @param texture defines the texture to check against the material
  31124. * @returns a boolean specifying if the material uses the texture
  31125. */
  31126. hasTexture(texture: BaseTexture): boolean;
  31127. /**
  31128. * Disposes the material
  31129. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31130. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31131. */
  31132. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31133. /**
  31134. * Makes a duplicate of the material, and gives it a new name
  31135. * @param name defines the new name for the duplicated material
  31136. * @returns the cloned material
  31137. */
  31138. clone(name: string): StandardMaterial;
  31139. /**
  31140. * Serializes this material in a JSON representation
  31141. * @returns the serialized material object
  31142. */
  31143. serialize(): any;
  31144. /**
  31145. * Creates a standard material from parsed material data
  31146. * @param source defines the JSON representation of the material
  31147. * @param scene defines the hosting scene
  31148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31149. * @returns a new standard material
  31150. */
  31151. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31152. /**
  31153. * Are diffuse textures enabled in the application.
  31154. */
  31155. static get DiffuseTextureEnabled(): boolean;
  31156. static set DiffuseTextureEnabled(value: boolean);
  31157. /**
  31158. * Are detail textures enabled in the application.
  31159. */
  31160. static get DetailTextureEnabled(): boolean;
  31161. static set DetailTextureEnabled(value: boolean);
  31162. /**
  31163. * Are ambient textures enabled in the application.
  31164. */
  31165. static get AmbientTextureEnabled(): boolean;
  31166. static set AmbientTextureEnabled(value: boolean);
  31167. /**
  31168. * Are opacity textures enabled in the application.
  31169. */
  31170. static get OpacityTextureEnabled(): boolean;
  31171. static set OpacityTextureEnabled(value: boolean);
  31172. /**
  31173. * Are reflection textures enabled in the application.
  31174. */
  31175. static get ReflectionTextureEnabled(): boolean;
  31176. static set ReflectionTextureEnabled(value: boolean);
  31177. /**
  31178. * Are emissive textures enabled in the application.
  31179. */
  31180. static get EmissiveTextureEnabled(): boolean;
  31181. static set EmissiveTextureEnabled(value: boolean);
  31182. /**
  31183. * Are specular textures enabled in the application.
  31184. */
  31185. static get SpecularTextureEnabled(): boolean;
  31186. static set SpecularTextureEnabled(value: boolean);
  31187. /**
  31188. * Are bump textures enabled in the application.
  31189. */
  31190. static get BumpTextureEnabled(): boolean;
  31191. static set BumpTextureEnabled(value: boolean);
  31192. /**
  31193. * Are lightmap textures enabled in the application.
  31194. */
  31195. static get LightmapTextureEnabled(): boolean;
  31196. static set LightmapTextureEnabled(value: boolean);
  31197. /**
  31198. * Are refraction textures enabled in the application.
  31199. */
  31200. static get RefractionTextureEnabled(): boolean;
  31201. static set RefractionTextureEnabled(value: boolean);
  31202. /**
  31203. * Are color grading textures enabled in the application.
  31204. */
  31205. static get ColorGradingTextureEnabled(): boolean;
  31206. static set ColorGradingTextureEnabled(value: boolean);
  31207. /**
  31208. * Are fresnels enabled in the application.
  31209. */
  31210. static get FresnelEnabled(): boolean;
  31211. static set FresnelEnabled(value: boolean);
  31212. }
  31213. }
  31214. declare module BABYLON {
  31215. /**
  31216. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31217. *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.
  31218. * The SPS is also a particle system. It provides some methods to manage the particles.
  31219. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31220. *
  31221. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31222. */
  31223. export class SolidParticleSystem implements IDisposable {
  31224. /**
  31225. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31226. * Example : var p = SPS.particles[i];
  31227. */
  31228. particles: SolidParticle[];
  31229. /**
  31230. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31231. */
  31232. nbParticles: number;
  31233. /**
  31234. * If the particles must ever face the camera (default false). Useful for planar particles.
  31235. */
  31236. billboard: boolean;
  31237. /**
  31238. * Recompute normals when adding a shape
  31239. */
  31240. recomputeNormals: boolean;
  31241. /**
  31242. * This a counter ofr your own usage. It's not set by any SPS functions.
  31243. */
  31244. counter: number;
  31245. /**
  31246. * The SPS name. This name is also given to the underlying mesh.
  31247. */
  31248. name: string;
  31249. /**
  31250. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31251. */
  31252. mesh: Mesh;
  31253. /**
  31254. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31255. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31256. */
  31257. vars: any;
  31258. /**
  31259. * This array is populated when the SPS is set as 'pickable'.
  31260. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31261. * Each element of this array is an object `{idx: int, faceId: int}`.
  31262. * `idx` is the picked particle index in the `SPS.particles` array
  31263. * `faceId` is the picked face index counted within this particle.
  31264. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31265. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31266. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31267. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31268. */
  31269. pickedParticles: {
  31270. idx: number;
  31271. faceId: number;
  31272. }[];
  31273. /**
  31274. * This array is populated when the SPS is set as 'pickable'
  31275. * Each key of this array is a submesh index.
  31276. * Each element of this array is a second array defined like this :
  31277. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31278. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31279. * `idx` is the picked particle index in the `SPS.particles` array
  31280. * `faceId` is the picked face index counted within this particle.
  31281. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31282. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31283. */
  31284. pickedBySubMesh: {
  31285. idx: number;
  31286. faceId: number;
  31287. }[][];
  31288. /**
  31289. * This array is populated when `enableDepthSort` is set to true.
  31290. * Each element of this array is an instance of the class DepthSortedParticle.
  31291. */
  31292. depthSortedParticles: DepthSortedParticle[];
  31293. /**
  31294. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31295. * @hidden
  31296. */
  31297. _bSphereOnly: boolean;
  31298. /**
  31299. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31300. * @hidden
  31301. */
  31302. _bSphereRadiusFactor: number;
  31303. private _scene;
  31304. private _positions;
  31305. private _indices;
  31306. private _normals;
  31307. private _colors;
  31308. private _uvs;
  31309. private _indices32;
  31310. private _positions32;
  31311. private _normals32;
  31312. private _fixedNormal32;
  31313. private _colors32;
  31314. private _uvs32;
  31315. private _index;
  31316. private _updatable;
  31317. private _pickable;
  31318. private _isVisibilityBoxLocked;
  31319. private _alwaysVisible;
  31320. private _depthSort;
  31321. private _expandable;
  31322. private _shapeCounter;
  31323. private _copy;
  31324. private _color;
  31325. private _computeParticleColor;
  31326. private _computeParticleTexture;
  31327. private _computeParticleRotation;
  31328. private _computeParticleVertex;
  31329. private _computeBoundingBox;
  31330. private _depthSortParticles;
  31331. private _camera;
  31332. private _mustUnrotateFixedNormals;
  31333. private _particlesIntersect;
  31334. private _needs32Bits;
  31335. private _isNotBuilt;
  31336. private _lastParticleId;
  31337. private _idxOfId;
  31338. private _multimaterialEnabled;
  31339. private _useModelMaterial;
  31340. private _indicesByMaterial;
  31341. private _materialIndexes;
  31342. private _depthSortFunction;
  31343. private _materialSortFunction;
  31344. private _materials;
  31345. private _multimaterial;
  31346. private _materialIndexesById;
  31347. private _defaultMaterial;
  31348. private _autoUpdateSubMeshes;
  31349. private _tmpVertex;
  31350. /**
  31351. * Creates a SPS (Solid Particle System) object.
  31352. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31353. * @param scene (Scene) is the scene in which the SPS is added.
  31354. * @param options defines the options of the sps e.g.
  31355. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31356. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31357. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31358. * * 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.
  31359. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31360. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31361. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31362. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31363. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31364. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31365. */
  31366. constructor(name: string, scene: Scene, options?: {
  31367. updatable?: boolean;
  31368. isPickable?: boolean;
  31369. enableDepthSort?: boolean;
  31370. particleIntersection?: boolean;
  31371. boundingSphereOnly?: boolean;
  31372. bSphereRadiusFactor?: number;
  31373. expandable?: boolean;
  31374. useModelMaterial?: boolean;
  31375. enableMultiMaterial?: boolean;
  31376. });
  31377. /**
  31378. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31379. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31380. * @returns the created mesh
  31381. */
  31382. buildMesh(): Mesh;
  31383. /**
  31384. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31385. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31386. * Thus the particles generated from `digest()` have their property `position` set yet.
  31387. * @param mesh ( Mesh ) is the mesh to be digested
  31388. * @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
  31389. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31390. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31391. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31392. * @returns the current SPS
  31393. */
  31394. digest(mesh: Mesh, options?: {
  31395. facetNb?: number;
  31396. number?: number;
  31397. delta?: number;
  31398. storage?: [];
  31399. }): SolidParticleSystem;
  31400. /**
  31401. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31402. * @hidden
  31403. */
  31404. private _unrotateFixedNormals;
  31405. /**
  31406. * Resets the temporary working copy particle
  31407. * @hidden
  31408. */
  31409. private _resetCopy;
  31410. /**
  31411. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31412. * @param p the current index in the positions array to be updated
  31413. * @param ind the current index in the indices array
  31414. * @param shape a Vector3 array, the shape geometry
  31415. * @param positions the positions array to be updated
  31416. * @param meshInd the shape indices array
  31417. * @param indices the indices array to be updated
  31418. * @param meshUV the shape uv array
  31419. * @param uvs the uv array to be updated
  31420. * @param meshCol the shape color array
  31421. * @param colors the color array to be updated
  31422. * @param meshNor the shape normals array
  31423. * @param normals the normals array to be updated
  31424. * @param idx the particle index
  31425. * @param idxInShape the particle index in its shape
  31426. * @param options the addShape() method passed options
  31427. * @model the particle model
  31428. * @hidden
  31429. */
  31430. private _meshBuilder;
  31431. /**
  31432. * Returns a shape Vector3 array from positions float array
  31433. * @param positions float array
  31434. * @returns a vector3 array
  31435. * @hidden
  31436. */
  31437. private _posToShape;
  31438. /**
  31439. * Returns a shapeUV array from a float uvs (array deep copy)
  31440. * @param uvs as a float array
  31441. * @returns a shapeUV array
  31442. * @hidden
  31443. */
  31444. private _uvsToShapeUV;
  31445. /**
  31446. * Adds a new particle object in the particles array
  31447. * @param idx particle index in particles array
  31448. * @param id particle id
  31449. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31450. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31451. * @param model particle ModelShape object
  31452. * @param shapeId model shape identifier
  31453. * @param idxInShape index of the particle in the current model
  31454. * @param bInfo model bounding info object
  31455. * @param storage target storage array, if any
  31456. * @hidden
  31457. */
  31458. private _addParticle;
  31459. /**
  31460. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31461. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31462. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31463. * @param nb (positive integer) the number of particles to be created from this model
  31464. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31465. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31466. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31467. * @returns the number of shapes in the system
  31468. */
  31469. addShape(mesh: Mesh, nb: number, options?: {
  31470. positionFunction?: any;
  31471. vertexFunction?: any;
  31472. storage?: [];
  31473. }): number;
  31474. /**
  31475. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31476. * @hidden
  31477. */
  31478. private _rebuildParticle;
  31479. /**
  31480. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31481. * @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.
  31482. * @returns the SPS.
  31483. */
  31484. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31485. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31486. * Returns an array with the removed particles.
  31487. * 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.
  31488. * The SPS can't be empty so at least one particle needs to remain in place.
  31489. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31490. * @param start index of the first particle to remove
  31491. * @param end index of the last particle to remove (included)
  31492. * @returns an array populated with the removed particles
  31493. */
  31494. removeParticles(start: number, end: number): SolidParticle[];
  31495. /**
  31496. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31497. * @param solidParticleArray an array populated with Solid Particles objects
  31498. * @returns the SPS
  31499. */
  31500. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31501. /**
  31502. * Creates a new particle and modifies the SPS mesh geometry :
  31503. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31504. * - calls _addParticle() to populate the particle array
  31505. * factorized code from addShape() and insertParticlesFromArray()
  31506. * @param idx particle index in the particles array
  31507. * @param i particle index in its shape
  31508. * @param modelShape particle ModelShape object
  31509. * @param shape shape vertex array
  31510. * @param meshInd shape indices array
  31511. * @param meshUV shape uv array
  31512. * @param meshCol shape color array
  31513. * @param meshNor shape normals array
  31514. * @param bbInfo shape bounding info
  31515. * @param storage target particle storage
  31516. * @options addShape() passed options
  31517. * @hidden
  31518. */
  31519. private _insertNewParticle;
  31520. /**
  31521. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31522. * This method calls `updateParticle()` for each particle of the SPS.
  31523. * For an animated SPS, it is usually called within the render loop.
  31524. * 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.
  31525. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31526. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31527. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31528. * @returns the SPS.
  31529. */
  31530. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31531. /**
  31532. * Disposes the SPS.
  31533. */
  31534. dispose(): void;
  31535. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31536. * idx is the particle index in the SPS
  31537. * faceId is the picked face index counted within this particle.
  31538. * Returns null if the pickInfo can't identify a picked particle.
  31539. * @param pickingInfo (PickingInfo object)
  31540. * @returns {idx: number, faceId: number} or null
  31541. */
  31542. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31543. idx: number;
  31544. faceId: number;
  31545. }>;
  31546. /**
  31547. * Returns a SolidParticle object from its identifier : particle.id
  31548. * @param id (integer) the particle Id
  31549. * @returns the searched particle or null if not found in the SPS.
  31550. */
  31551. getParticleById(id: number): Nullable<SolidParticle>;
  31552. /**
  31553. * Returns a new array populated with the particles having the passed shapeId.
  31554. * @param shapeId (integer) the shape identifier
  31555. * @returns a new solid particle array
  31556. */
  31557. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31558. /**
  31559. * Populates the passed array "ref" with the particles having the passed shapeId.
  31560. * @param shapeId the shape identifier
  31561. * @returns the SPS
  31562. * @param ref
  31563. */
  31564. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31565. /**
  31566. * Computes the required SubMeshes according the materials assigned to the particles.
  31567. * @returns the solid particle system.
  31568. * Does nothing if called before the SPS mesh is built.
  31569. */
  31570. computeSubMeshes(): SolidParticleSystem;
  31571. /**
  31572. * Sorts the solid particles by material when MultiMaterial is enabled.
  31573. * Updates the indices32 array.
  31574. * Updates the indicesByMaterial array.
  31575. * Updates the mesh indices array.
  31576. * @returns the SPS
  31577. * @hidden
  31578. */
  31579. private _sortParticlesByMaterial;
  31580. /**
  31581. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31582. * @hidden
  31583. */
  31584. private _setMaterialIndexesById;
  31585. /**
  31586. * Returns an array with unique values of Materials from the passed array
  31587. * @param array the material array to be checked and filtered
  31588. * @hidden
  31589. */
  31590. private _filterUniqueMaterialId;
  31591. /**
  31592. * Sets a new Standard Material as _defaultMaterial if not already set.
  31593. * @hidden
  31594. */
  31595. private _setDefaultMaterial;
  31596. /**
  31597. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31598. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31599. * @returns the SPS.
  31600. */
  31601. refreshVisibleSize(): SolidParticleSystem;
  31602. /**
  31603. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31604. * @param size the size (float) of the visibility box
  31605. * note : this doesn't lock the SPS mesh bounding box.
  31606. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31607. */
  31608. setVisibilityBox(size: number): void;
  31609. /**
  31610. * Gets whether the SPS as always visible or not
  31611. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31612. */
  31613. get isAlwaysVisible(): boolean;
  31614. /**
  31615. * Sets the SPS as always visible or not
  31616. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31617. */
  31618. set isAlwaysVisible(val: boolean);
  31619. /**
  31620. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31621. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31622. */
  31623. set isVisibilityBoxLocked(val: boolean);
  31624. /**
  31625. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31626. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31627. */
  31628. get isVisibilityBoxLocked(): boolean;
  31629. /**
  31630. * Tells to `setParticles()` to compute the particle rotations or not.
  31631. * Default value : true. The SPS is faster when it's set to false.
  31632. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31633. */
  31634. set computeParticleRotation(val: boolean);
  31635. /**
  31636. * Tells to `setParticles()` to compute the particle colors or not.
  31637. * Default value : true. The SPS is faster when it's set to false.
  31638. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31639. */
  31640. set computeParticleColor(val: boolean);
  31641. set computeParticleTexture(val: boolean);
  31642. /**
  31643. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31644. * Default value : false. The SPS is faster when it's set to false.
  31645. * Note : the particle custom vertex positions aren't stored values.
  31646. */
  31647. set computeParticleVertex(val: boolean);
  31648. /**
  31649. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31650. */
  31651. set computeBoundingBox(val: boolean);
  31652. /**
  31653. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31654. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31655. * Default : `true`
  31656. */
  31657. set depthSortParticles(val: boolean);
  31658. /**
  31659. * Gets if `setParticles()` computes the particle rotations or not.
  31660. * Default value : true. The SPS is faster when it's set to false.
  31661. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31662. */
  31663. get computeParticleRotation(): boolean;
  31664. /**
  31665. * Gets if `setParticles()` computes the particle colors or not.
  31666. * Default value : true. The SPS is faster when it's set to false.
  31667. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31668. */
  31669. get computeParticleColor(): boolean;
  31670. /**
  31671. * Gets if `setParticles()` computes the particle textures or not.
  31672. * Default value : true. The SPS is faster when it's set to false.
  31673. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31674. */
  31675. get computeParticleTexture(): boolean;
  31676. /**
  31677. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31678. * Default value : false. The SPS is faster when it's set to false.
  31679. * Note : the particle custom vertex positions aren't stored values.
  31680. */
  31681. get computeParticleVertex(): boolean;
  31682. /**
  31683. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31684. */
  31685. get computeBoundingBox(): boolean;
  31686. /**
  31687. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31688. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31689. * Default : `true`
  31690. */
  31691. get depthSortParticles(): boolean;
  31692. /**
  31693. * Gets if the SPS is created as expandable at construction time.
  31694. * Default : `false`
  31695. */
  31696. get expandable(): boolean;
  31697. /**
  31698. * Gets if the SPS supports the Multi Materials
  31699. */
  31700. get multimaterialEnabled(): boolean;
  31701. /**
  31702. * Gets if the SPS uses the model materials for its own multimaterial.
  31703. */
  31704. get useModelMaterial(): boolean;
  31705. /**
  31706. * The SPS used material array.
  31707. */
  31708. get materials(): Material[];
  31709. /**
  31710. * Sets the SPS MultiMaterial from the passed materials.
  31711. * Note : the passed array is internally copied and not used then by reference.
  31712. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31713. */
  31714. setMultiMaterial(materials: Material[]): void;
  31715. /**
  31716. * The SPS computed multimaterial object
  31717. */
  31718. get multimaterial(): MultiMaterial;
  31719. set multimaterial(mm: MultiMaterial);
  31720. /**
  31721. * If the subMeshes must be updated on the next call to setParticles()
  31722. */
  31723. get autoUpdateSubMeshes(): boolean;
  31724. set autoUpdateSubMeshes(val: boolean);
  31725. /**
  31726. * This function does nothing. It may be overwritten to set all the particle first values.
  31727. * The SPS doesn't call this function, you may have to call it by your own.
  31728. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31729. */
  31730. initParticles(): void;
  31731. /**
  31732. * This function does nothing. It may be overwritten to recycle a particle.
  31733. * The SPS doesn't call this function, you may have to call it by your own.
  31734. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31735. * @param particle The particle to recycle
  31736. * @returns the recycled particle
  31737. */
  31738. recycleParticle(particle: SolidParticle): SolidParticle;
  31739. /**
  31740. * Updates a particle : this function should be overwritten by the user.
  31741. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31742. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31743. * @example : just set a particle position or velocity and recycle conditions
  31744. * @param particle The particle to update
  31745. * @returns the updated particle
  31746. */
  31747. updateParticle(particle: SolidParticle): SolidParticle;
  31748. /**
  31749. * Updates a vertex of a particle : it can be overwritten by the user.
  31750. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31751. * @param particle the current particle
  31752. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31753. * @param pt the index of the current vertex in the particle shape
  31754. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31755. * @example : just set a vertex particle position or color
  31756. * @returns the sps
  31757. */
  31758. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31759. /**
  31760. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31761. * This does nothing and may be overwritten by the user.
  31762. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31763. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31764. * @param update the boolean update value actually passed to setParticles()
  31765. */
  31766. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31767. /**
  31768. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31769. * This will be passed three parameters.
  31770. * This does nothing and may be overwritten by the user.
  31771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31773. * @param update the boolean update value actually passed to setParticles()
  31774. */
  31775. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31776. }
  31777. }
  31778. declare module BABYLON {
  31779. /**
  31780. * Represents one particle of a solid particle system.
  31781. */
  31782. export class SolidParticle {
  31783. /**
  31784. * particle global index
  31785. */
  31786. idx: number;
  31787. /**
  31788. * particle identifier
  31789. */
  31790. id: number;
  31791. /**
  31792. * The color of the particle
  31793. */
  31794. color: Nullable<Color4>;
  31795. /**
  31796. * The world space position of the particle.
  31797. */
  31798. position: Vector3;
  31799. /**
  31800. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31801. */
  31802. rotation: Vector3;
  31803. /**
  31804. * The world space rotation quaternion of the particle.
  31805. */
  31806. rotationQuaternion: Nullable<Quaternion>;
  31807. /**
  31808. * The scaling of the particle.
  31809. */
  31810. scaling: Vector3;
  31811. /**
  31812. * The uvs of the particle.
  31813. */
  31814. uvs: Vector4;
  31815. /**
  31816. * The current speed of the particle.
  31817. */
  31818. velocity: Vector3;
  31819. /**
  31820. * The pivot point in the particle local space.
  31821. */
  31822. pivot: Vector3;
  31823. /**
  31824. * Must the particle be translated from its pivot point in its local space ?
  31825. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31826. * Default : false
  31827. */
  31828. translateFromPivot: boolean;
  31829. /**
  31830. * Is the particle active or not ?
  31831. */
  31832. alive: boolean;
  31833. /**
  31834. * Is the particle visible or not ?
  31835. */
  31836. isVisible: boolean;
  31837. /**
  31838. * Index of this particle in the global "positions" array (Internal use)
  31839. * @hidden
  31840. */
  31841. _pos: number;
  31842. /**
  31843. * @hidden Index of this particle in the global "indices" array (Internal use)
  31844. */
  31845. _ind: number;
  31846. /**
  31847. * @hidden ModelShape of this particle (Internal use)
  31848. */
  31849. _model: ModelShape;
  31850. /**
  31851. * ModelShape id of this particle
  31852. */
  31853. shapeId: number;
  31854. /**
  31855. * Index of the particle in its shape id
  31856. */
  31857. idxInShape: number;
  31858. /**
  31859. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31860. */
  31861. _modelBoundingInfo: BoundingInfo;
  31862. /**
  31863. * @hidden Particle BoundingInfo object (Internal use)
  31864. */
  31865. _boundingInfo: BoundingInfo;
  31866. /**
  31867. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31868. */
  31869. _sps: SolidParticleSystem;
  31870. /**
  31871. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31872. */
  31873. _stillInvisible: boolean;
  31874. /**
  31875. * @hidden Last computed particle rotation matrix
  31876. */
  31877. _rotationMatrix: number[];
  31878. /**
  31879. * Parent particle Id, if any.
  31880. * Default null.
  31881. */
  31882. parentId: Nullable<number>;
  31883. /**
  31884. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31885. */
  31886. materialIndex: Nullable<number>;
  31887. /**
  31888. * Custom object or properties.
  31889. */
  31890. props: Nullable<any>;
  31891. /**
  31892. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31893. * The possible values are :
  31894. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31895. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31896. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31897. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31898. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31899. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31900. * */
  31901. cullingStrategy: number;
  31902. /**
  31903. * @hidden Internal global position in the SPS.
  31904. */
  31905. _globalPosition: Vector3;
  31906. /**
  31907. * Creates a Solid Particle object.
  31908. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31909. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31910. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31911. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31912. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31913. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31914. * @param shapeId (integer) is the model shape identifier in the SPS.
  31915. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31916. * @param sps defines the sps it is associated to
  31917. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31918. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31919. */
  31920. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31921. /**
  31922. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31923. * @param target the particle target
  31924. * @returns the current particle
  31925. */
  31926. copyToRef(target: SolidParticle): SolidParticle;
  31927. /**
  31928. * Legacy support, changed scale to scaling
  31929. */
  31930. get scale(): Vector3;
  31931. /**
  31932. * Legacy support, changed scale to scaling
  31933. */
  31934. set scale(scale: Vector3);
  31935. /**
  31936. * Legacy support, changed quaternion to rotationQuaternion
  31937. */
  31938. get quaternion(): Nullable<Quaternion>;
  31939. /**
  31940. * Legacy support, changed quaternion to rotationQuaternion
  31941. */
  31942. set quaternion(q: Nullable<Quaternion>);
  31943. /**
  31944. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31945. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31946. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31947. * @returns true if it intersects
  31948. */
  31949. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31950. /**
  31951. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31952. * A particle is in the frustum if its bounding box intersects the frustum
  31953. * @param frustumPlanes defines the frustum to test
  31954. * @returns true if the particle is in the frustum planes
  31955. */
  31956. isInFrustum(frustumPlanes: Plane[]): boolean;
  31957. /**
  31958. * get the rotation matrix of the particle
  31959. * @hidden
  31960. */
  31961. getRotationMatrix(m: Matrix): void;
  31962. }
  31963. /**
  31964. * Represents the shape of the model used by one particle of a solid particle system.
  31965. * SPS internal tool, don't use it manually.
  31966. */
  31967. export class ModelShape {
  31968. /**
  31969. * The shape id
  31970. * @hidden
  31971. */
  31972. shapeID: number;
  31973. /**
  31974. * flat array of model positions (internal use)
  31975. * @hidden
  31976. */
  31977. _shape: Vector3[];
  31978. /**
  31979. * flat array of model UVs (internal use)
  31980. * @hidden
  31981. */
  31982. _shapeUV: number[];
  31983. /**
  31984. * color array of the model
  31985. * @hidden
  31986. */
  31987. _shapeColors: number[];
  31988. /**
  31989. * indices array of the model
  31990. * @hidden
  31991. */
  31992. _indices: number[];
  31993. /**
  31994. * normals array of the model
  31995. * @hidden
  31996. */
  31997. _normals: number[];
  31998. /**
  31999. * length of the shape in the model indices array (internal use)
  32000. * @hidden
  32001. */
  32002. _indicesLength: number;
  32003. /**
  32004. * Custom position function (internal use)
  32005. * @hidden
  32006. */
  32007. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  32008. /**
  32009. * Custom vertex function (internal use)
  32010. * @hidden
  32011. */
  32012. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  32013. /**
  32014. * Model material (internal use)
  32015. * @hidden
  32016. */
  32017. _material: Nullable<Material>;
  32018. /**
  32019. * 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.
  32020. * SPS internal tool, don't use it manually.
  32021. * @hidden
  32022. */
  32023. 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>);
  32024. }
  32025. /**
  32026. * Represents a Depth Sorted Particle in the solid particle system.
  32027. * @hidden
  32028. */
  32029. export class DepthSortedParticle {
  32030. /**
  32031. * Particle index
  32032. */
  32033. idx: number;
  32034. /**
  32035. * Index of the particle in the "indices" array
  32036. */
  32037. ind: number;
  32038. /**
  32039. * Length of the particle shape in the "indices" array
  32040. */
  32041. indicesLength: number;
  32042. /**
  32043. * Squared distance from the particle to the camera
  32044. */
  32045. sqDistance: number;
  32046. /**
  32047. * Material index when used with MultiMaterials
  32048. */
  32049. materialIndex: number;
  32050. /**
  32051. * Creates a new sorted particle
  32052. * @param materialIndex
  32053. */
  32054. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32055. }
  32056. /**
  32057. * Represents a solid particle vertex
  32058. */
  32059. export class SolidParticleVertex {
  32060. /**
  32061. * Vertex position
  32062. */
  32063. position: Vector3;
  32064. /**
  32065. * Vertex color
  32066. */
  32067. color: Color4;
  32068. /**
  32069. * Vertex UV
  32070. */
  32071. uv: Vector2;
  32072. /**
  32073. * Creates a new solid particle vertex
  32074. */
  32075. constructor();
  32076. /** Vertex x coordinate */
  32077. get x(): number;
  32078. set x(val: number);
  32079. /** Vertex y coordinate */
  32080. get y(): number;
  32081. set y(val: number);
  32082. /** Vertex z coordinate */
  32083. get z(): number;
  32084. set z(val: number);
  32085. }
  32086. }
  32087. declare module BABYLON {
  32088. /**
  32089. * @hidden
  32090. */
  32091. export class _MeshCollisionData {
  32092. _checkCollisions: boolean;
  32093. _collisionMask: number;
  32094. _collisionGroup: number;
  32095. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32096. _collider: Nullable<Collider>;
  32097. _oldPositionForCollisions: Vector3;
  32098. _diffPositionForCollisions: Vector3;
  32099. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32100. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32101. _collisionResponse: boolean;
  32102. }
  32103. }
  32104. declare module BABYLON {
  32105. /** @hidden */
  32106. class _FacetDataStorage {
  32107. facetPositions: Vector3[];
  32108. facetNormals: Vector3[];
  32109. facetPartitioning: number[][];
  32110. facetNb: number;
  32111. partitioningSubdivisions: number;
  32112. partitioningBBoxRatio: number;
  32113. facetDataEnabled: boolean;
  32114. facetParameters: any;
  32115. bbSize: Vector3;
  32116. subDiv: {
  32117. max: number;
  32118. X: number;
  32119. Y: number;
  32120. Z: number;
  32121. };
  32122. facetDepthSort: boolean;
  32123. facetDepthSortEnabled: boolean;
  32124. depthSortedIndices: IndicesArray;
  32125. depthSortedFacets: {
  32126. ind: number;
  32127. sqDistance: number;
  32128. }[];
  32129. facetDepthSortFunction: (f1: {
  32130. ind: number;
  32131. sqDistance: number;
  32132. }, f2: {
  32133. ind: number;
  32134. sqDistance: number;
  32135. }) => number;
  32136. facetDepthSortFrom: Vector3;
  32137. facetDepthSortOrigin: Vector3;
  32138. invertedMatrix: Matrix;
  32139. }
  32140. /**
  32141. * @hidden
  32142. **/
  32143. class _InternalAbstractMeshDataInfo {
  32144. _hasVertexAlpha: boolean;
  32145. _useVertexColors: boolean;
  32146. _numBoneInfluencers: number;
  32147. _applyFog: boolean;
  32148. _receiveShadows: boolean;
  32149. _facetData: _FacetDataStorage;
  32150. _visibility: number;
  32151. _skeleton: Nullable<Skeleton>;
  32152. _layerMask: number;
  32153. _computeBonesUsingShaders: boolean;
  32154. _isActive: boolean;
  32155. _onlyForInstances: boolean;
  32156. _isActiveIntermediate: boolean;
  32157. _onlyForInstancesIntermediate: boolean;
  32158. _actAsRegularMesh: boolean;
  32159. }
  32160. /**
  32161. * Class used to store all common mesh properties
  32162. */
  32163. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32164. /** No occlusion */
  32165. static OCCLUSION_TYPE_NONE: number;
  32166. /** Occlusion set to optimisitic */
  32167. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32168. /** Occlusion set to strict */
  32169. static OCCLUSION_TYPE_STRICT: number;
  32170. /** Use an accurante occlusion algorithm */
  32171. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32172. /** Use a conservative occlusion algorithm */
  32173. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32174. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32175. * Test order :
  32176. * Is the bounding sphere outside the frustum ?
  32177. * If not, are the bounding box vertices outside the frustum ?
  32178. * It not, then the cullable object is in the frustum.
  32179. */
  32180. static readonly CULLINGSTRATEGY_STANDARD: number;
  32181. /** Culling strategy : Bounding Sphere Only.
  32182. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32183. * It's also less accurate than the standard because some not visible objects can still be selected.
  32184. * Test : is the bounding sphere outside the frustum ?
  32185. * If not, then the cullable object is in the frustum.
  32186. */
  32187. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32188. /** Culling strategy : Optimistic Inclusion.
  32189. * This in an inclusion test first, then the standard exclusion test.
  32190. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32191. * 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.
  32192. * Anyway, it's as accurate as the standard strategy.
  32193. * Test :
  32194. * Is the cullable object bounding sphere center in the frustum ?
  32195. * If not, apply the default culling strategy.
  32196. */
  32197. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32198. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32199. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32200. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32201. * 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.
  32202. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32203. * Test :
  32204. * Is the cullable object bounding sphere center in the frustum ?
  32205. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32206. */
  32207. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32208. /**
  32209. * No billboard
  32210. */
  32211. static get BILLBOARDMODE_NONE(): number;
  32212. /** Billboard on X axis */
  32213. static get BILLBOARDMODE_X(): number;
  32214. /** Billboard on Y axis */
  32215. static get BILLBOARDMODE_Y(): number;
  32216. /** Billboard on Z axis */
  32217. static get BILLBOARDMODE_Z(): number;
  32218. /** Billboard on all axes */
  32219. static get BILLBOARDMODE_ALL(): number;
  32220. /** Billboard on using position instead of orientation */
  32221. static get BILLBOARDMODE_USE_POSITION(): number;
  32222. /** @hidden */
  32223. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32224. /**
  32225. * The culling strategy to use to check whether the mesh must be rendered or not.
  32226. * This value can be changed at any time and will be used on the next render mesh selection.
  32227. * The possible values are :
  32228. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32229. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32231. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32232. * Please read each static variable documentation to get details about the culling process.
  32233. * */
  32234. cullingStrategy: number;
  32235. /**
  32236. * Gets the number of facets in the mesh
  32237. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32238. */
  32239. get facetNb(): number;
  32240. /**
  32241. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32242. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32243. */
  32244. get partitioningSubdivisions(): number;
  32245. set partitioningSubdivisions(nb: number);
  32246. /**
  32247. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32248. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32249. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32250. */
  32251. get partitioningBBoxRatio(): number;
  32252. set partitioningBBoxRatio(ratio: number);
  32253. /**
  32254. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32255. * Works only for updatable meshes.
  32256. * Doesn't work with multi-materials
  32257. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32258. */
  32259. get mustDepthSortFacets(): boolean;
  32260. set mustDepthSortFacets(sort: boolean);
  32261. /**
  32262. * The location (Vector3) where the facet depth sort must be computed from.
  32263. * By default, the active camera position.
  32264. * Used only when facet depth sort is enabled
  32265. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32266. */
  32267. get facetDepthSortFrom(): Vector3;
  32268. set facetDepthSortFrom(location: Vector3);
  32269. /**
  32270. * gets a boolean indicating if facetData is enabled
  32271. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32272. */
  32273. get isFacetDataEnabled(): boolean;
  32274. /** @hidden */
  32275. _updateNonUniformScalingState(value: boolean): boolean;
  32276. /**
  32277. * An event triggered when this mesh collides with another one
  32278. */
  32279. onCollideObservable: Observable<AbstractMesh>;
  32280. /** Set a function to call when this mesh collides with another one */
  32281. set onCollide(callback: () => void);
  32282. /**
  32283. * An event triggered when the collision's position changes
  32284. */
  32285. onCollisionPositionChangeObservable: Observable<Vector3>;
  32286. /** Set a function to call when the collision's position changes */
  32287. set onCollisionPositionChange(callback: () => void);
  32288. /**
  32289. * An event triggered when material is changed
  32290. */
  32291. onMaterialChangedObservable: Observable<AbstractMesh>;
  32292. /**
  32293. * Gets or sets the orientation for POV movement & rotation
  32294. */
  32295. definedFacingForward: boolean;
  32296. /** @hidden */
  32297. _occlusionQuery: Nullable<WebGLQuery>;
  32298. /** @hidden */
  32299. _renderingGroup: Nullable<RenderingGroup>;
  32300. /**
  32301. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32302. */
  32303. get visibility(): number;
  32304. /**
  32305. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32306. */
  32307. set visibility(value: number);
  32308. /** Gets or sets the alpha index used to sort transparent meshes
  32309. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32310. */
  32311. alphaIndex: number;
  32312. /**
  32313. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32314. */
  32315. isVisible: boolean;
  32316. /**
  32317. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32318. */
  32319. isPickable: boolean;
  32320. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32321. showSubMeshesBoundingBox: boolean;
  32322. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32323. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32324. */
  32325. isBlocker: boolean;
  32326. /**
  32327. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32328. */
  32329. enablePointerMoveEvents: boolean;
  32330. private _renderingGroupId;
  32331. /**
  32332. * Specifies the rendering group id for this mesh (0 by default)
  32333. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32334. */
  32335. get renderingGroupId(): number;
  32336. set renderingGroupId(value: number);
  32337. private _material;
  32338. /** Gets or sets current material */
  32339. get material(): Nullable<Material>;
  32340. set material(value: Nullable<Material>);
  32341. /**
  32342. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32343. * @see https://doc.babylonjs.com/babylon101/shadows
  32344. */
  32345. get receiveShadows(): boolean;
  32346. set receiveShadows(value: boolean);
  32347. /** Defines color to use when rendering outline */
  32348. outlineColor: Color3;
  32349. /** Define width to use when rendering outline */
  32350. outlineWidth: number;
  32351. /** Defines color to use when rendering overlay */
  32352. overlayColor: Color3;
  32353. /** Defines alpha to use when rendering overlay */
  32354. overlayAlpha: number;
  32355. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32356. get hasVertexAlpha(): boolean;
  32357. set hasVertexAlpha(value: boolean);
  32358. /** 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) */
  32359. get useVertexColors(): boolean;
  32360. set useVertexColors(value: boolean);
  32361. /**
  32362. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32363. */
  32364. get computeBonesUsingShaders(): boolean;
  32365. set computeBonesUsingShaders(value: boolean);
  32366. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32367. get numBoneInfluencers(): number;
  32368. set numBoneInfluencers(value: number);
  32369. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32370. get applyFog(): boolean;
  32371. set applyFog(value: boolean);
  32372. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32373. useOctreeForRenderingSelection: boolean;
  32374. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32375. useOctreeForPicking: boolean;
  32376. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32377. useOctreeForCollisions: boolean;
  32378. /**
  32379. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32380. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32381. */
  32382. get layerMask(): number;
  32383. set layerMask(value: number);
  32384. /**
  32385. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32386. */
  32387. alwaysSelectAsActiveMesh: boolean;
  32388. /**
  32389. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32390. */
  32391. doNotSyncBoundingInfo: boolean;
  32392. /**
  32393. * Gets or sets the current action manager
  32394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32395. */
  32396. actionManager: Nullable<AbstractActionManager>;
  32397. private _meshCollisionData;
  32398. /**
  32399. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32400. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32401. */
  32402. ellipsoid: Vector3;
  32403. /**
  32404. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32405. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32406. */
  32407. ellipsoidOffset: Vector3;
  32408. /**
  32409. * Gets or sets a collision mask used to mask collisions (default is -1).
  32410. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32411. */
  32412. get collisionMask(): number;
  32413. set collisionMask(mask: number);
  32414. /**
  32415. * Gets or sets a collision response flag (default is true).
  32416. * when collisionResponse is false, events are still triggered but colliding entity has no response
  32417. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  32418. * to respond to the collision.
  32419. */
  32420. get collisionResponse(): boolean;
  32421. set collisionResponse(response: boolean);
  32422. /**
  32423. * Gets or sets the current collision group mask (-1 by default).
  32424. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32425. */
  32426. get collisionGroup(): number;
  32427. set collisionGroup(mask: number);
  32428. /**
  32429. * Gets or sets current surrounding meshes (null by default).
  32430. *
  32431. * By default collision detection is tested against every mesh in the scene.
  32432. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32433. * meshes will be tested for the collision.
  32434. *
  32435. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32436. */
  32437. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32438. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32439. /**
  32440. * Defines edge width used when edgesRenderer is enabled
  32441. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32442. */
  32443. edgesWidth: number;
  32444. /**
  32445. * Defines edge color used when edgesRenderer is enabled
  32446. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32447. */
  32448. edgesColor: Color4;
  32449. /** @hidden */
  32450. _edgesRenderer: Nullable<IEdgesRenderer>;
  32451. /** @hidden */
  32452. _masterMesh: Nullable<AbstractMesh>;
  32453. /** @hidden */
  32454. _boundingInfo: Nullable<BoundingInfo>;
  32455. /** @hidden */
  32456. _renderId: number;
  32457. /**
  32458. * Gets or sets the list of subMeshes
  32459. * @see https://doc.babylonjs.com/how_to/multi_materials
  32460. */
  32461. subMeshes: SubMesh[];
  32462. /** @hidden */
  32463. _intersectionsInProgress: AbstractMesh[];
  32464. /** @hidden */
  32465. _unIndexed: boolean;
  32466. /** @hidden */
  32467. _lightSources: Light[];
  32468. /** Gets the list of lights affecting that mesh */
  32469. get lightSources(): Light[];
  32470. /** @hidden */
  32471. get _positions(): Nullable<Vector3[]>;
  32472. /** @hidden */
  32473. _waitingData: {
  32474. lods: Nullable<any>;
  32475. actions: Nullable<any>;
  32476. freezeWorldMatrix: Nullable<boolean>;
  32477. };
  32478. /** @hidden */
  32479. _bonesTransformMatrices: Nullable<Float32Array>;
  32480. /** @hidden */
  32481. _transformMatrixTexture: Nullable<RawTexture>;
  32482. /**
  32483. * Gets or sets a skeleton to apply skining transformations
  32484. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32485. */
  32486. set skeleton(value: Nullable<Skeleton>);
  32487. get skeleton(): Nullable<Skeleton>;
  32488. /**
  32489. * An event triggered when the mesh is rebuilt.
  32490. */
  32491. onRebuildObservable: Observable<AbstractMesh>;
  32492. /**
  32493. * Creates a new AbstractMesh
  32494. * @param name defines the name of the mesh
  32495. * @param scene defines the hosting scene
  32496. */
  32497. constructor(name: string, scene?: Nullable<Scene>);
  32498. /**
  32499. * Returns the string "AbstractMesh"
  32500. * @returns "AbstractMesh"
  32501. */
  32502. getClassName(): string;
  32503. /**
  32504. * Gets a string representation of the current mesh
  32505. * @param fullDetails defines a boolean indicating if full details must be included
  32506. * @returns a string representation of the current mesh
  32507. */
  32508. toString(fullDetails?: boolean): string;
  32509. /**
  32510. * @hidden
  32511. */
  32512. protected _getEffectiveParent(): Nullable<Node>;
  32513. /** @hidden */
  32514. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32515. /** @hidden */
  32516. _rebuild(): void;
  32517. /** @hidden */
  32518. _resyncLightSources(): void;
  32519. /** @hidden */
  32520. _resyncLightSource(light: Light): void;
  32521. /** @hidden */
  32522. _unBindEffect(): void;
  32523. /** @hidden */
  32524. _removeLightSource(light: Light, dispose: boolean): void;
  32525. private _markSubMeshesAsDirty;
  32526. /** @hidden */
  32527. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32528. /** @hidden */
  32529. _markSubMeshesAsAttributesDirty(): void;
  32530. /** @hidden */
  32531. _markSubMeshesAsMiscDirty(): void;
  32532. /**
  32533. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32534. */
  32535. get scaling(): Vector3;
  32536. set scaling(newScaling: Vector3);
  32537. /**
  32538. * Returns true if the mesh is blocked. Implemented by child classes
  32539. */
  32540. get isBlocked(): boolean;
  32541. /**
  32542. * Returns the mesh itself by default. Implemented by child classes
  32543. * @param camera defines the camera to use to pick the right LOD level
  32544. * @returns the currentAbstractMesh
  32545. */
  32546. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32547. /**
  32548. * Returns 0 by default. Implemented by child classes
  32549. * @returns an integer
  32550. */
  32551. getTotalVertices(): number;
  32552. /**
  32553. * Returns a positive integer : the total number of indices in this mesh geometry.
  32554. * @returns the numner of indices or zero if the mesh has no geometry.
  32555. */
  32556. getTotalIndices(): number;
  32557. /**
  32558. * Returns null by default. Implemented by child classes
  32559. * @returns null
  32560. */
  32561. getIndices(): Nullable<IndicesArray>;
  32562. /**
  32563. * Returns the array of the requested vertex data kind. Implemented by child classes
  32564. * @param kind defines the vertex data kind to use
  32565. * @returns null
  32566. */
  32567. getVerticesData(kind: string): Nullable<FloatArray>;
  32568. /**
  32569. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32570. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32571. * Note that a new underlying VertexBuffer object is created each call.
  32572. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32573. * @param kind defines vertex data kind:
  32574. * * VertexBuffer.PositionKind
  32575. * * VertexBuffer.UVKind
  32576. * * VertexBuffer.UV2Kind
  32577. * * VertexBuffer.UV3Kind
  32578. * * VertexBuffer.UV4Kind
  32579. * * VertexBuffer.UV5Kind
  32580. * * VertexBuffer.UV6Kind
  32581. * * VertexBuffer.ColorKind
  32582. * * VertexBuffer.MatricesIndicesKind
  32583. * * VertexBuffer.MatricesIndicesExtraKind
  32584. * * VertexBuffer.MatricesWeightsKind
  32585. * * VertexBuffer.MatricesWeightsExtraKind
  32586. * @param data defines the data source
  32587. * @param updatable defines if the data must be flagged as updatable (or static)
  32588. * @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
  32589. * @returns the current mesh
  32590. */
  32591. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32592. /**
  32593. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32594. * If the mesh has no geometry, it is simply returned as it is.
  32595. * @param kind defines vertex data kind:
  32596. * * VertexBuffer.PositionKind
  32597. * * VertexBuffer.UVKind
  32598. * * VertexBuffer.UV2Kind
  32599. * * VertexBuffer.UV3Kind
  32600. * * VertexBuffer.UV4Kind
  32601. * * VertexBuffer.UV5Kind
  32602. * * VertexBuffer.UV6Kind
  32603. * * VertexBuffer.ColorKind
  32604. * * VertexBuffer.MatricesIndicesKind
  32605. * * VertexBuffer.MatricesIndicesExtraKind
  32606. * * VertexBuffer.MatricesWeightsKind
  32607. * * VertexBuffer.MatricesWeightsExtraKind
  32608. * @param data defines the data source
  32609. * @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
  32610. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32611. * @returns the current mesh
  32612. */
  32613. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32614. /**
  32615. * Sets the mesh indices,
  32616. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32617. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32618. * @param totalVertices Defines the total number of vertices
  32619. * @returns the current mesh
  32620. */
  32621. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32622. /**
  32623. * Gets a boolean indicating if specific vertex data is present
  32624. * @param kind defines the vertex data kind to use
  32625. * @returns true is data kind is present
  32626. */
  32627. isVerticesDataPresent(kind: string): boolean;
  32628. /**
  32629. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32630. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32631. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32632. * @returns a BoundingInfo
  32633. */
  32634. getBoundingInfo(): BoundingInfo;
  32635. /**
  32636. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32637. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32638. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32639. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32640. * @returns the current mesh
  32641. */
  32642. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32643. /**
  32644. * Overwrite the current bounding info
  32645. * @param boundingInfo defines the new bounding info
  32646. * @returns the current mesh
  32647. */
  32648. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32649. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32650. get useBones(): boolean;
  32651. /** @hidden */
  32652. _preActivate(): void;
  32653. /** @hidden */
  32654. _preActivateForIntermediateRendering(renderId: number): void;
  32655. /** @hidden */
  32656. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32657. /** @hidden */
  32658. _postActivate(): void;
  32659. /** @hidden */
  32660. _freeze(): void;
  32661. /** @hidden */
  32662. _unFreeze(): void;
  32663. /**
  32664. * Gets the current world matrix
  32665. * @returns a Matrix
  32666. */
  32667. getWorldMatrix(): Matrix;
  32668. /** @hidden */
  32669. _getWorldMatrixDeterminant(): number;
  32670. /**
  32671. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32672. */
  32673. get isAnInstance(): boolean;
  32674. /**
  32675. * Gets a boolean indicating if this mesh has instances
  32676. */
  32677. get hasInstances(): boolean;
  32678. /**
  32679. * Gets a boolean indicating if this mesh has thin instances
  32680. */
  32681. get hasThinInstances(): boolean;
  32682. /**
  32683. * Perform relative position change from the point of view of behind the front of the mesh.
  32684. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32685. * Supports definition of mesh facing forward or backward
  32686. * @param amountRight defines the distance on the right axis
  32687. * @param amountUp defines the distance on the up axis
  32688. * @param amountForward defines the distance on the forward axis
  32689. * @returns the current mesh
  32690. */
  32691. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32692. /**
  32693. * Calculate relative position change from the point of view of behind the front of the mesh.
  32694. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32695. * Supports definition of mesh facing forward or backward
  32696. * @param amountRight defines the distance on the right axis
  32697. * @param amountUp defines the distance on the up axis
  32698. * @param amountForward defines the distance on the forward axis
  32699. * @returns the new displacement vector
  32700. */
  32701. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32702. /**
  32703. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32704. * Supports definition of mesh facing forward or backward
  32705. * @param flipBack defines the flip
  32706. * @param twirlClockwise defines the twirl
  32707. * @param tiltRight defines the tilt
  32708. * @returns the current mesh
  32709. */
  32710. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32711. /**
  32712. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32713. * Supports definition of mesh facing forward or backward.
  32714. * @param flipBack defines the flip
  32715. * @param twirlClockwise defines the twirl
  32716. * @param tiltRight defines the tilt
  32717. * @returns the new rotation vector
  32718. */
  32719. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32720. /**
  32721. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32722. * This means the mesh underlying bounding box and sphere are recomputed.
  32723. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32724. * @returns the current mesh
  32725. */
  32726. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32727. /** @hidden */
  32728. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32729. /** @hidden */
  32730. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32731. /** @hidden */
  32732. _updateBoundingInfo(): AbstractMesh;
  32733. /** @hidden */
  32734. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32735. /** @hidden */
  32736. protected _afterComputeWorldMatrix(): void;
  32737. /** @hidden */
  32738. get _effectiveMesh(): AbstractMesh;
  32739. /**
  32740. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32741. * A mesh is in the frustum if its bounding box intersects the frustum
  32742. * @param frustumPlanes defines the frustum to test
  32743. * @returns true if the mesh is in the frustum planes
  32744. */
  32745. isInFrustum(frustumPlanes: Plane[]): boolean;
  32746. /**
  32747. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32748. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32749. * @param frustumPlanes defines the frustum to test
  32750. * @returns true if the mesh is completely in the frustum planes
  32751. */
  32752. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32753. /**
  32754. * True if the mesh intersects another mesh or a SolidParticle object
  32755. * @param mesh defines a target mesh or SolidParticle to test
  32756. * @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)
  32757. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32758. * @returns true if there is an intersection
  32759. */
  32760. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32761. /**
  32762. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32763. * @param point defines the point to test
  32764. * @returns true if there is an intersection
  32765. */
  32766. intersectsPoint(point: Vector3): boolean;
  32767. /**
  32768. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32770. */
  32771. get checkCollisions(): boolean;
  32772. set checkCollisions(collisionEnabled: boolean);
  32773. /**
  32774. * Gets Collider object used to compute collisions (not physics)
  32775. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32776. */
  32777. get collider(): Nullable<Collider>;
  32778. /**
  32779. * Move the mesh using collision engine
  32780. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32781. * @param displacement defines the requested displacement vector
  32782. * @returns the current mesh
  32783. */
  32784. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32785. private _onCollisionPositionChange;
  32786. /** @hidden */
  32787. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32788. /** @hidden */
  32789. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32790. /** @hidden */
  32791. _checkCollision(collider: Collider): AbstractMesh;
  32792. /** @hidden */
  32793. _generatePointsArray(): boolean;
  32794. /**
  32795. * Checks if the passed Ray intersects with the mesh
  32796. * @param ray defines the ray to use
  32797. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32798. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32799. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32800. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  32801. * @returns the picking info
  32802. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32803. */
  32804. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  32805. /**
  32806. * Clones the current mesh
  32807. * @param name defines the mesh name
  32808. * @param newParent defines the new mesh parent
  32809. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32810. * @returns the new mesh
  32811. */
  32812. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32813. /**
  32814. * Disposes all the submeshes of the current meshnp
  32815. * @returns the current mesh
  32816. */
  32817. releaseSubMeshes(): AbstractMesh;
  32818. /**
  32819. * Releases resources associated with this abstract mesh.
  32820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32822. */
  32823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32824. /**
  32825. * Adds the passed mesh as a child to the current mesh
  32826. * @param mesh defines the child mesh
  32827. * @returns the current mesh
  32828. */
  32829. addChild(mesh: AbstractMesh): AbstractMesh;
  32830. /**
  32831. * Removes the passed mesh from the current mesh children list
  32832. * @param mesh defines the child mesh
  32833. * @returns the current mesh
  32834. */
  32835. removeChild(mesh: AbstractMesh): AbstractMesh;
  32836. /** @hidden */
  32837. private _initFacetData;
  32838. /**
  32839. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32840. * This method can be called within the render loop.
  32841. * 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
  32842. * @returns the current mesh
  32843. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32844. */
  32845. updateFacetData(): AbstractMesh;
  32846. /**
  32847. * Returns the facetLocalNormals array.
  32848. * The normals are expressed in the mesh local spac
  32849. * @returns an array of Vector3
  32850. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32851. */
  32852. getFacetLocalNormals(): Vector3[];
  32853. /**
  32854. * Returns the facetLocalPositions array.
  32855. * The facet positions are expressed in the mesh local space
  32856. * @returns an array of Vector3
  32857. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32858. */
  32859. getFacetLocalPositions(): Vector3[];
  32860. /**
  32861. * Returns the facetLocalPartioning array
  32862. * @returns an array of array of numbers
  32863. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32864. */
  32865. getFacetLocalPartitioning(): number[][];
  32866. /**
  32867. * Returns the i-th facet position in the world system.
  32868. * This method allocates a new Vector3 per call
  32869. * @param i defines the facet index
  32870. * @returns a new Vector3
  32871. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32872. */
  32873. getFacetPosition(i: number): Vector3;
  32874. /**
  32875. * Sets the reference Vector3 with the i-th facet position in the world system
  32876. * @param i defines the facet index
  32877. * @param ref defines the target vector
  32878. * @returns the current mesh
  32879. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32880. */
  32881. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32882. /**
  32883. * Returns the i-th facet normal in the world system.
  32884. * This method allocates a new Vector3 per call
  32885. * @param i defines the facet index
  32886. * @returns a new Vector3
  32887. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32888. */
  32889. getFacetNormal(i: number): Vector3;
  32890. /**
  32891. * Sets the reference Vector3 with the i-th facet normal in the world system
  32892. * @param i defines the facet index
  32893. * @param ref defines the target vector
  32894. * @returns the current mesh
  32895. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32896. */
  32897. getFacetNormalToRef(i: number, ref: Vector3): this;
  32898. /**
  32899. * 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)
  32900. * @param x defines x coordinate
  32901. * @param y defines y coordinate
  32902. * @param z defines z coordinate
  32903. * @returns the array of facet indexes
  32904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32905. */
  32906. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32907. /**
  32908. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32909. * @param projected sets as the (x,y,z) world projection on the facet
  32910. * @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
  32911. * @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
  32912. * @param x defines x coordinate
  32913. * @param y defines y coordinate
  32914. * @param z defines z coordinate
  32915. * @returns the face index if found (or null instead)
  32916. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32917. */
  32918. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32919. /**
  32920. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32921. * @param projected sets as the (x,y,z) local projection on the facet
  32922. * @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
  32923. * @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
  32924. * @param x defines x coordinate
  32925. * @param y defines y coordinate
  32926. * @param z defines z coordinate
  32927. * @returns the face index if found (or null instead)
  32928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32929. */
  32930. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32931. /**
  32932. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32933. * @returns the parameters
  32934. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32935. */
  32936. getFacetDataParameters(): any;
  32937. /**
  32938. * Disables the feature FacetData and frees the related memory
  32939. * @returns the current mesh
  32940. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32941. */
  32942. disableFacetData(): AbstractMesh;
  32943. /**
  32944. * Updates the AbstractMesh indices array
  32945. * @param indices defines the data source
  32946. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32947. * @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)
  32948. * @returns the current mesh
  32949. */
  32950. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32951. /**
  32952. * Creates new normals data for the mesh
  32953. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32954. * @returns the current mesh
  32955. */
  32956. createNormals(updatable: boolean): AbstractMesh;
  32957. /**
  32958. * Align the mesh with a normal
  32959. * @param normal defines the normal to use
  32960. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32961. * @returns the current mesh
  32962. */
  32963. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32964. /** @hidden */
  32965. _checkOcclusionQuery(): boolean;
  32966. /**
  32967. * Disables the mesh edge rendering mode
  32968. * @returns the currentAbstractMesh
  32969. */
  32970. disableEdgesRendering(): AbstractMesh;
  32971. /**
  32972. * Enables the edge rendering mode on the mesh.
  32973. * This mode makes the mesh edges visible
  32974. * @param epsilon defines the maximal distance between two angles to detect a face
  32975. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32976. * @returns the currentAbstractMesh
  32977. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32978. */
  32979. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32980. /**
  32981. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32982. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32983. */
  32984. getConnectedParticleSystems(): IParticleSystem[];
  32985. }
  32986. }
  32987. declare module BABYLON {
  32988. /**
  32989. * Interface used to define ActionEvent
  32990. */
  32991. export interface IActionEvent {
  32992. /** The mesh or sprite that triggered the action */
  32993. source: any;
  32994. /** The X mouse cursor position at the time of the event */
  32995. pointerX: number;
  32996. /** The Y mouse cursor position at the time of the event */
  32997. pointerY: number;
  32998. /** The mesh that is currently pointed at (can be null) */
  32999. meshUnderPointer: Nullable<AbstractMesh>;
  33000. /** the original (browser) event that triggered the ActionEvent */
  33001. sourceEvent?: any;
  33002. /** additional data for the event */
  33003. additionalData?: any;
  33004. }
  33005. /**
  33006. * ActionEvent is the event being sent when an action is triggered.
  33007. */
  33008. export class ActionEvent implements IActionEvent {
  33009. /** The mesh or sprite that triggered the action */
  33010. source: any;
  33011. /** The X mouse cursor position at the time of the event */
  33012. pointerX: number;
  33013. /** The Y mouse cursor position at the time of the event */
  33014. pointerY: number;
  33015. /** The mesh that is currently pointed at (can be null) */
  33016. meshUnderPointer: Nullable<AbstractMesh>;
  33017. /** the original (browser) event that triggered the ActionEvent */
  33018. sourceEvent?: any;
  33019. /** additional data for the event */
  33020. additionalData?: any;
  33021. /**
  33022. * Creates a new ActionEvent
  33023. * @param source The mesh or sprite that triggered the action
  33024. * @param pointerX The X mouse cursor position at the time of the event
  33025. * @param pointerY The Y mouse cursor position at the time of the event
  33026. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33027. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33028. * @param additionalData additional data for the event
  33029. */
  33030. constructor(
  33031. /** The mesh or sprite that triggered the action */
  33032. source: any,
  33033. /** The X mouse cursor position at the time of the event */
  33034. pointerX: number,
  33035. /** The Y mouse cursor position at the time of the event */
  33036. pointerY: number,
  33037. /** The mesh that is currently pointed at (can be null) */
  33038. meshUnderPointer: Nullable<AbstractMesh>,
  33039. /** the original (browser) event that triggered the ActionEvent */
  33040. sourceEvent?: any,
  33041. /** additional data for the event */
  33042. additionalData?: any);
  33043. /**
  33044. * Helper function to auto-create an ActionEvent from a source mesh.
  33045. * @param source The source mesh that triggered the event
  33046. * @param evt The original (browser) event
  33047. * @param additionalData additional data for the event
  33048. * @returns the new ActionEvent
  33049. */
  33050. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33051. /**
  33052. * Helper function to auto-create an ActionEvent from a source sprite
  33053. * @param source The source sprite that triggered the event
  33054. * @param scene Scene associated with the sprite
  33055. * @param evt The original (browser) event
  33056. * @param additionalData additional data for the event
  33057. * @returns the new ActionEvent
  33058. */
  33059. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33060. /**
  33061. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33062. * @param scene the scene where the event occurred
  33063. * @param evt The original (browser) event
  33064. * @returns the new ActionEvent
  33065. */
  33066. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33067. /**
  33068. * Helper function to auto-create an ActionEvent from a primitive
  33069. * @param prim defines the target primitive
  33070. * @param pointerPos defines the pointer position
  33071. * @param evt The original (browser) event
  33072. * @param additionalData additional data for the event
  33073. * @returns the new ActionEvent
  33074. */
  33075. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33076. }
  33077. }
  33078. declare module BABYLON {
  33079. /**
  33080. * Abstract class used to decouple action Manager from scene and meshes.
  33081. * Do not instantiate.
  33082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33083. */
  33084. export abstract class AbstractActionManager implements IDisposable {
  33085. /** Gets the list of active triggers */
  33086. static Triggers: {
  33087. [key: string]: number;
  33088. };
  33089. /** Gets the cursor to use when hovering items */
  33090. hoverCursor: string;
  33091. /** Gets the list of actions */
  33092. actions: IAction[];
  33093. /**
  33094. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33095. */
  33096. isRecursive: boolean;
  33097. /**
  33098. * Releases all associated resources
  33099. */
  33100. abstract dispose(): void;
  33101. /**
  33102. * Does this action manager has pointer triggers
  33103. */
  33104. abstract get hasPointerTriggers(): boolean;
  33105. /**
  33106. * Does this action manager has pick triggers
  33107. */
  33108. abstract get hasPickTriggers(): boolean;
  33109. /**
  33110. * Process a specific trigger
  33111. * @param trigger defines the trigger to process
  33112. * @param evt defines the event details to be processed
  33113. */
  33114. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33115. /**
  33116. * Does this action manager handles actions of any of the given triggers
  33117. * @param triggers defines the triggers to be tested
  33118. * @return a boolean indicating whether one (or more) of the triggers is handled
  33119. */
  33120. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33121. /**
  33122. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33123. * speed.
  33124. * @param triggerA defines the trigger to be tested
  33125. * @param triggerB defines the trigger to be tested
  33126. * @return a boolean indicating whether one (or more) of the triggers is handled
  33127. */
  33128. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33129. /**
  33130. * Does this action manager handles actions of a given trigger
  33131. * @param trigger defines the trigger to be tested
  33132. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33133. * @return whether the trigger is handled
  33134. */
  33135. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33136. /**
  33137. * Serialize this manager to a JSON object
  33138. * @param name defines the property name to store this manager
  33139. * @returns a JSON representation of this manager
  33140. */
  33141. abstract serialize(name: string): any;
  33142. /**
  33143. * Registers an action to this action manager
  33144. * @param action defines the action to be registered
  33145. * @return the action amended (prepared) after registration
  33146. */
  33147. abstract registerAction(action: IAction): Nullable<IAction>;
  33148. /**
  33149. * Unregisters an action to this action manager
  33150. * @param action defines the action to be unregistered
  33151. * @return a boolean indicating whether the action has been unregistered
  33152. */
  33153. abstract unregisterAction(action: IAction): Boolean;
  33154. /**
  33155. * Does exist one action manager with at least one trigger
  33156. **/
  33157. static get HasTriggers(): boolean;
  33158. /**
  33159. * Does exist one action manager with at least one pick trigger
  33160. **/
  33161. static get HasPickTriggers(): boolean;
  33162. /**
  33163. * Does exist one action manager that handles actions of a given trigger
  33164. * @param trigger defines the trigger to be tested
  33165. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33166. **/
  33167. static HasSpecificTrigger(trigger: number): boolean;
  33168. }
  33169. }
  33170. declare module BABYLON {
  33171. /**
  33172. * Defines how a node can be built from a string name.
  33173. */
  33174. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33175. /**
  33176. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33177. */
  33178. export class Node implements IBehaviorAware<Node> {
  33179. /** @hidden */
  33180. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33181. private static _NodeConstructors;
  33182. /**
  33183. * Add a new node constructor
  33184. * @param type defines the type name of the node to construct
  33185. * @param constructorFunc defines the constructor function
  33186. */
  33187. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33188. /**
  33189. * Returns a node constructor based on type name
  33190. * @param type defines the type name
  33191. * @param name defines the new node name
  33192. * @param scene defines the hosting scene
  33193. * @param options defines optional options to transmit to constructors
  33194. * @returns the new constructor or null
  33195. */
  33196. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33197. /**
  33198. * Gets or sets the name of the node
  33199. */
  33200. name: string;
  33201. /**
  33202. * Gets or sets the id of the node
  33203. */
  33204. id: string;
  33205. /**
  33206. * Gets or sets the unique id of the node
  33207. */
  33208. uniqueId: number;
  33209. /**
  33210. * Gets or sets a string used to store user defined state for the node
  33211. */
  33212. state: string;
  33213. /**
  33214. * Gets or sets an object used to store user defined information for the node
  33215. */
  33216. metadata: any;
  33217. /**
  33218. * For internal use only. Please do not use.
  33219. */
  33220. reservedDataStore: any;
  33221. /**
  33222. * List of inspectable custom properties (used by the Inspector)
  33223. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33224. */
  33225. inspectableCustomProperties: IInspectable[];
  33226. private _doNotSerialize;
  33227. /**
  33228. * Gets or sets a boolean used to define if the node must be serialized
  33229. */
  33230. get doNotSerialize(): boolean;
  33231. set doNotSerialize(value: boolean);
  33232. /** @hidden */
  33233. _isDisposed: boolean;
  33234. /**
  33235. * Gets a list of Animations associated with the node
  33236. */
  33237. animations: Animation[];
  33238. protected _ranges: {
  33239. [name: string]: Nullable<AnimationRange>;
  33240. };
  33241. /**
  33242. * Callback raised when the node is ready to be used
  33243. */
  33244. onReady: Nullable<(node: Node) => void>;
  33245. private _isEnabled;
  33246. private _isParentEnabled;
  33247. private _isReady;
  33248. /** @hidden */
  33249. _currentRenderId: number;
  33250. private _parentUpdateId;
  33251. /** @hidden */
  33252. _childUpdateId: number;
  33253. /** @hidden */
  33254. _waitingParentId: Nullable<string>;
  33255. /** @hidden */
  33256. _scene: Scene;
  33257. /** @hidden */
  33258. _cache: any;
  33259. private _parentNode;
  33260. private _children;
  33261. /** @hidden */
  33262. _worldMatrix: Matrix;
  33263. /** @hidden */
  33264. _worldMatrixDeterminant: number;
  33265. /** @hidden */
  33266. _worldMatrixDeterminantIsDirty: boolean;
  33267. /** @hidden */
  33268. private _sceneRootNodesIndex;
  33269. /**
  33270. * Gets a boolean indicating if the node has been disposed
  33271. * @returns true if the node was disposed
  33272. */
  33273. isDisposed(): boolean;
  33274. /**
  33275. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33276. * @see https://doc.babylonjs.com/how_to/parenting
  33277. */
  33278. set parent(parent: Nullable<Node>);
  33279. get parent(): Nullable<Node>;
  33280. /** @hidden */
  33281. _addToSceneRootNodes(): void;
  33282. /** @hidden */
  33283. _removeFromSceneRootNodes(): void;
  33284. private _animationPropertiesOverride;
  33285. /**
  33286. * Gets or sets the animation properties override
  33287. */
  33288. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33289. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33290. /**
  33291. * Gets a string identifying the name of the class
  33292. * @returns "Node" string
  33293. */
  33294. getClassName(): string;
  33295. /** @hidden */
  33296. readonly _isNode: boolean;
  33297. /**
  33298. * An event triggered when the mesh is disposed
  33299. */
  33300. onDisposeObservable: Observable<Node>;
  33301. private _onDisposeObserver;
  33302. /**
  33303. * Sets a callback that will be raised when the node will be disposed
  33304. */
  33305. set onDispose(callback: () => void);
  33306. /**
  33307. * Creates a new Node
  33308. * @param name the name and id to be given to this node
  33309. * @param scene the scene this node will be added to
  33310. */
  33311. constructor(name: string, scene?: Nullable<Scene>);
  33312. /**
  33313. * Gets the scene of the node
  33314. * @returns a scene
  33315. */
  33316. getScene(): Scene;
  33317. /**
  33318. * Gets the engine of the node
  33319. * @returns a Engine
  33320. */
  33321. getEngine(): Engine;
  33322. private _behaviors;
  33323. /**
  33324. * Attach a behavior to the node
  33325. * @see https://doc.babylonjs.com/features/behaviour
  33326. * @param behavior defines the behavior to attach
  33327. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33328. * @returns the current Node
  33329. */
  33330. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33331. /**
  33332. * Remove an attached behavior
  33333. * @see https://doc.babylonjs.com/features/behaviour
  33334. * @param behavior defines the behavior to attach
  33335. * @returns the current Node
  33336. */
  33337. removeBehavior(behavior: Behavior<Node>): Node;
  33338. /**
  33339. * Gets the list of attached behaviors
  33340. * @see https://doc.babylonjs.com/features/behaviour
  33341. */
  33342. get behaviors(): Behavior<Node>[];
  33343. /**
  33344. * Gets an attached behavior by name
  33345. * @param name defines the name of the behavior to look for
  33346. * @see https://doc.babylonjs.com/features/behaviour
  33347. * @returns null if behavior was not found else the requested behavior
  33348. */
  33349. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33350. /**
  33351. * Returns the latest update of the World matrix
  33352. * @returns a Matrix
  33353. */
  33354. getWorldMatrix(): Matrix;
  33355. /** @hidden */
  33356. _getWorldMatrixDeterminant(): number;
  33357. /**
  33358. * Returns directly the latest state of the mesh World matrix.
  33359. * A Matrix is returned.
  33360. */
  33361. get worldMatrixFromCache(): Matrix;
  33362. /** @hidden */
  33363. _initCache(): void;
  33364. /** @hidden */
  33365. updateCache(force?: boolean): void;
  33366. /** @hidden */
  33367. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33368. /** @hidden */
  33369. _updateCache(ignoreParentClass?: boolean): void;
  33370. /** @hidden */
  33371. _isSynchronized(): boolean;
  33372. /** @hidden */
  33373. _markSyncedWithParent(): void;
  33374. /** @hidden */
  33375. isSynchronizedWithParent(): boolean;
  33376. /** @hidden */
  33377. isSynchronized(): boolean;
  33378. /**
  33379. * Is this node ready to be used/rendered
  33380. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33381. * @return true if the node is ready
  33382. */
  33383. isReady(completeCheck?: boolean): boolean;
  33384. /**
  33385. * Is this node enabled?
  33386. * 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
  33387. * @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
  33388. * @return whether this node (and its parent) is enabled
  33389. */
  33390. isEnabled(checkAncestors?: boolean): boolean;
  33391. /** @hidden */
  33392. protected _syncParentEnabledState(): void;
  33393. /**
  33394. * Set the enabled state of this node
  33395. * @param value defines the new enabled state
  33396. */
  33397. setEnabled(value: boolean): void;
  33398. /**
  33399. * Is this node a descendant of the given node?
  33400. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33401. * @param ancestor defines the parent node to inspect
  33402. * @returns a boolean indicating if this node is a descendant of the given node
  33403. */
  33404. isDescendantOf(ancestor: Node): boolean;
  33405. /** @hidden */
  33406. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33407. /**
  33408. * Will return all nodes that have this node as ascendant
  33409. * @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
  33410. * @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
  33411. * @return all children nodes of all types
  33412. */
  33413. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33414. /**
  33415. * Get all child-meshes of this node
  33416. * @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)
  33417. * @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
  33418. * @returns an array of AbstractMesh
  33419. */
  33420. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33421. /**
  33422. * Get all direct children of this node
  33423. * @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
  33424. * @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)
  33425. * @returns an array of Node
  33426. */
  33427. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33428. /** @hidden */
  33429. _setReady(state: boolean): void;
  33430. /**
  33431. * Get an animation by name
  33432. * @param name defines the name of the animation to look for
  33433. * @returns null if not found else the requested animation
  33434. */
  33435. getAnimationByName(name: string): Nullable<Animation>;
  33436. /**
  33437. * Creates an animation range for this node
  33438. * @param name defines the name of the range
  33439. * @param from defines the starting key
  33440. * @param to defines the end key
  33441. */
  33442. createAnimationRange(name: string, from: number, to: number): void;
  33443. /**
  33444. * Delete a specific animation range
  33445. * @param name defines the name of the range to delete
  33446. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33447. */
  33448. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33449. /**
  33450. * Get an animation range by name
  33451. * @param name defines the name of the animation range to look for
  33452. * @returns null if not found else the requested animation range
  33453. */
  33454. getAnimationRange(name: string): Nullable<AnimationRange>;
  33455. /**
  33456. * Gets the list of all animation ranges defined on this node
  33457. * @returns an array
  33458. */
  33459. getAnimationRanges(): Nullable<AnimationRange>[];
  33460. /**
  33461. * Will start the animation sequence
  33462. * @param name defines the range frames for animation sequence
  33463. * @param loop defines if the animation should loop (false by default)
  33464. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33465. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33466. * @returns the object created for this animation. If range does not exist, it will return null
  33467. */
  33468. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33469. /**
  33470. * Serialize animation ranges into a JSON compatible object
  33471. * @returns serialization object
  33472. */
  33473. serializeAnimationRanges(): any;
  33474. /**
  33475. * Computes the world matrix of the node
  33476. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33477. * @returns the world matrix
  33478. */
  33479. computeWorldMatrix(force?: boolean): Matrix;
  33480. /**
  33481. * Releases resources associated with this node.
  33482. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33483. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33484. */
  33485. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33486. /**
  33487. * Parse animation range data from a serialization object and store them into a given node
  33488. * @param node defines where to store the animation ranges
  33489. * @param parsedNode defines the serialization object to read data from
  33490. * @param scene defines the hosting scene
  33491. */
  33492. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33493. /**
  33494. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33495. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33496. * @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
  33497. * @returns the new bounding vectors
  33498. */
  33499. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33500. min: Vector3;
  33501. max: Vector3;
  33502. };
  33503. }
  33504. }
  33505. declare module BABYLON {
  33506. /**
  33507. * @hidden
  33508. */
  33509. export class _IAnimationState {
  33510. key: number;
  33511. repeatCount: number;
  33512. workValue?: any;
  33513. loopMode?: number;
  33514. offsetValue?: any;
  33515. highLimitValue?: any;
  33516. }
  33517. /**
  33518. * Class used to store any kind of animation
  33519. */
  33520. export class Animation {
  33521. /**Name of the animation */
  33522. name: string;
  33523. /**Property to animate */
  33524. targetProperty: string;
  33525. /**The frames per second of the animation */
  33526. framePerSecond: number;
  33527. /**The data type of the animation */
  33528. dataType: number;
  33529. /**The loop mode of the animation */
  33530. loopMode?: number | undefined;
  33531. /**Specifies if blending should be enabled */
  33532. enableBlending?: boolean | undefined;
  33533. /**
  33534. * Use matrix interpolation instead of using direct key value when animating matrices
  33535. */
  33536. static AllowMatricesInterpolation: boolean;
  33537. /**
  33538. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33539. */
  33540. static AllowMatrixDecomposeForInterpolation: boolean;
  33541. /** Define the Url to load snippets */
  33542. static SnippetUrl: string;
  33543. /** Snippet ID if the animation was created from the snippet server */
  33544. snippetId: string;
  33545. /**
  33546. * Stores the key frames of the animation
  33547. */
  33548. private _keys;
  33549. /**
  33550. * Stores the easing function of the animation
  33551. */
  33552. private _easingFunction;
  33553. /**
  33554. * @hidden Internal use only
  33555. */
  33556. _runtimeAnimations: RuntimeAnimation[];
  33557. /**
  33558. * The set of event that will be linked to this animation
  33559. */
  33560. private _events;
  33561. /**
  33562. * Stores an array of target property paths
  33563. */
  33564. targetPropertyPath: string[];
  33565. /**
  33566. * Stores the blending speed of the animation
  33567. */
  33568. blendingSpeed: number;
  33569. /**
  33570. * Stores the animation ranges for the animation
  33571. */
  33572. private _ranges;
  33573. /**
  33574. * @hidden Internal use
  33575. */
  33576. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33577. /**
  33578. * Sets up an animation
  33579. * @param property The property to animate
  33580. * @param animationType The animation type to apply
  33581. * @param framePerSecond The frames per second of the animation
  33582. * @param easingFunction The easing function used in the animation
  33583. * @returns The created animation
  33584. */
  33585. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33586. /**
  33587. * Create and start an animation on a node
  33588. * @param name defines the name of the global animation that will be run on all nodes
  33589. * @param node defines the root node where the animation will take place
  33590. * @param targetProperty defines property to animate
  33591. * @param framePerSecond defines the number of frame per second yo use
  33592. * @param totalFrame defines the number of frames in total
  33593. * @param from defines the initial value
  33594. * @param to defines the final value
  33595. * @param loopMode defines which loop mode you want to use (off by default)
  33596. * @param easingFunction defines the easing function to use (linear by default)
  33597. * @param onAnimationEnd defines the callback to call when animation end
  33598. * @returns the animatable created for this animation
  33599. */
  33600. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33601. /**
  33602. * Create and start an animation on a node and its descendants
  33603. * @param name defines the name of the global animation that will be run on all nodes
  33604. * @param node defines the root node where the animation will take place
  33605. * @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
  33606. * @param targetProperty defines property to animate
  33607. * @param framePerSecond defines the number of frame per second to use
  33608. * @param totalFrame defines the number of frames in total
  33609. * @param from defines the initial value
  33610. * @param to defines the final value
  33611. * @param loopMode defines which loop mode you want to use (off by default)
  33612. * @param easingFunction defines the easing function to use (linear by default)
  33613. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33614. * @returns the list of animatables created for all nodes
  33615. * @example https://www.babylonjs-playground.com/#MH0VLI
  33616. */
  33617. 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[]>;
  33618. /**
  33619. * Creates a new animation, merges it with the existing animations and starts it
  33620. * @param name Name of the animation
  33621. * @param node Node which contains the scene that begins the animations
  33622. * @param targetProperty Specifies which property to animate
  33623. * @param framePerSecond The frames per second of the animation
  33624. * @param totalFrame The total number of frames
  33625. * @param from The frame at the beginning of the animation
  33626. * @param to The frame at the end of the animation
  33627. * @param loopMode Specifies the loop mode of the animation
  33628. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33629. * @param onAnimationEnd Callback to run once the animation is complete
  33630. * @returns Nullable animation
  33631. */
  33632. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33633. /**
  33634. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33635. * @param sourceAnimation defines the Animation containing keyframes to convert
  33636. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33637. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33638. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33639. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33640. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33641. */
  33642. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33643. /**
  33644. * Transition property of an host to the target Value
  33645. * @param property The property to transition
  33646. * @param targetValue The target Value of the property
  33647. * @param host The object where the property to animate belongs
  33648. * @param scene Scene used to run the animation
  33649. * @param frameRate Framerate (in frame/s) to use
  33650. * @param transition The transition type we want to use
  33651. * @param duration The duration of the animation, in milliseconds
  33652. * @param onAnimationEnd Callback trigger at the end of the animation
  33653. * @returns Nullable animation
  33654. */
  33655. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33656. /**
  33657. * Return the array of runtime animations currently using this animation
  33658. */
  33659. get runtimeAnimations(): RuntimeAnimation[];
  33660. /**
  33661. * Specifies if any of the runtime animations are currently running
  33662. */
  33663. get hasRunningRuntimeAnimations(): boolean;
  33664. /**
  33665. * Initializes the animation
  33666. * @param name Name of the animation
  33667. * @param targetProperty Property to animate
  33668. * @param framePerSecond The frames per second of the animation
  33669. * @param dataType The data type of the animation
  33670. * @param loopMode The loop mode of the animation
  33671. * @param enableBlending Specifies if blending should be enabled
  33672. */
  33673. constructor(
  33674. /**Name of the animation */
  33675. name: string,
  33676. /**Property to animate */
  33677. targetProperty: string,
  33678. /**The frames per second of the animation */
  33679. framePerSecond: number,
  33680. /**The data type of the animation */
  33681. dataType: number,
  33682. /**The loop mode of the animation */
  33683. loopMode?: number | undefined,
  33684. /**Specifies if blending should be enabled */
  33685. enableBlending?: boolean | undefined);
  33686. /**
  33687. * Converts the animation to a string
  33688. * @param fullDetails support for multiple levels of logging within scene loading
  33689. * @returns String form of the animation
  33690. */
  33691. toString(fullDetails?: boolean): string;
  33692. /**
  33693. * Add an event to this animation
  33694. * @param event Event to add
  33695. */
  33696. addEvent(event: AnimationEvent): void;
  33697. /**
  33698. * Remove all events found at the given frame
  33699. * @param frame The frame to remove events from
  33700. */
  33701. removeEvents(frame: number): void;
  33702. /**
  33703. * Retrieves all the events from the animation
  33704. * @returns Events from the animation
  33705. */
  33706. getEvents(): AnimationEvent[];
  33707. /**
  33708. * Creates an animation range
  33709. * @param name Name of the animation range
  33710. * @param from Starting frame of the animation range
  33711. * @param to Ending frame of the animation
  33712. */
  33713. createRange(name: string, from: number, to: number): void;
  33714. /**
  33715. * Deletes an animation range by name
  33716. * @param name Name of the animation range to delete
  33717. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33718. */
  33719. deleteRange(name: string, deleteFrames?: boolean): void;
  33720. /**
  33721. * Gets the animation range by name, or null if not defined
  33722. * @param name Name of the animation range
  33723. * @returns Nullable animation range
  33724. */
  33725. getRange(name: string): Nullable<AnimationRange>;
  33726. /**
  33727. * Gets the key frames from the animation
  33728. * @returns The key frames of the animation
  33729. */
  33730. getKeys(): Array<IAnimationKey>;
  33731. /**
  33732. * Gets the highest frame rate of the animation
  33733. * @returns Highest frame rate of the animation
  33734. */
  33735. getHighestFrame(): number;
  33736. /**
  33737. * Gets the easing function of the animation
  33738. * @returns Easing function of the animation
  33739. */
  33740. getEasingFunction(): IEasingFunction;
  33741. /**
  33742. * Sets the easing function of the animation
  33743. * @param easingFunction A custom mathematical formula for animation
  33744. */
  33745. setEasingFunction(easingFunction: EasingFunction): void;
  33746. /**
  33747. * Interpolates a scalar linearly
  33748. * @param startValue Start value of the animation curve
  33749. * @param endValue End value of the animation curve
  33750. * @param gradient Scalar amount to interpolate
  33751. * @returns Interpolated scalar value
  33752. */
  33753. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33754. /**
  33755. * Interpolates a scalar cubically
  33756. * @param startValue Start value of the animation curve
  33757. * @param outTangent End tangent of the animation
  33758. * @param endValue End value of the animation curve
  33759. * @param inTangent Start tangent of the animation curve
  33760. * @param gradient Scalar amount to interpolate
  33761. * @returns Interpolated scalar value
  33762. */
  33763. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33764. /**
  33765. * Interpolates a quaternion using a spherical linear interpolation
  33766. * @param startValue Start value of the animation curve
  33767. * @param endValue End value of the animation curve
  33768. * @param gradient Scalar amount to interpolate
  33769. * @returns Interpolated quaternion value
  33770. */
  33771. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33772. /**
  33773. * Interpolates a quaternion cubically
  33774. * @param startValue Start value of the animation curve
  33775. * @param outTangent End tangent of the animation curve
  33776. * @param endValue End value of the animation curve
  33777. * @param inTangent Start tangent of the animation curve
  33778. * @param gradient Scalar amount to interpolate
  33779. * @returns Interpolated quaternion value
  33780. */
  33781. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33782. /**
  33783. * Interpolates a Vector3 linearl
  33784. * @param startValue Start value of the animation curve
  33785. * @param endValue End value of the animation curve
  33786. * @param gradient Scalar amount to interpolate
  33787. * @returns Interpolated scalar value
  33788. */
  33789. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33790. /**
  33791. * Interpolates a Vector3 cubically
  33792. * @param startValue Start value of the animation curve
  33793. * @param outTangent End tangent of the animation
  33794. * @param endValue End value of the animation curve
  33795. * @param inTangent Start tangent of the animation curve
  33796. * @param gradient Scalar amount to interpolate
  33797. * @returns InterpolatedVector3 value
  33798. */
  33799. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33800. /**
  33801. * Interpolates a Vector2 linearly
  33802. * @param startValue Start value of the animation curve
  33803. * @param endValue End value of the animation curve
  33804. * @param gradient Scalar amount to interpolate
  33805. * @returns Interpolated Vector2 value
  33806. */
  33807. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33808. /**
  33809. * Interpolates a Vector2 cubically
  33810. * @param startValue Start value of the animation curve
  33811. * @param outTangent End tangent of the animation
  33812. * @param endValue End value of the animation curve
  33813. * @param inTangent Start tangent of the animation curve
  33814. * @param gradient Scalar amount to interpolate
  33815. * @returns Interpolated Vector2 value
  33816. */
  33817. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33818. /**
  33819. * Interpolates a size linearly
  33820. * @param startValue Start value of the animation curve
  33821. * @param endValue End value of the animation curve
  33822. * @param gradient Scalar amount to interpolate
  33823. * @returns Interpolated Size value
  33824. */
  33825. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33826. /**
  33827. * Interpolates a Color3 linearly
  33828. * @param startValue Start value of the animation curve
  33829. * @param endValue End value of the animation curve
  33830. * @param gradient Scalar amount to interpolate
  33831. * @returns Interpolated Color3 value
  33832. */
  33833. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33834. /**
  33835. * Interpolates a Color4 linearly
  33836. * @param startValue Start value of the animation curve
  33837. * @param endValue End value of the animation curve
  33838. * @param gradient Scalar amount to interpolate
  33839. * @returns Interpolated Color3 value
  33840. */
  33841. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33842. /**
  33843. * @hidden Internal use only
  33844. */
  33845. _getKeyValue(value: any): any;
  33846. /**
  33847. * @hidden Internal use only
  33848. */
  33849. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33850. /**
  33851. * Defines the function to use to interpolate matrices
  33852. * @param startValue defines the start matrix
  33853. * @param endValue defines the end matrix
  33854. * @param gradient defines the gradient between both matrices
  33855. * @param result defines an optional target matrix where to store the interpolation
  33856. * @returns the interpolated matrix
  33857. */
  33858. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33859. /**
  33860. * Makes a copy of the animation
  33861. * @returns Cloned animation
  33862. */
  33863. clone(): Animation;
  33864. /**
  33865. * Sets the key frames of the animation
  33866. * @param values The animation key frames to set
  33867. */
  33868. setKeys(values: Array<IAnimationKey>): void;
  33869. /**
  33870. * Serializes the animation to an object
  33871. * @returns Serialized object
  33872. */
  33873. serialize(): any;
  33874. /**
  33875. * Float animation type
  33876. */
  33877. static readonly ANIMATIONTYPE_FLOAT: number;
  33878. /**
  33879. * Vector3 animation type
  33880. */
  33881. static readonly ANIMATIONTYPE_VECTOR3: number;
  33882. /**
  33883. * Quaternion animation type
  33884. */
  33885. static readonly ANIMATIONTYPE_QUATERNION: number;
  33886. /**
  33887. * Matrix animation type
  33888. */
  33889. static readonly ANIMATIONTYPE_MATRIX: number;
  33890. /**
  33891. * Color3 animation type
  33892. */
  33893. static readonly ANIMATIONTYPE_COLOR3: number;
  33894. /**
  33895. * Color3 animation type
  33896. */
  33897. static readonly ANIMATIONTYPE_COLOR4: number;
  33898. /**
  33899. * Vector2 animation type
  33900. */
  33901. static readonly ANIMATIONTYPE_VECTOR2: number;
  33902. /**
  33903. * Size animation type
  33904. */
  33905. static readonly ANIMATIONTYPE_SIZE: number;
  33906. /**
  33907. * Relative Loop Mode
  33908. */
  33909. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33910. /**
  33911. * Cycle Loop Mode
  33912. */
  33913. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33914. /**
  33915. * Constant Loop Mode
  33916. */
  33917. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33918. /** @hidden */
  33919. static _UniversalLerp(left: any, right: any, amount: number): any;
  33920. /**
  33921. * Parses an animation object and creates an animation
  33922. * @param parsedAnimation Parsed animation object
  33923. * @returns Animation object
  33924. */
  33925. static Parse(parsedAnimation: any): Animation;
  33926. /**
  33927. * Appends the serialized animations from the source animations
  33928. * @param source Source containing the animations
  33929. * @param destination Target to store the animations
  33930. */
  33931. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33932. /**
  33933. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33934. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33935. * @param url defines the url to load from
  33936. * @returns a promise that will resolve to the new animation or an array of animations
  33937. */
  33938. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33939. /**
  33940. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33941. * @param snippetId defines the snippet to load
  33942. * @returns a promise that will resolve to the new animation or a new array of animations
  33943. */
  33944. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33945. }
  33946. }
  33947. declare module BABYLON {
  33948. /**
  33949. * Interface containing an array of animations
  33950. */
  33951. export interface IAnimatable {
  33952. /**
  33953. * Array of animations
  33954. */
  33955. animations: Nullable<Array<Animation>>;
  33956. }
  33957. }
  33958. declare module BABYLON {
  33959. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33960. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33961. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33962. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33963. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33964. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33965. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33966. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33967. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33968. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33969. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33970. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33971. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33972. /**
  33973. * Decorator used to define property that can be serialized as reference to a camera
  33974. * @param sourceName defines the name of the property to decorate
  33975. */
  33976. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33977. /**
  33978. * Class used to help serialization objects
  33979. */
  33980. export class SerializationHelper {
  33981. /** @hidden */
  33982. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  33983. /** @hidden */
  33984. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  33985. /** @hidden */
  33986. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  33987. /** @hidden */
  33988. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  33989. /**
  33990. * Appends the serialized animations from the source animations
  33991. * @param source Source containing the animations
  33992. * @param destination Target to store the animations
  33993. */
  33994. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33995. /**
  33996. * Static function used to serialized a specific entity
  33997. * @param entity defines the entity to serialize
  33998. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  33999. * @returns a JSON compatible object representing the serialization of the entity
  34000. */
  34001. static Serialize<T>(entity: T, serializationObject?: any): any;
  34002. /**
  34003. * Creates a new entity from a serialization data object
  34004. * @param creationFunction defines a function used to instanciated the new entity
  34005. * @param source defines the source serialization data
  34006. * @param scene defines the hosting scene
  34007. * @param rootUrl defines the root url for resources
  34008. * @returns a new entity
  34009. */
  34010. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34011. /**
  34012. * Clones an object
  34013. * @param creationFunction defines the function used to instanciate the new object
  34014. * @param source defines the source object
  34015. * @returns the cloned object
  34016. */
  34017. static Clone<T>(creationFunction: () => T, source: T): T;
  34018. /**
  34019. * Instanciates a new object based on a source one (some data will be shared between both object)
  34020. * @param creationFunction defines the function used to instanciate the new object
  34021. * @param source defines the source object
  34022. * @returns the new object
  34023. */
  34024. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34025. }
  34026. }
  34027. declare module BABYLON {
  34028. /**
  34029. * Base class of all the textures in babylon.
  34030. * It groups all the common properties the materials, post process, lights... might need
  34031. * in order to make a correct use of the texture.
  34032. */
  34033. export class BaseTexture implements IAnimatable {
  34034. /**
  34035. * Default anisotropic filtering level for the application.
  34036. * It is set to 4 as a good tradeoff between perf and quality.
  34037. */
  34038. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34039. /**
  34040. * Gets or sets the unique id of the texture
  34041. */
  34042. uniqueId: number;
  34043. /**
  34044. * Define the name of the texture.
  34045. */
  34046. name: string;
  34047. /**
  34048. * Gets or sets an object used to store user defined information.
  34049. */
  34050. metadata: any;
  34051. /**
  34052. * For internal use only. Please do not use.
  34053. */
  34054. reservedDataStore: any;
  34055. private _hasAlpha;
  34056. /**
  34057. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34058. */
  34059. set hasAlpha(value: boolean);
  34060. get hasAlpha(): boolean;
  34061. /**
  34062. * Defines if the alpha value should be determined via the rgb values.
  34063. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34064. */
  34065. getAlphaFromRGB: boolean;
  34066. /**
  34067. * Intensity or strength of the texture.
  34068. * It is commonly used by materials to fine tune the intensity of the texture
  34069. */
  34070. level: number;
  34071. /**
  34072. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34073. * This is part of the texture as textures usually maps to one uv set.
  34074. */
  34075. coordinatesIndex: number;
  34076. protected _coordinatesMode: number;
  34077. /**
  34078. * How a texture is mapped.
  34079. *
  34080. * | Value | Type | Description |
  34081. * | ----- | ----------------------------------- | ----------- |
  34082. * | 0 | EXPLICIT_MODE | |
  34083. * | 1 | SPHERICAL_MODE | |
  34084. * | 2 | PLANAR_MODE | |
  34085. * | 3 | CUBIC_MODE | |
  34086. * | 4 | PROJECTION_MODE | |
  34087. * | 5 | SKYBOX_MODE | |
  34088. * | 6 | INVCUBIC_MODE | |
  34089. * | 7 | EQUIRECTANGULAR_MODE | |
  34090. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34091. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34092. */
  34093. set coordinatesMode(value: number);
  34094. get coordinatesMode(): number;
  34095. private _wrapU;
  34096. /**
  34097. * | Value | Type | Description |
  34098. * | ----- | ------------------ | ----------- |
  34099. * | 0 | CLAMP_ADDRESSMODE | |
  34100. * | 1 | WRAP_ADDRESSMODE | |
  34101. * | 2 | MIRROR_ADDRESSMODE | |
  34102. */
  34103. get wrapU(): number;
  34104. set wrapU(value: number);
  34105. private _wrapV;
  34106. /**
  34107. * | Value | Type | Description |
  34108. * | ----- | ------------------ | ----------- |
  34109. * | 0 | CLAMP_ADDRESSMODE | |
  34110. * | 1 | WRAP_ADDRESSMODE | |
  34111. * | 2 | MIRROR_ADDRESSMODE | |
  34112. */
  34113. get wrapV(): number;
  34114. set wrapV(value: number);
  34115. /**
  34116. * | Value | Type | Description |
  34117. * | ----- | ------------------ | ----------- |
  34118. * | 0 | CLAMP_ADDRESSMODE | |
  34119. * | 1 | WRAP_ADDRESSMODE | |
  34120. * | 2 | MIRROR_ADDRESSMODE | |
  34121. */
  34122. wrapR: number;
  34123. /**
  34124. * With compliant hardware and browser (supporting anisotropic filtering)
  34125. * this defines the level of anisotropic filtering in the texture.
  34126. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34127. */
  34128. anisotropicFilteringLevel: number;
  34129. /**
  34130. * Define if the texture is a cube texture or if false a 2d texture.
  34131. */
  34132. get isCube(): boolean;
  34133. set isCube(value: boolean);
  34134. /**
  34135. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34136. */
  34137. get is3D(): boolean;
  34138. set is3D(value: boolean);
  34139. /**
  34140. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34141. */
  34142. get is2DArray(): boolean;
  34143. set is2DArray(value: boolean);
  34144. private _gammaSpace;
  34145. /**
  34146. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34147. * HDR texture are usually stored in linear space.
  34148. * This only impacts the PBR and Background materials
  34149. */
  34150. get gammaSpace(): boolean;
  34151. set gammaSpace(gamma: boolean);
  34152. /**
  34153. * Gets or sets whether or not the texture contains RGBD data.
  34154. */
  34155. get isRGBD(): boolean;
  34156. set isRGBD(value: boolean);
  34157. /**
  34158. * Is Z inverted in the texture (useful in a cube texture).
  34159. */
  34160. invertZ: boolean;
  34161. /**
  34162. * Are mip maps generated for this texture or not.
  34163. */
  34164. get noMipmap(): boolean;
  34165. /**
  34166. * @hidden
  34167. */
  34168. lodLevelInAlpha: boolean;
  34169. /**
  34170. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34171. */
  34172. get lodGenerationOffset(): number;
  34173. set lodGenerationOffset(value: number);
  34174. /**
  34175. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34176. */
  34177. get lodGenerationScale(): number;
  34178. set lodGenerationScale(value: number);
  34179. /**
  34180. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34181. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34182. * average roughness values.
  34183. */
  34184. get linearSpecularLOD(): boolean;
  34185. set linearSpecularLOD(value: boolean);
  34186. /**
  34187. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34188. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34189. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34190. */
  34191. get irradianceTexture(): Nullable<BaseTexture>;
  34192. set irradianceTexture(value: Nullable<BaseTexture>);
  34193. /**
  34194. * Define if the texture is a render target.
  34195. */
  34196. isRenderTarget: boolean;
  34197. /**
  34198. * Define the unique id of the texture in the scene.
  34199. */
  34200. get uid(): string;
  34201. /** @hidden */
  34202. _prefiltered: boolean;
  34203. /**
  34204. * Return a string representation of the texture.
  34205. * @returns the texture as a string
  34206. */
  34207. toString(): string;
  34208. /**
  34209. * Get the class name of the texture.
  34210. * @returns "BaseTexture"
  34211. */
  34212. getClassName(): string;
  34213. /**
  34214. * Define the list of animation attached to the texture.
  34215. */
  34216. animations: Animation[];
  34217. /**
  34218. * An event triggered when the texture is disposed.
  34219. */
  34220. onDisposeObservable: Observable<BaseTexture>;
  34221. private _onDisposeObserver;
  34222. /**
  34223. * Callback triggered when the texture has been disposed.
  34224. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34225. */
  34226. set onDispose(callback: () => void);
  34227. /**
  34228. * Define the current state of the loading sequence when in delayed load mode.
  34229. */
  34230. delayLoadState: number;
  34231. protected _scene: Nullable<Scene>;
  34232. protected _engine: Nullable<ThinEngine>;
  34233. /** @hidden */
  34234. _texture: Nullable<InternalTexture>;
  34235. private _uid;
  34236. /**
  34237. * Define if the texture is preventinga material to render or not.
  34238. * If not and the texture is not ready, the engine will use a default black texture instead.
  34239. */
  34240. get isBlocking(): boolean;
  34241. /**
  34242. * Instantiates a new BaseTexture.
  34243. * Base class of all the textures in babylon.
  34244. * It groups all the common properties the materials, post process, lights... might need
  34245. * in order to make a correct use of the texture.
  34246. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34247. */
  34248. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34249. /**
  34250. * Get the scene the texture belongs to.
  34251. * @returns the scene or null if undefined
  34252. */
  34253. getScene(): Nullable<Scene>;
  34254. /** @hidden */
  34255. protected _getEngine(): Nullable<ThinEngine>;
  34256. /**
  34257. * Get the texture transform matrix used to offset tile the texture for istance.
  34258. * @returns the transformation matrix
  34259. */
  34260. getTextureMatrix(): Matrix;
  34261. /**
  34262. * Get the texture reflection matrix used to rotate/transform the reflection.
  34263. * @returns the reflection matrix
  34264. */
  34265. getReflectionTextureMatrix(): Matrix;
  34266. /**
  34267. * Get the underlying lower level texture from Babylon.
  34268. * @returns the insternal texture
  34269. */
  34270. getInternalTexture(): Nullable<InternalTexture>;
  34271. /**
  34272. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34273. * @returns true if ready or not blocking
  34274. */
  34275. isReadyOrNotBlocking(): boolean;
  34276. /**
  34277. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34278. * @returns true if fully ready
  34279. */
  34280. isReady(): boolean;
  34281. private _cachedSize;
  34282. /**
  34283. * Get the size of the texture.
  34284. * @returns the texture size.
  34285. */
  34286. getSize(): ISize;
  34287. /**
  34288. * Get the base size of the texture.
  34289. * It can be different from the size if the texture has been resized for POT for instance
  34290. * @returns the base size
  34291. */
  34292. getBaseSize(): ISize;
  34293. /**
  34294. * Update the sampling mode of the texture.
  34295. * Default is Trilinear mode.
  34296. *
  34297. * | Value | Type | Description |
  34298. * | ----- | ------------------ | ----------- |
  34299. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34300. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34301. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34302. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34303. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34304. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34305. * | 7 | NEAREST_LINEAR | |
  34306. * | 8 | NEAREST_NEAREST | |
  34307. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34308. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34309. * | 11 | LINEAR_LINEAR | |
  34310. * | 12 | LINEAR_NEAREST | |
  34311. *
  34312. * > _mag_: magnification filter (close to the viewer)
  34313. * > _min_: minification filter (far from the viewer)
  34314. * > _mip_: filter used between mip map levels
  34315. *@param samplingMode Define the new sampling mode of the texture
  34316. */
  34317. updateSamplingMode(samplingMode: number): void;
  34318. /**
  34319. * Scales the texture if is `canRescale()`
  34320. * @param ratio the resize factor we want to use to rescale
  34321. */
  34322. scale(ratio: number): void;
  34323. /**
  34324. * Get if the texture can rescale.
  34325. */
  34326. get canRescale(): boolean;
  34327. /** @hidden */
  34328. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34329. /** @hidden */
  34330. _rebuild(): void;
  34331. /**
  34332. * Triggers the load sequence in delayed load mode.
  34333. */
  34334. delayLoad(): void;
  34335. /**
  34336. * Clones the texture.
  34337. * @returns the cloned texture
  34338. */
  34339. clone(): Nullable<BaseTexture>;
  34340. /**
  34341. * Get the texture underlying type (INT, FLOAT...)
  34342. */
  34343. get textureType(): number;
  34344. /**
  34345. * Get the texture underlying format (RGB, RGBA...)
  34346. */
  34347. get textureFormat(): number;
  34348. /**
  34349. * Indicates that textures need to be re-calculated for all materials
  34350. */
  34351. protected _markAllSubMeshesAsTexturesDirty(): void;
  34352. /**
  34353. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34354. * This will returns an RGBA array buffer containing either in values (0-255) or
  34355. * float values (0-1) depending of the underlying buffer type.
  34356. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34357. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34358. * @param buffer defines a user defined buffer to fill with data (can be null)
  34359. * @returns The Array buffer containing the pixels data.
  34360. */
  34361. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34362. /**
  34363. * Release and destroy the underlying lower level texture aka internalTexture.
  34364. */
  34365. releaseInternalTexture(): void;
  34366. /** @hidden */
  34367. get _lodTextureHigh(): Nullable<BaseTexture>;
  34368. /** @hidden */
  34369. get _lodTextureMid(): Nullable<BaseTexture>;
  34370. /** @hidden */
  34371. get _lodTextureLow(): Nullable<BaseTexture>;
  34372. /**
  34373. * Dispose the texture and release its associated resources.
  34374. */
  34375. dispose(): void;
  34376. /**
  34377. * Serialize the texture into a JSON representation that can be parsed later on.
  34378. * @returns the JSON representation of the texture
  34379. */
  34380. serialize(): any;
  34381. /**
  34382. * Helper function to be called back once a list of texture contains only ready textures.
  34383. * @param textures Define the list of textures to wait for
  34384. * @param callback Define the callback triggered once the entire list will be ready
  34385. */
  34386. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34387. private static _isScene;
  34388. }
  34389. }
  34390. declare module BABYLON {
  34391. /**
  34392. * Options to be used when creating an effect.
  34393. */
  34394. export interface IEffectCreationOptions {
  34395. /**
  34396. * Atrributes that will be used in the shader.
  34397. */
  34398. attributes: string[];
  34399. /**
  34400. * Uniform varible names that will be set in the shader.
  34401. */
  34402. uniformsNames: string[];
  34403. /**
  34404. * Uniform buffer variable names that will be set in the shader.
  34405. */
  34406. uniformBuffersNames: string[];
  34407. /**
  34408. * Sampler texture variable names that will be set in the shader.
  34409. */
  34410. samplers: string[];
  34411. /**
  34412. * Define statements that will be set in the shader.
  34413. */
  34414. defines: any;
  34415. /**
  34416. * Possible fallbacks for this effect to improve performance when needed.
  34417. */
  34418. fallbacks: Nullable<IEffectFallbacks>;
  34419. /**
  34420. * Callback that will be called when the shader is compiled.
  34421. */
  34422. onCompiled: Nullable<(effect: Effect) => void>;
  34423. /**
  34424. * Callback that will be called if an error occurs during shader compilation.
  34425. */
  34426. onError: Nullable<(effect: Effect, errors: string) => void>;
  34427. /**
  34428. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34429. */
  34430. indexParameters?: any;
  34431. /**
  34432. * Max number of lights that can be used in the shader.
  34433. */
  34434. maxSimultaneousLights?: number;
  34435. /**
  34436. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34437. */
  34438. transformFeedbackVaryings?: Nullable<string[]>;
  34439. /**
  34440. * 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
  34441. */
  34442. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34443. /**
  34444. * Is this effect rendering to several color attachments ?
  34445. */
  34446. multiTarget?: boolean;
  34447. }
  34448. /**
  34449. * Effect containing vertex and fragment shader that can be executed on an object.
  34450. */
  34451. export class Effect implements IDisposable {
  34452. /**
  34453. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34454. */
  34455. static ShadersRepository: string;
  34456. /**
  34457. * Enable logging of the shader code when a compilation error occurs
  34458. */
  34459. static LogShaderCodeOnCompilationError: boolean;
  34460. /**
  34461. * Name of the effect.
  34462. */
  34463. name: any;
  34464. /**
  34465. * String container all the define statements that should be set on the shader.
  34466. */
  34467. defines: string;
  34468. /**
  34469. * Callback that will be called when the shader is compiled.
  34470. */
  34471. onCompiled: Nullable<(effect: Effect) => void>;
  34472. /**
  34473. * Callback that will be called if an error occurs during shader compilation.
  34474. */
  34475. onError: Nullable<(effect: Effect, errors: string) => void>;
  34476. /**
  34477. * Callback that will be called when effect is bound.
  34478. */
  34479. onBind: Nullable<(effect: Effect) => void>;
  34480. /**
  34481. * Unique ID of the effect.
  34482. */
  34483. uniqueId: number;
  34484. /**
  34485. * Observable that will be called when the shader is compiled.
  34486. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34487. */
  34488. onCompileObservable: Observable<Effect>;
  34489. /**
  34490. * Observable that will be called if an error occurs during shader compilation.
  34491. */
  34492. onErrorObservable: Observable<Effect>;
  34493. /** @hidden */
  34494. _onBindObservable: Nullable<Observable<Effect>>;
  34495. /**
  34496. * @hidden
  34497. * Specifies if the effect was previously ready
  34498. */
  34499. _wasPreviouslyReady: boolean;
  34500. /**
  34501. * Observable that will be called when effect is bound.
  34502. */
  34503. get onBindObservable(): Observable<Effect>;
  34504. /** @hidden */
  34505. _bonesComputationForcedToCPU: boolean;
  34506. /** @hidden */
  34507. _multiTarget: boolean;
  34508. private static _uniqueIdSeed;
  34509. private _engine;
  34510. private _uniformBuffersNames;
  34511. private _uniformBuffersNamesList;
  34512. private _uniformsNames;
  34513. private _samplerList;
  34514. private _samplers;
  34515. private _isReady;
  34516. private _compilationError;
  34517. private _allFallbacksProcessed;
  34518. private _attributesNames;
  34519. private _attributes;
  34520. private _attributeLocationByName;
  34521. private _uniforms;
  34522. /**
  34523. * Key for the effect.
  34524. * @hidden
  34525. */
  34526. _key: string;
  34527. private _indexParameters;
  34528. private _fallbacks;
  34529. private _vertexSourceCode;
  34530. private _fragmentSourceCode;
  34531. private _vertexSourceCodeOverride;
  34532. private _fragmentSourceCodeOverride;
  34533. private _transformFeedbackVaryings;
  34534. /**
  34535. * Compiled shader to webGL program.
  34536. * @hidden
  34537. */
  34538. _pipelineContext: Nullable<IPipelineContext>;
  34539. private _valueCache;
  34540. private static _baseCache;
  34541. /**
  34542. * Instantiates an effect.
  34543. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34544. * @param baseName Name of the effect.
  34545. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34546. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34547. * @param samplers List of sampler variables that will be passed to the shader.
  34548. * @param engine Engine to be used to render the effect
  34549. * @param defines Define statements to be added to the shader.
  34550. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34551. * @param onCompiled Callback that will be called when the shader is compiled.
  34552. * @param onError Callback that will be called if an error occurs during shader compilation.
  34553. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34554. */
  34555. 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);
  34556. private _useFinalCode;
  34557. /**
  34558. * Unique key for this effect
  34559. */
  34560. get key(): string;
  34561. /**
  34562. * If the effect has been compiled and prepared.
  34563. * @returns if the effect is compiled and prepared.
  34564. */
  34565. isReady(): boolean;
  34566. private _isReadyInternal;
  34567. /**
  34568. * The engine the effect was initialized with.
  34569. * @returns the engine.
  34570. */
  34571. getEngine(): Engine;
  34572. /**
  34573. * The pipeline context for this effect
  34574. * @returns the associated pipeline context
  34575. */
  34576. getPipelineContext(): Nullable<IPipelineContext>;
  34577. /**
  34578. * The set of names of attribute variables for the shader.
  34579. * @returns An array of attribute names.
  34580. */
  34581. getAttributesNames(): string[];
  34582. /**
  34583. * Returns the attribute at the given index.
  34584. * @param index The index of the attribute.
  34585. * @returns The location of the attribute.
  34586. */
  34587. getAttributeLocation(index: number): number;
  34588. /**
  34589. * Returns the attribute based on the name of the variable.
  34590. * @param name of the attribute to look up.
  34591. * @returns the attribute location.
  34592. */
  34593. getAttributeLocationByName(name: string): number;
  34594. /**
  34595. * The number of attributes.
  34596. * @returns the numnber of attributes.
  34597. */
  34598. getAttributesCount(): number;
  34599. /**
  34600. * Gets the index of a uniform variable.
  34601. * @param uniformName of the uniform to look up.
  34602. * @returns the index.
  34603. */
  34604. getUniformIndex(uniformName: string): number;
  34605. /**
  34606. * Returns the attribute based on the name of the variable.
  34607. * @param uniformName of the uniform to look up.
  34608. * @returns the location of the uniform.
  34609. */
  34610. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34611. /**
  34612. * Returns an array of sampler variable names
  34613. * @returns The array of sampler variable names.
  34614. */
  34615. getSamplers(): string[];
  34616. /**
  34617. * Returns an array of uniform variable names
  34618. * @returns The array of uniform variable names.
  34619. */
  34620. getUniformNames(): string[];
  34621. /**
  34622. * Returns an array of uniform buffer variable names
  34623. * @returns The array of uniform buffer variable names.
  34624. */
  34625. getUniformBuffersNames(): string[];
  34626. /**
  34627. * Returns the index parameters used to create the effect
  34628. * @returns The index parameters object
  34629. */
  34630. getIndexParameters(): any;
  34631. /**
  34632. * The error from the last compilation.
  34633. * @returns the error string.
  34634. */
  34635. getCompilationError(): string;
  34636. /**
  34637. * Gets a boolean indicating that all fallbacks were used during compilation
  34638. * @returns true if all fallbacks were used
  34639. */
  34640. allFallbacksProcessed(): boolean;
  34641. /**
  34642. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34643. * @param func The callback to be used.
  34644. */
  34645. executeWhenCompiled(func: (effect: Effect) => void): void;
  34646. private _checkIsReady;
  34647. private _loadShader;
  34648. /**
  34649. * Gets the vertex shader source code of this effect
  34650. */
  34651. get vertexSourceCode(): string;
  34652. /**
  34653. * Gets the fragment shader source code of this effect
  34654. */
  34655. get fragmentSourceCode(): string;
  34656. /**
  34657. * Recompiles the webGL program
  34658. * @param vertexSourceCode The source code for the vertex shader.
  34659. * @param fragmentSourceCode The source code for the fragment shader.
  34660. * @param onCompiled Callback called when completed.
  34661. * @param onError Callback called on error.
  34662. * @hidden
  34663. */
  34664. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34665. /**
  34666. * Prepares the effect
  34667. * @hidden
  34668. */
  34669. _prepareEffect(): void;
  34670. private _getShaderCodeAndErrorLine;
  34671. private _processCompilationErrors;
  34672. /**
  34673. * Checks if the effect is supported. (Must be called after compilation)
  34674. */
  34675. get isSupported(): boolean;
  34676. /**
  34677. * Binds a texture to the engine to be used as output of the shader.
  34678. * @param channel Name of the output variable.
  34679. * @param texture Texture to bind.
  34680. * @hidden
  34681. */
  34682. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34683. /**
  34684. * Sets a texture on the engine to be used in the shader.
  34685. * @param channel Name of the sampler variable.
  34686. * @param texture Texture to set.
  34687. */
  34688. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34689. /**
  34690. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34691. * @param channel Name of the sampler variable.
  34692. * @param texture Texture to set.
  34693. */
  34694. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34695. /**
  34696. * Sets an array of textures on the engine to be used in the shader.
  34697. * @param channel Name of the variable.
  34698. * @param textures Textures to set.
  34699. */
  34700. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34701. /**
  34702. * 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)
  34703. * @param channel Name of the sampler variable.
  34704. * @param postProcess Post process to get the input texture from.
  34705. */
  34706. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34707. /**
  34708. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34709. * 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)
  34710. * @param channel Name of the sampler variable.
  34711. * @param postProcess Post process to get the output texture from.
  34712. */
  34713. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34714. /** @hidden */
  34715. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34716. /** @hidden */
  34717. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34718. /** @hidden */
  34719. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34720. /** @hidden */
  34721. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34722. /**
  34723. * Binds a buffer to a uniform.
  34724. * @param buffer Buffer to bind.
  34725. * @param name Name of the uniform variable to bind to.
  34726. */
  34727. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34728. /**
  34729. * Binds block to a uniform.
  34730. * @param blockName Name of the block to bind.
  34731. * @param index Index to bind.
  34732. */
  34733. bindUniformBlock(blockName: string, index: number): void;
  34734. /**
  34735. * Sets an interger value on a uniform variable.
  34736. * @param uniformName Name of the variable.
  34737. * @param value Value to be set.
  34738. * @returns this effect.
  34739. */
  34740. setInt(uniformName: string, value: number): Effect;
  34741. /**
  34742. * Sets an int array on a uniform variable.
  34743. * @param uniformName Name of the variable.
  34744. * @param array array to be set.
  34745. * @returns this effect.
  34746. */
  34747. setIntArray(uniformName: string, array: Int32Array): Effect;
  34748. /**
  34749. * 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)
  34750. * @param uniformName Name of the variable.
  34751. * @param array array to be set.
  34752. * @returns this effect.
  34753. */
  34754. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34755. /**
  34756. * 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)
  34757. * @param uniformName Name of the variable.
  34758. * @param array array to be set.
  34759. * @returns this effect.
  34760. */
  34761. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34762. /**
  34763. * 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)
  34764. * @param uniformName Name of the variable.
  34765. * @param array array to be set.
  34766. * @returns this effect.
  34767. */
  34768. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34769. /**
  34770. * Sets an float array on a uniform variable.
  34771. * @param uniformName Name of the variable.
  34772. * @param array array to be set.
  34773. * @returns this effect.
  34774. */
  34775. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34776. /**
  34777. * 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)
  34778. * @param uniformName Name of the variable.
  34779. * @param array array to be set.
  34780. * @returns this effect.
  34781. */
  34782. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34783. /**
  34784. * 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)
  34785. * @param uniformName Name of the variable.
  34786. * @param array array to be set.
  34787. * @returns this effect.
  34788. */
  34789. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34790. /**
  34791. * 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)
  34792. * @param uniformName Name of the variable.
  34793. * @param array array to be set.
  34794. * @returns this effect.
  34795. */
  34796. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34797. /**
  34798. * Sets an array on a uniform variable.
  34799. * @param uniformName Name of the variable.
  34800. * @param array array to be set.
  34801. * @returns this effect.
  34802. */
  34803. setArray(uniformName: string, array: number[]): Effect;
  34804. /**
  34805. * 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)
  34806. * @param uniformName Name of the variable.
  34807. * @param array array to be set.
  34808. * @returns this effect.
  34809. */
  34810. setArray2(uniformName: string, array: number[]): Effect;
  34811. /**
  34812. * 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)
  34813. * @param uniformName Name of the variable.
  34814. * @param array array to be set.
  34815. * @returns this effect.
  34816. */
  34817. setArray3(uniformName: string, array: number[]): Effect;
  34818. /**
  34819. * 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)
  34820. * @param uniformName Name of the variable.
  34821. * @param array array to be set.
  34822. * @returns this effect.
  34823. */
  34824. setArray4(uniformName: string, array: number[]): Effect;
  34825. /**
  34826. * Sets matrices on a uniform variable.
  34827. * @param uniformName Name of the variable.
  34828. * @param matrices matrices to be set.
  34829. * @returns this effect.
  34830. */
  34831. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  34832. /**
  34833. * Sets matrix on a uniform variable.
  34834. * @param uniformName Name of the variable.
  34835. * @param matrix matrix to be set.
  34836. * @returns this effect.
  34837. */
  34838. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34839. /**
  34840. * 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)
  34841. * @param uniformName Name of the variable.
  34842. * @param matrix matrix to be set.
  34843. * @returns this effect.
  34844. */
  34845. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34846. /**
  34847. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34848. * @param uniformName Name of the variable.
  34849. * @param matrix matrix to be set.
  34850. * @returns this effect.
  34851. */
  34852. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  34853. /**
  34854. * Sets a float on a uniform variable.
  34855. * @param uniformName Name of the variable.
  34856. * @param value value to be set.
  34857. * @returns this effect.
  34858. */
  34859. setFloat(uniformName: string, value: number): Effect;
  34860. /**
  34861. * Sets a boolean on a uniform variable.
  34862. * @param uniformName Name of the variable.
  34863. * @param bool value to be set.
  34864. * @returns this effect.
  34865. */
  34866. setBool(uniformName: string, bool: boolean): Effect;
  34867. /**
  34868. * Sets a Vector2 on a uniform variable.
  34869. * @param uniformName Name of the variable.
  34870. * @param vector2 vector2 to be set.
  34871. * @returns this effect.
  34872. */
  34873. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34874. /**
  34875. * Sets a float2 on a uniform variable.
  34876. * @param uniformName Name of the variable.
  34877. * @param x First float in float2.
  34878. * @param y Second float in float2.
  34879. * @returns this effect.
  34880. */
  34881. setFloat2(uniformName: string, x: number, y: number): Effect;
  34882. /**
  34883. * Sets a Vector3 on a uniform variable.
  34884. * @param uniformName Name of the variable.
  34885. * @param vector3 Value to be set.
  34886. * @returns this effect.
  34887. */
  34888. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34889. /**
  34890. * Sets a float3 on a uniform variable.
  34891. * @param uniformName Name of the variable.
  34892. * @param x First float in float3.
  34893. * @param y Second float in float3.
  34894. * @param z Third float in float3.
  34895. * @returns this effect.
  34896. */
  34897. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34898. /**
  34899. * Sets a Vector4 on a uniform variable.
  34900. * @param uniformName Name of the variable.
  34901. * @param vector4 Value to be set.
  34902. * @returns this effect.
  34903. */
  34904. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34905. /**
  34906. * Sets a float4 on a uniform variable.
  34907. * @param uniformName Name of the variable.
  34908. * @param x First float in float4.
  34909. * @param y Second float in float4.
  34910. * @param z Third float in float4.
  34911. * @param w Fourth float in float4.
  34912. * @returns this effect.
  34913. */
  34914. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34915. /**
  34916. * Sets a Color3 on a uniform variable.
  34917. * @param uniformName Name of the variable.
  34918. * @param color3 Value to be set.
  34919. * @returns this effect.
  34920. */
  34921. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34922. /**
  34923. * Sets a Color4 on a uniform variable.
  34924. * @param uniformName Name of the variable.
  34925. * @param color3 Value to be set.
  34926. * @param alpha Alpha value to be set.
  34927. * @returns this effect.
  34928. */
  34929. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34930. /**
  34931. * Sets a Color4 on a uniform variable
  34932. * @param uniformName defines the name of the variable
  34933. * @param color4 defines the value to be set
  34934. * @returns this effect.
  34935. */
  34936. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34937. /** Release all associated resources */
  34938. dispose(): void;
  34939. /**
  34940. * This function will add a new shader to the shader store
  34941. * @param name the name of the shader
  34942. * @param pixelShader optional pixel shader content
  34943. * @param vertexShader optional vertex shader content
  34944. */
  34945. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34946. /**
  34947. * Store of each shader (The can be looked up using effect.key)
  34948. */
  34949. static ShadersStore: {
  34950. [key: string]: string;
  34951. };
  34952. /**
  34953. * Store of each included file for a shader (The can be looked up using effect.key)
  34954. */
  34955. static IncludesShadersStore: {
  34956. [key: string]: string;
  34957. };
  34958. /**
  34959. * Resets the cache of effects.
  34960. */
  34961. static ResetCache(): void;
  34962. }
  34963. }
  34964. declare module BABYLON {
  34965. /**
  34966. * Interface used to describe the capabilities of the engine relatively to the current browser
  34967. */
  34968. export interface EngineCapabilities {
  34969. /** Maximum textures units per fragment shader */
  34970. maxTexturesImageUnits: number;
  34971. /** Maximum texture units per vertex shader */
  34972. maxVertexTextureImageUnits: number;
  34973. /** Maximum textures units in the entire pipeline */
  34974. maxCombinedTexturesImageUnits: number;
  34975. /** Maximum texture size */
  34976. maxTextureSize: number;
  34977. /** Maximum texture samples */
  34978. maxSamples?: number;
  34979. /** Maximum cube texture size */
  34980. maxCubemapTextureSize: number;
  34981. /** Maximum render texture size */
  34982. maxRenderTextureSize: number;
  34983. /** Maximum number of vertex attributes */
  34984. maxVertexAttribs: number;
  34985. /** Maximum number of varyings */
  34986. maxVaryingVectors: number;
  34987. /** Maximum number of uniforms per vertex shader */
  34988. maxVertexUniformVectors: number;
  34989. /** Maximum number of uniforms per fragment shader */
  34990. maxFragmentUniformVectors: number;
  34991. /** Defines if standard derivates (dx/dy) are supported */
  34992. standardDerivatives: boolean;
  34993. /** Defines if s3tc texture compression is supported */
  34994. s3tc?: WEBGL_compressed_texture_s3tc;
  34995. /** Defines if pvrtc texture compression is supported */
  34996. pvrtc: any;
  34997. /** Defines if etc1 texture compression is supported */
  34998. etc1: any;
  34999. /** Defines if etc2 texture compression is supported */
  35000. etc2: any;
  35001. /** Defines if astc texture compression is supported */
  35002. astc: any;
  35003. /** Defines if bptc texture compression is supported */
  35004. bptc: any;
  35005. /** Defines if float textures are supported */
  35006. textureFloat: boolean;
  35007. /** Defines if vertex array objects are supported */
  35008. vertexArrayObject: boolean;
  35009. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35010. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35011. /** Gets the maximum level of anisotropy supported */
  35012. maxAnisotropy: number;
  35013. /** Defines if instancing is supported */
  35014. instancedArrays: boolean;
  35015. /** Defines if 32 bits indices are supported */
  35016. uintIndices: boolean;
  35017. /** Defines if high precision shaders are supported */
  35018. highPrecisionShaderSupported: boolean;
  35019. /** Defines if depth reading in the fragment shader is supported */
  35020. fragmentDepthSupported: boolean;
  35021. /** Defines if float texture linear filtering is supported*/
  35022. textureFloatLinearFiltering: boolean;
  35023. /** Defines if rendering to float textures is supported */
  35024. textureFloatRender: boolean;
  35025. /** Defines if half float textures are supported*/
  35026. textureHalfFloat: boolean;
  35027. /** Defines if half float texture linear filtering is supported*/
  35028. textureHalfFloatLinearFiltering: boolean;
  35029. /** Defines if rendering to half float textures is supported */
  35030. textureHalfFloatRender: boolean;
  35031. /** Defines if textureLOD shader command is supported */
  35032. textureLOD: boolean;
  35033. /** Defines if draw buffers extension is supported */
  35034. drawBuffersExtension: boolean;
  35035. /** Defines if depth textures are supported */
  35036. depthTextureExtension: boolean;
  35037. /** Defines if float color buffer are supported */
  35038. colorBufferFloat: boolean;
  35039. /** Gets disjoint timer query extension (null if not supported) */
  35040. timerQuery?: EXT_disjoint_timer_query;
  35041. /** Defines if timestamp can be used with timer query */
  35042. canUseTimestampForTimerQuery: boolean;
  35043. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35044. multiview?: any;
  35045. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35046. oculusMultiview?: any;
  35047. /** Function used to let the system compiles shaders in background */
  35048. parallelShaderCompile?: {
  35049. COMPLETION_STATUS_KHR: number;
  35050. };
  35051. /** Max number of texture samples for MSAA */
  35052. maxMSAASamples: number;
  35053. /** Defines if the blend min max extension is supported */
  35054. blendMinMax: boolean;
  35055. }
  35056. }
  35057. declare module BABYLON {
  35058. /**
  35059. * @hidden
  35060. **/
  35061. export class DepthCullingState {
  35062. private _isDepthTestDirty;
  35063. private _isDepthMaskDirty;
  35064. private _isDepthFuncDirty;
  35065. private _isCullFaceDirty;
  35066. private _isCullDirty;
  35067. private _isZOffsetDirty;
  35068. private _isFrontFaceDirty;
  35069. private _depthTest;
  35070. private _depthMask;
  35071. private _depthFunc;
  35072. private _cull;
  35073. private _cullFace;
  35074. private _zOffset;
  35075. private _frontFace;
  35076. /**
  35077. * Initializes the state.
  35078. */
  35079. constructor();
  35080. get isDirty(): boolean;
  35081. get zOffset(): number;
  35082. set zOffset(value: number);
  35083. get cullFace(): Nullable<number>;
  35084. set cullFace(value: Nullable<number>);
  35085. get cull(): Nullable<boolean>;
  35086. set cull(value: Nullable<boolean>);
  35087. get depthFunc(): Nullable<number>;
  35088. set depthFunc(value: Nullable<number>);
  35089. get depthMask(): boolean;
  35090. set depthMask(value: boolean);
  35091. get depthTest(): boolean;
  35092. set depthTest(value: boolean);
  35093. get frontFace(): Nullable<number>;
  35094. set frontFace(value: Nullable<number>);
  35095. reset(): void;
  35096. apply(gl: WebGLRenderingContext): void;
  35097. }
  35098. }
  35099. declare module BABYLON {
  35100. /**
  35101. * @hidden
  35102. **/
  35103. export class StencilState {
  35104. /** 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 */
  35105. static readonly ALWAYS: number;
  35106. /** Passed to stencilOperation to specify that stencil value must be kept */
  35107. static readonly KEEP: number;
  35108. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35109. static readonly REPLACE: number;
  35110. private _isStencilTestDirty;
  35111. private _isStencilMaskDirty;
  35112. private _isStencilFuncDirty;
  35113. private _isStencilOpDirty;
  35114. private _stencilTest;
  35115. private _stencilMask;
  35116. private _stencilFunc;
  35117. private _stencilFuncRef;
  35118. private _stencilFuncMask;
  35119. private _stencilOpStencilFail;
  35120. private _stencilOpDepthFail;
  35121. private _stencilOpStencilDepthPass;
  35122. get isDirty(): boolean;
  35123. get stencilFunc(): number;
  35124. set stencilFunc(value: number);
  35125. get stencilFuncRef(): number;
  35126. set stencilFuncRef(value: number);
  35127. get stencilFuncMask(): number;
  35128. set stencilFuncMask(value: number);
  35129. get stencilOpStencilFail(): number;
  35130. set stencilOpStencilFail(value: number);
  35131. get stencilOpDepthFail(): number;
  35132. set stencilOpDepthFail(value: number);
  35133. get stencilOpStencilDepthPass(): number;
  35134. set stencilOpStencilDepthPass(value: number);
  35135. get stencilMask(): number;
  35136. set stencilMask(value: number);
  35137. get stencilTest(): boolean;
  35138. set stencilTest(value: boolean);
  35139. constructor();
  35140. reset(): void;
  35141. apply(gl: WebGLRenderingContext): void;
  35142. }
  35143. }
  35144. declare module BABYLON {
  35145. /**
  35146. * @hidden
  35147. **/
  35148. export class AlphaState {
  35149. private _isAlphaBlendDirty;
  35150. private _isBlendFunctionParametersDirty;
  35151. private _isBlendEquationParametersDirty;
  35152. private _isBlendConstantsDirty;
  35153. private _alphaBlend;
  35154. private _blendFunctionParameters;
  35155. private _blendEquationParameters;
  35156. private _blendConstants;
  35157. /**
  35158. * Initializes the state.
  35159. */
  35160. constructor();
  35161. get isDirty(): boolean;
  35162. get alphaBlend(): boolean;
  35163. set alphaBlend(value: boolean);
  35164. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35165. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35166. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35167. reset(): void;
  35168. apply(gl: WebGLRenderingContext): void;
  35169. }
  35170. }
  35171. declare module BABYLON {
  35172. /** @hidden */
  35173. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35174. attributeProcessor(attribute: string): string;
  35175. varyingProcessor(varying: string, isFragment: boolean): string;
  35176. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35177. }
  35178. }
  35179. declare module BABYLON {
  35180. /**
  35181. * Interface for attribute information associated with buffer instanciation
  35182. */
  35183. export interface InstancingAttributeInfo {
  35184. /**
  35185. * Name of the GLSL attribute
  35186. * if attribute index is not specified, this is used to retrieve the index from the effect
  35187. */
  35188. attributeName: string;
  35189. /**
  35190. * Index/offset of the attribute in the vertex shader
  35191. * if not specified, this will be computes from the name.
  35192. */
  35193. index?: number;
  35194. /**
  35195. * size of the attribute, 1, 2, 3 or 4
  35196. */
  35197. attributeSize: number;
  35198. /**
  35199. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35200. */
  35201. offset: number;
  35202. /**
  35203. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35204. * default to 1
  35205. */
  35206. divisor?: number;
  35207. /**
  35208. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35209. * default is FLOAT
  35210. */
  35211. attributeType?: number;
  35212. /**
  35213. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35214. */
  35215. normalized?: boolean;
  35216. }
  35217. }
  35218. declare module BABYLON {
  35219. interface ThinEngine {
  35220. /**
  35221. * Update a video texture
  35222. * @param texture defines the texture to update
  35223. * @param video defines the video element to use
  35224. * @param invertY defines if data must be stored with Y axis inverted
  35225. */
  35226. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35227. }
  35228. }
  35229. declare module BABYLON {
  35230. interface ThinEngine {
  35231. /**
  35232. * Creates a dynamic texture
  35233. * @param width defines the width of the texture
  35234. * @param height defines the height of the texture
  35235. * @param generateMipMaps defines if the engine should generate the mip levels
  35236. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35237. * @returns the dynamic texture inside an InternalTexture
  35238. */
  35239. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35240. /**
  35241. * Update the content of a dynamic texture
  35242. * @param texture defines the texture to update
  35243. * @param canvas defines the canvas containing the source
  35244. * @param invertY defines if data must be stored with Y axis inverted
  35245. * @param premulAlpha defines if alpha is stored as premultiplied
  35246. * @param format defines the format of the data
  35247. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35248. */
  35249. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35250. }
  35251. }
  35252. declare module BABYLON {
  35253. /**
  35254. * Settings for finer control over video usage
  35255. */
  35256. export interface VideoTextureSettings {
  35257. /**
  35258. * Applies `autoplay` to video, if specified
  35259. */
  35260. autoPlay?: boolean;
  35261. /**
  35262. * Applies `loop` to video, if specified
  35263. */
  35264. loop?: boolean;
  35265. /**
  35266. * Automatically updates internal texture from video at every frame in the render loop
  35267. */
  35268. autoUpdateTexture: boolean;
  35269. /**
  35270. * Image src displayed during the video loading or until the user interacts with the video.
  35271. */
  35272. poster?: string;
  35273. }
  35274. /**
  35275. * If you want to display a video in your scene, this is the special texture for that.
  35276. * This special texture works similar to other textures, with the exception of a few parameters.
  35277. * @see https://doc.babylonjs.com/how_to/video_texture
  35278. */
  35279. export class VideoTexture extends Texture {
  35280. /**
  35281. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35282. */
  35283. readonly autoUpdateTexture: boolean;
  35284. /**
  35285. * The video instance used by the texture internally
  35286. */
  35287. readonly video: HTMLVideoElement;
  35288. private _onUserActionRequestedObservable;
  35289. /**
  35290. * Event triggerd when a dom action is required by the user to play the video.
  35291. * This happens due to recent changes in browser policies preventing video to auto start.
  35292. */
  35293. get onUserActionRequestedObservable(): Observable<Texture>;
  35294. private _generateMipMaps;
  35295. private _stillImageCaptured;
  35296. private _displayingPosterTexture;
  35297. private _settings;
  35298. private _createInternalTextureOnEvent;
  35299. private _frameId;
  35300. private _currentSrc;
  35301. /**
  35302. * Creates a video texture.
  35303. * If you want to display a video in your scene, this is the special texture for that.
  35304. * This special texture works similar to other textures, with the exception of a few parameters.
  35305. * @see https://doc.babylonjs.com/how_to/video_texture
  35306. * @param name optional name, will detect from video source, if not defined
  35307. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35308. * @param scene is obviously the current scene.
  35309. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35310. * @param invertY is false by default but can be used to invert video on Y axis
  35311. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35312. * @param settings allows finer control over video usage
  35313. */
  35314. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35315. private _getName;
  35316. private _getVideo;
  35317. private _createInternalTexture;
  35318. private reset;
  35319. /**
  35320. * @hidden Internal method to initiate `update`.
  35321. */
  35322. _rebuild(): void;
  35323. /**
  35324. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35325. */
  35326. update(): void;
  35327. /**
  35328. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35329. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35330. */
  35331. updateTexture(isVisible: boolean): void;
  35332. protected _updateInternalTexture: () => void;
  35333. /**
  35334. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35335. * @param url New url.
  35336. */
  35337. updateURL(url: string): void;
  35338. /**
  35339. * Clones the texture.
  35340. * @returns the cloned texture
  35341. */
  35342. clone(): VideoTexture;
  35343. /**
  35344. * Dispose the texture and release its associated resources.
  35345. */
  35346. dispose(): void;
  35347. /**
  35348. * Creates a video texture straight from a stream.
  35349. * @param scene Define the scene the texture should be created in
  35350. * @param stream Define the stream the texture should be created from
  35351. * @returns The created video texture as a promise
  35352. */
  35353. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35354. /**
  35355. * Creates a video texture straight from your WebCam video feed.
  35356. * @param scene Define the scene the texture should be created in
  35357. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35358. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35359. * @returns The created video texture as a promise
  35360. */
  35361. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35362. minWidth: number;
  35363. maxWidth: number;
  35364. minHeight: number;
  35365. maxHeight: number;
  35366. deviceId: string;
  35367. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35368. /**
  35369. * Creates a video texture straight from your WebCam video feed.
  35370. * @param scene Define the scene the texture should be created in
  35371. * @param onReady Define a callback to triggered once the texture will be ready
  35372. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35373. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35374. */
  35375. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35376. minWidth: number;
  35377. maxWidth: number;
  35378. minHeight: number;
  35379. maxHeight: number;
  35380. deviceId: string;
  35381. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35382. }
  35383. }
  35384. declare module BABYLON {
  35385. /**
  35386. * Defines the interface used by objects working like Scene
  35387. * @hidden
  35388. */
  35389. export interface ISceneLike {
  35390. _addPendingData(data: any): void;
  35391. _removePendingData(data: any): void;
  35392. offlineProvider: IOfflineProvider;
  35393. }
  35394. /**
  35395. * Information about the current host
  35396. */
  35397. export interface HostInformation {
  35398. /**
  35399. * Defines if the current host is a mobile
  35400. */
  35401. isMobile: boolean;
  35402. }
  35403. /** Interface defining initialization parameters for Engine class */
  35404. export interface EngineOptions extends WebGLContextAttributes {
  35405. /**
  35406. * Defines if the engine should no exceed a specified device ratio
  35407. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35408. */
  35409. limitDeviceRatio?: number;
  35410. /**
  35411. * Defines if webvr should be enabled automatically
  35412. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35413. */
  35414. autoEnableWebVR?: boolean;
  35415. /**
  35416. * Defines if webgl2 should be turned off even if supported
  35417. * @see https://doc.babylonjs.com/features/webgl2
  35418. */
  35419. disableWebGL2Support?: boolean;
  35420. /**
  35421. * Defines if webaudio should be initialized as well
  35422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35423. */
  35424. audioEngine?: boolean;
  35425. /**
  35426. * Defines if animations should run using a deterministic lock step
  35427. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35428. */
  35429. deterministicLockstep?: boolean;
  35430. /** Defines the maximum steps to use with deterministic lock step mode */
  35431. lockstepMaxSteps?: number;
  35432. /** Defines the seconds between each deterministic lock step */
  35433. timeStep?: number;
  35434. /**
  35435. * Defines that engine should ignore context lost events
  35436. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35437. */
  35438. doNotHandleContextLost?: boolean;
  35439. /**
  35440. * Defines that engine should ignore modifying touch action attribute and style
  35441. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35442. */
  35443. doNotHandleTouchAction?: boolean;
  35444. /**
  35445. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35446. */
  35447. useHighPrecisionFloats?: boolean;
  35448. /**
  35449. * Make the canvas XR Compatible for XR sessions
  35450. */
  35451. xrCompatible?: boolean;
  35452. /**
  35453. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  35454. */
  35455. useHighPrecisionMatrix?: boolean;
  35456. /**
  35457. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  35458. */
  35459. failIfMajorPerformanceCaveat?: boolean;
  35460. }
  35461. /**
  35462. * The base engine class (root of all engines)
  35463. */
  35464. export class ThinEngine {
  35465. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35466. static ExceptionList: ({
  35467. key: string;
  35468. capture: string;
  35469. captureConstraint: number;
  35470. targets: string[];
  35471. } | {
  35472. key: string;
  35473. capture: null;
  35474. captureConstraint: null;
  35475. targets: string[];
  35476. })[];
  35477. /** @hidden */
  35478. static _TextureLoaders: IInternalTextureLoader[];
  35479. /**
  35480. * Returns the current npm package of the sdk
  35481. */
  35482. static get NpmPackage(): string;
  35483. /**
  35484. * Returns the current version of the framework
  35485. */
  35486. static get Version(): string;
  35487. /**
  35488. * Returns a string describing the current engine
  35489. */
  35490. get description(): string;
  35491. /**
  35492. * Gets or sets the epsilon value used by collision engine
  35493. */
  35494. static CollisionsEpsilon: number;
  35495. /**
  35496. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35497. */
  35498. static get ShadersRepository(): string;
  35499. static set ShadersRepository(value: string);
  35500. /** @hidden */
  35501. _shaderProcessor: IShaderProcessor;
  35502. /**
  35503. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35504. */
  35505. forcePOTTextures: boolean;
  35506. /**
  35507. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35508. */
  35509. isFullscreen: boolean;
  35510. /**
  35511. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35512. */
  35513. cullBackFaces: boolean;
  35514. /**
  35515. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35516. */
  35517. renderEvenInBackground: boolean;
  35518. /**
  35519. * Gets or sets a boolean indicating that cache can be kept between frames
  35520. */
  35521. preventCacheWipeBetweenFrames: boolean;
  35522. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35523. validateShaderPrograms: boolean;
  35524. /**
  35525. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35526. * This can provide greater z depth for distant objects.
  35527. */
  35528. useReverseDepthBuffer: boolean;
  35529. /**
  35530. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35531. */
  35532. disableUniformBuffers: boolean;
  35533. /** @hidden */
  35534. _uniformBuffers: UniformBuffer[];
  35535. /**
  35536. * Gets a boolean indicating that the engine supports uniform buffers
  35537. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35538. */
  35539. get supportsUniformBuffers(): boolean;
  35540. /** @hidden */
  35541. _gl: WebGLRenderingContext;
  35542. /** @hidden */
  35543. _webGLVersion: number;
  35544. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35545. protected _windowIsBackground: boolean;
  35546. protected _creationOptions: EngineOptions;
  35547. protected _highPrecisionShadersAllowed: boolean;
  35548. /** @hidden */
  35549. get _shouldUseHighPrecisionShader(): boolean;
  35550. /**
  35551. * Gets a boolean indicating that only power of 2 textures are supported
  35552. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35553. */
  35554. get needPOTTextures(): boolean;
  35555. /** @hidden */
  35556. _badOS: boolean;
  35557. /** @hidden */
  35558. _badDesktopOS: boolean;
  35559. private _hardwareScalingLevel;
  35560. /** @hidden */
  35561. _caps: EngineCapabilities;
  35562. private _isStencilEnable;
  35563. private _glVersion;
  35564. private _glRenderer;
  35565. private _glVendor;
  35566. /** @hidden */
  35567. _videoTextureSupported: boolean;
  35568. protected _renderingQueueLaunched: boolean;
  35569. protected _activeRenderLoops: (() => void)[];
  35570. /**
  35571. * Observable signaled when a context lost event is raised
  35572. */
  35573. onContextLostObservable: Observable<ThinEngine>;
  35574. /**
  35575. * Observable signaled when a context restored event is raised
  35576. */
  35577. onContextRestoredObservable: Observable<ThinEngine>;
  35578. private _onContextLost;
  35579. private _onContextRestored;
  35580. protected _contextWasLost: boolean;
  35581. /** @hidden */
  35582. _doNotHandleContextLost: boolean;
  35583. /**
  35584. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35585. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35586. */
  35587. get doNotHandleContextLost(): boolean;
  35588. set doNotHandleContextLost(value: boolean);
  35589. /**
  35590. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35591. */
  35592. disableVertexArrayObjects: boolean;
  35593. /** @hidden */
  35594. protected _colorWrite: boolean;
  35595. /** @hidden */
  35596. protected _colorWriteChanged: boolean;
  35597. /** @hidden */
  35598. protected _depthCullingState: DepthCullingState;
  35599. /** @hidden */
  35600. protected _stencilState: StencilState;
  35601. /** @hidden */
  35602. _alphaState: AlphaState;
  35603. /** @hidden */
  35604. _alphaMode: number;
  35605. /** @hidden */
  35606. _alphaEquation: number;
  35607. /** @hidden */
  35608. _internalTexturesCache: InternalTexture[];
  35609. /** @hidden */
  35610. protected _activeChannel: number;
  35611. private _currentTextureChannel;
  35612. /** @hidden */
  35613. protected _boundTexturesCache: {
  35614. [key: string]: Nullable<InternalTexture>;
  35615. };
  35616. /** @hidden */
  35617. protected _currentEffect: Nullable<Effect>;
  35618. /** @hidden */
  35619. protected _currentProgram: Nullable<WebGLProgram>;
  35620. private _compiledEffects;
  35621. private _vertexAttribArraysEnabled;
  35622. /** @hidden */
  35623. protected _cachedViewport: Nullable<IViewportLike>;
  35624. private _cachedVertexArrayObject;
  35625. /** @hidden */
  35626. protected _cachedVertexBuffers: any;
  35627. /** @hidden */
  35628. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35629. /** @hidden */
  35630. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35631. /** @hidden */
  35632. _currentRenderTarget: Nullable<InternalTexture>;
  35633. private _uintIndicesCurrentlySet;
  35634. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35635. /** @hidden */
  35636. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35637. /** @hidden */
  35638. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35639. private _currentBufferPointers;
  35640. private _currentInstanceLocations;
  35641. private _currentInstanceBuffers;
  35642. private _textureUnits;
  35643. /** @hidden */
  35644. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35645. /** @hidden */
  35646. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35647. /** @hidden */
  35648. _boundRenderFunction: any;
  35649. private _vaoRecordInProgress;
  35650. private _mustWipeVertexAttributes;
  35651. private _emptyTexture;
  35652. private _emptyCubeTexture;
  35653. private _emptyTexture3D;
  35654. private _emptyTexture2DArray;
  35655. /** @hidden */
  35656. _frameHandler: number;
  35657. private _nextFreeTextureSlots;
  35658. private _maxSimultaneousTextures;
  35659. private _activeRequests;
  35660. /** @hidden */
  35661. _transformTextureUrl: Nullable<(url: string) => string>;
  35662. /**
  35663. * Gets information about the current host
  35664. */
  35665. hostInformation: HostInformation;
  35666. protected get _supportsHardwareTextureRescaling(): boolean;
  35667. private _framebufferDimensionsObject;
  35668. /**
  35669. * sets the object from which width and height will be taken from when getting render width and height
  35670. * Will fallback to the gl object
  35671. * @param dimensions the framebuffer width and height that will be used.
  35672. */
  35673. set framebufferDimensionsObject(dimensions: Nullable<{
  35674. framebufferWidth: number;
  35675. framebufferHeight: number;
  35676. }>);
  35677. /**
  35678. * Gets the current viewport
  35679. */
  35680. get currentViewport(): Nullable<IViewportLike>;
  35681. /**
  35682. * Gets the default empty texture
  35683. */
  35684. get emptyTexture(): InternalTexture;
  35685. /**
  35686. * Gets the default empty 3D texture
  35687. */
  35688. get emptyTexture3D(): InternalTexture;
  35689. /**
  35690. * Gets the default empty 2D array texture
  35691. */
  35692. get emptyTexture2DArray(): InternalTexture;
  35693. /**
  35694. * Gets the default empty cube texture
  35695. */
  35696. get emptyCubeTexture(): InternalTexture;
  35697. /**
  35698. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35699. */
  35700. readonly premultipliedAlpha: boolean;
  35701. /**
  35702. * Observable event triggered before each texture is initialized
  35703. */
  35704. onBeforeTextureInitObservable: Observable<Texture>;
  35705. /**
  35706. * Creates a new engine
  35707. * @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
  35708. * @param antialias defines enable antialiasing (default: false)
  35709. * @param options defines further options to be sent to the getContext() function
  35710. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35711. */
  35712. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35713. private _rebuildInternalTextures;
  35714. private _rebuildEffects;
  35715. /**
  35716. * Gets a boolean indicating if all created effects are ready
  35717. * @returns true if all effects are ready
  35718. */
  35719. areAllEffectsReady(): boolean;
  35720. protected _rebuildBuffers(): void;
  35721. protected _initGLContext(): void;
  35722. /**
  35723. * Gets version of the current webGL context
  35724. */
  35725. get webGLVersion(): number;
  35726. /**
  35727. * Gets a string identifying the name of the class
  35728. * @returns "Engine" string
  35729. */
  35730. getClassName(): string;
  35731. /**
  35732. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35733. */
  35734. get isStencilEnable(): boolean;
  35735. /** @hidden */
  35736. _prepareWorkingCanvas(): void;
  35737. /**
  35738. * Reset the texture cache to empty state
  35739. */
  35740. resetTextureCache(): void;
  35741. /**
  35742. * Gets an object containing information about the current webGL context
  35743. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35744. */
  35745. getGlInfo(): {
  35746. vendor: string;
  35747. renderer: string;
  35748. version: string;
  35749. };
  35750. /**
  35751. * Defines the hardware scaling level.
  35752. * By default the hardware scaling level is computed from the window device ratio.
  35753. * 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.
  35754. * @param level defines the level to use
  35755. */
  35756. setHardwareScalingLevel(level: number): void;
  35757. /**
  35758. * Gets the current hardware scaling level.
  35759. * By default the hardware scaling level is computed from the window device ratio.
  35760. * 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.
  35761. * @returns a number indicating the current hardware scaling level
  35762. */
  35763. getHardwareScalingLevel(): number;
  35764. /**
  35765. * Gets the list of loaded textures
  35766. * @returns an array containing all loaded textures
  35767. */
  35768. getLoadedTexturesCache(): InternalTexture[];
  35769. /**
  35770. * Gets the object containing all engine capabilities
  35771. * @returns the EngineCapabilities object
  35772. */
  35773. getCaps(): EngineCapabilities;
  35774. /**
  35775. * stop executing a render loop function and remove it from the execution array
  35776. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35777. */
  35778. stopRenderLoop(renderFunction?: () => void): void;
  35779. /** @hidden */
  35780. _renderLoop(): void;
  35781. /**
  35782. * Gets the HTML canvas attached with the current webGL context
  35783. * @returns a HTML canvas
  35784. */
  35785. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35786. /**
  35787. * Gets host window
  35788. * @returns the host window object
  35789. */
  35790. getHostWindow(): Nullable<Window>;
  35791. /**
  35792. * Gets the current render width
  35793. * @param useScreen defines if screen size must be used (or the current render target if any)
  35794. * @returns a number defining the current render width
  35795. */
  35796. getRenderWidth(useScreen?: boolean): number;
  35797. /**
  35798. * Gets the current render height
  35799. * @param useScreen defines if screen size must be used (or the current render target if any)
  35800. * @returns a number defining the current render height
  35801. */
  35802. getRenderHeight(useScreen?: boolean): number;
  35803. /**
  35804. * Can be used to override the current requestAnimationFrame requester.
  35805. * @hidden
  35806. */
  35807. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35808. /**
  35809. * Register and execute a render loop. The engine can have more than one render function
  35810. * @param renderFunction defines the function to continuously execute
  35811. */
  35812. runRenderLoop(renderFunction: () => void): void;
  35813. /**
  35814. * Clear the current render buffer or the current render target (if any is set up)
  35815. * @param color defines the color to use
  35816. * @param backBuffer defines if the back buffer must be cleared
  35817. * @param depth defines if the depth buffer must be cleared
  35818. * @param stencil defines if the stencil buffer must be cleared
  35819. */
  35820. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35821. private _viewportCached;
  35822. /** @hidden */
  35823. _viewport(x: number, y: number, width: number, height: number): void;
  35824. /**
  35825. * Set the WebGL's viewport
  35826. * @param viewport defines the viewport element to be used
  35827. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35828. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35829. */
  35830. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35831. /**
  35832. * Begin a new frame
  35833. */
  35834. beginFrame(): void;
  35835. /**
  35836. * Enf the current frame
  35837. */
  35838. endFrame(): void;
  35839. /**
  35840. * Resize the view according to the canvas' size
  35841. */
  35842. resize(): void;
  35843. /**
  35844. * Force a specific size of the canvas
  35845. * @param width defines the new canvas' width
  35846. * @param height defines the new canvas' height
  35847. * @returns true if the size was changed
  35848. */
  35849. setSize(width: number, height: number): boolean;
  35850. /**
  35851. * Binds the frame buffer to the specified texture.
  35852. * @param texture The texture to render to or null for the default canvas
  35853. * @param faceIndex The face of the texture to render to in case of cube texture
  35854. * @param requiredWidth The width of the target to render to
  35855. * @param requiredHeight The height of the target to render to
  35856. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35857. * @param lodLevel defines the lod level to bind to the frame buffer
  35858. * @param layer defines the 2d array index to bind to frame buffer to
  35859. */
  35860. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35861. /** @hidden */
  35862. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35863. /**
  35864. * Unbind the current render target texture from the webGL context
  35865. * @param texture defines the render target texture to unbind
  35866. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35867. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35868. */
  35869. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35870. /**
  35871. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35872. */
  35873. flushFramebuffer(): void;
  35874. /**
  35875. * Unbind the current render target and bind the default framebuffer
  35876. */
  35877. restoreDefaultFramebuffer(): void;
  35878. /** @hidden */
  35879. protected _resetVertexBufferBinding(): void;
  35880. /**
  35881. * Creates a vertex buffer
  35882. * @param data the data for the vertex buffer
  35883. * @returns the new WebGL static buffer
  35884. */
  35885. createVertexBuffer(data: DataArray): DataBuffer;
  35886. private _createVertexBuffer;
  35887. /**
  35888. * Creates a dynamic vertex buffer
  35889. * @param data the data for the dynamic vertex buffer
  35890. * @returns the new WebGL dynamic buffer
  35891. */
  35892. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35893. protected _resetIndexBufferBinding(): void;
  35894. /**
  35895. * Creates a new index buffer
  35896. * @param indices defines the content of the index buffer
  35897. * @param updatable defines if the index buffer must be updatable
  35898. * @returns a new webGL buffer
  35899. */
  35900. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35901. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35902. /**
  35903. * Bind a webGL buffer to the webGL context
  35904. * @param buffer defines the buffer to bind
  35905. */
  35906. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35907. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35908. private bindBuffer;
  35909. /**
  35910. * update the bound buffer with the given data
  35911. * @param data defines the data to update
  35912. */
  35913. updateArrayBuffer(data: Float32Array): void;
  35914. private _vertexAttribPointer;
  35915. /** @hidden */
  35916. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35917. private _bindVertexBuffersAttributes;
  35918. /**
  35919. * Records a vertex array object
  35920. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35921. * @param vertexBuffers defines the list of vertex buffers to store
  35922. * @param indexBuffer defines the index buffer to store
  35923. * @param effect defines the effect to store
  35924. * @returns the new vertex array object
  35925. */
  35926. recordVertexArrayObject(vertexBuffers: {
  35927. [key: string]: VertexBuffer;
  35928. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35929. /**
  35930. * Bind a specific vertex array object
  35931. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35932. * @param vertexArrayObject defines the vertex array object to bind
  35933. * @param indexBuffer defines the index buffer to bind
  35934. */
  35935. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  35936. /**
  35937. * Bind webGl buffers directly to the webGL context
  35938. * @param vertexBuffer defines the vertex buffer to bind
  35939. * @param indexBuffer defines the index buffer to bind
  35940. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  35941. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  35942. * @param effect defines the effect associated with the vertex buffer
  35943. */
  35944. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  35945. private _unbindVertexArrayObject;
  35946. /**
  35947. * Bind a list of vertex buffers to the webGL context
  35948. * @param vertexBuffers defines the list of vertex buffers to bind
  35949. * @param indexBuffer defines the index buffer to bind
  35950. * @param effect defines the effect associated with the vertex buffers
  35951. */
  35952. bindBuffers(vertexBuffers: {
  35953. [key: string]: Nullable<VertexBuffer>;
  35954. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  35955. /**
  35956. * Unbind all instance attributes
  35957. */
  35958. unbindInstanceAttributes(): void;
  35959. /**
  35960. * Release and free the memory of a vertex array object
  35961. * @param vao defines the vertex array object to delete
  35962. */
  35963. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  35964. /** @hidden */
  35965. _releaseBuffer(buffer: DataBuffer): boolean;
  35966. protected _deleteBuffer(buffer: DataBuffer): void;
  35967. /**
  35968. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  35969. * @param instancesBuffer defines the webGL buffer to update and bind
  35970. * @param data defines the data to store in the buffer
  35971. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  35972. */
  35973. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  35974. /**
  35975. * Bind the content of a webGL buffer used with instantiation
  35976. * @param instancesBuffer defines the webGL buffer to bind
  35977. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  35978. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  35979. */
  35980. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  35981. /**
  35982. * Disable the instance attribute corresponding to the name in parameter
  35983. * @param name defines the name of the attribute to disable
  35984. */
  35985. disableInstanceAttributeByName(name: string): void;
  35986. /**
  35987. * Disable the instance attribute corresponding to the location in parameter
  35988. * @param attributeLocation defines the attribute location of the attribute to disable
  35989. */
  35990. disableInstanceAttribute(attributeLocation: number): void;
  35991. /**
  35992. * Disable the attribute corresponding to the location in parameter
  35993. * @param attributeLocation defines the attribute location of the attribute to disable
  35994. */
  35995. disableAttributeByIndex(attributeLocation: number): void;
  35996. /**
  35997. * Send a draw order
  35998. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  35999. * @param indexStart defines the starting index
  36000. * @param indexCount defines the number of index to draw
  36001. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36002. */
  36003. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36004. /**
  36005. * Draw a list of points
  36006. * @param verticesStart defines the index of first vertex to draw
  36007. * @param verticesCount defines the count of vertices to draw
  36008. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36009. */
  36010. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36011. /**
  36012. * Draw a list of unindexed primitives
  36013. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36014. * @param verticesStart defines the index of first vertex to draw
  36015. * @param verticesCount defines the count of vertices to draw
  36016. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36017. */
  36018. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36019. /**
  36020. * Draw a list of indexed primitives
  36021. * @param fillMode defines the primitive to use
  36022. * @param indexStart defines the starting index
  36023. * @param indexCount defines the number of index to draw
  36024. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36025. */
  36026. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36027. /**
  36028. * Draw a list of unindexed primitives
  36029. * @param fillMode defines the primitive to use
  36030. * @param verticesStart defines the index of first vertex to draw
  36031. * @param verticesCount defines the count of vertices to draw
  36032. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36033. */
  36034. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36035. private _drawMode;
  36036. /** @hidden */
  36037. protected _reportDrawCall(): void;
  36038. /** @hidden */
  36039. _releaseEffect(effect: Effect): void;
  36040. /** @hidden */
  36041. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36042. /**
  36043. * Create a new effect (used to store vertex/fragment shaders)
  36044. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36045. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36046. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36047. * @param samplers defines an array of string used to represent textures
  36048. * @param defines defines the string containing the defines to use to compile the shaders
  36049. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36050. * @param onCompiled defines a function to call when the effect creation is successful
  36051. * @param onError defines a function to call when the effect creation has failed
  36052. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36053. * @returns the new Effect
  36054. */
  36055. 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;
  36056. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36057. private _compileShader;
  36058. private _compileRawShader;
  36059. /** @hidden */
  36060. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36061. /**
  36062. * Directly creates a webGL program
  36063. * @param pipelineContext defines the pipeline context to attach to
  36064. * @param vertexCode defines the vertex shader code to use
  36065. * @param fragmentCode defines the fragment shader code to use
  36066. * @param context defines the webGL context to use (if not set, the current one will be used)
  36067. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36068. * @returns the new webGL program
  36069. */
  36070. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36071. /**
  36072. * Creates a webGL program
  36073. * @param pipelineContext defines the pipeline context to attach to
  36074. * @param vertexCode defines the vertex shader code to use
  36075. * @param fragmentCode defines the fragment shader code to use
  36076. * @param defines defines the string containing the defines to use to compile the shaders
  36077. * @param context defines the webGL context to use (if not set, the current one will be used)
  36078. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36079. * @returns the new webGL program
  36080. */
  36081. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36082. /**
  36083. * Creates a new pipeline context
  36084. * @returns the new pipeline
  36085. */
  36086. createPipelineContext(): IPipelineContext;
  36087. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36088. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36089. /** @hidden */
  36090. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36091. /** @hidden */
  36092. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36093. /** @hidden */
  36094. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36095. /**
  36096. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36097. * @param pipelineContext defines the pipeline context to use
  36098. * @param uniformsNames defines the list of uniform names
  36099. * @returns an array of webGL uniform locations
  36100. */
  36101. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36102. /**
  36103. * Gets the lsit of active attributes for a given webGL program
  36104. * @param pipelineContext defines the pipeline context to use
  36105. * @param attributesNames defines the list of attribute names to get
  36106. * @returns an array of indices indicating the offset of each attribute
  36107. */
  36108. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36109. /**
  36110. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36111. * @param effect defines the effect to activate
  36112. */
  36113. enableEffect(effect: Nullable<Effect>): void;
  36114. /**
  36115. * Set the value of an uniform to a number (int)
  36116. * @param uniform defines the webGL uniform location where to store the value
  36117. * @param value defines the int number to store
  36118. * @returns true if the value was set
  36119. */
  36120. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36121. /**
  36122. * Set the value of an uniform to an array of int32
  36123. * @param uniform defines the webGL uniform location where to store the value
  36124. * @param array defines the array of int32 to store
  36125. * @returns true if the value was set
  36126. */
  36127. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36128. /**
  36129. * Set the value of an uniform to an array of int32 (stored as vec2)
  36130. * @param uniform defines the webGL uniform location where to store the value
  36131. * @param array defines the array of int32 to store
  36132. * @returns true if the value was set
  36133. */
  36134. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36135. /**
  36136. * Set the value of an uniform to an array of int32 (stored as vec3)
  36137. * @param uniform defines the webGL uniform location where to store the value
  36138. * @param array defines the array of int32 to store
  36139. * @returns true if the value was set
  36140. */
  36141. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36142. /**
  36143. * Set the value of an uniform to an array of int32 (stored as vec4)
  36144. * @param uniform defines the webGL uniform location where to store the value
  36145. * @param array defines the array of int32 to store
  36146. * @returns true if the value was set
  36147. */
  36148. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  36149. /**
  36150. * Set the value of an uniform to an array of number
  36151. * @param uniform defines the webGL uniform location where to store the value
  36152. * @param array defines the array of number to store
  36153. * @returns true if the value was set
  36154. */
  36155. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36156. /**
  36157. * Set the value of an uniform to an array of number (stored as vec2)
  36158. * @param uniform defines the webGL uniform location where to store the value
  36159. * @param array defines the array of number to store
  36160. * @returns true if the value was set
  36161. */
  36162. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36163. /**
  36164. * Set the value of an uniform to an array of number (stored as vec3)
  36165. * @param uniform defines the webGL uniform location where to store the value
  36166. * @param array defines the array of number to store
  36167. * @returns true if the value was set
  36168. */
  36169. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36170. /**
  36171. * Set the value of an uniform to an array of number (stored as vec4)
  36172. * @param uniform defines the webGL uniform location where to store the value
  36173. * @param array defines the array of number to store
  36174. * @returns true if the value was set
  36175. */
  36176. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  36177. /**
  36178. * Set the value of an uniform to an array of float32 (stored as matrices)
  36179. * @param uniform defines the webGL uniform location where to store the value
  36180. * @param matrices defines the array of float32 to store
  36181. * @returns true if the value was set
  36182. */
  36183. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  36184. /**
  36185. * Set the value of an uniform to a matrix (3x3)
  36186. * @param uniform defines the webGL uniform location where to store the value
  36187. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36188. * @returns true if the value was set
  36189. */
  36190. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36191. /**
  36192. * Set the value of an uniform to a matrix (2x2)
  36193. * @param uniform defines the webGL uniform location where to store the value
  36194. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36195. * @returns true if the value was set
  36196. */
  36197. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  36198. /**
  36199. * Set the value of an uniform to a number (float)
  36200. * @param uniform defines the webGL uniform location where to store the value
  36201. * @param value defines the float number to store
  36202. * @returns true if the value was transfered
  36203. */
  36204. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  36205. /**
  36206. * Set the value of an uniform to a vec2
  36207. * @param uniform defines the webGL uniform location where to store the value
  36208. * @param x defines the 1st component of the value
  36209. * @param y defines the 2nd component of the value
  36210. * @returns true if the value was set
  36211. */
  36212. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  36213. /**
  36214. * Set the value of an uniform to a vec3
  36215. * @param uniform defines the webGL uniform location where to store the value
  36216. * @param x defines the 1st component of the value
  36217. * @param y defines the 2nd component of the value
  36218. * @param z defines the 3rd component of the value
  36219. * @returns true if the value was set
  36220. */
  36221. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  36222. /**
  36223. * Set the value of an uniform to a vec4
  36224. * @param uniform defines the webGL uniform location where to store the value
  36225. * @param x defines the 1st component of the value
  36226. * @param y defines the 2nd component of the value
  36227. * @param z defines the 3rd component of the value
  36228. * @param w defines the 4th component of the value
  36229. * @returns true if the value was set
  36230. */
  36231. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  36232. /**
  36233. * Apply all cached states (depth, culling, stencil and alpha)
  36234. */
  36235. applyStates(): void;
  36236. /**
  36237. * Enable or disable color writing
  36238. * @param enable defines the state to set
  36239. */
  36240. setColorWrite(enable: boolean): void;
  36241. /**
  36242. * Gets a boolean indicating if color writing is enabled
  36243. * @returns the current color writing state
  36244. */
  36245. getColorWrite(): boolean;
  36246. /**
  36247. * Gets the depth culling state manager
  36248. */
  36249. get depthCullingState(): DepthCullingState;
  36250. /**
  36251. * Gets the alpha state manager
  36252. */
  36253. get alphaState(): AlphaState;
  36254. /**
  36255. * Gets the stencil state manager
  36256. */
  36257. get stencilState(): StencilState;
  36258. /**
  36259. * Clears the list of texture accessible through engine.
  36260. * This can help preventing texture load conflict due to name collision.
  36261. */
  36262. clearInternalTexturesCache(): void;
  36263. /**
  36264. * Force the entire cache to be cleared
  36265. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36266. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36267. */
  36268. wipeCaches(bruteForce?: boolean): void;
  36269. /** @hidden */
  36270. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36271. min: number;
  36272. mag: number;
  36273. };
  36274. /** @hidden */
  36275. _createTexture(): WebGLTexture;
  36276. /**
  36277. * Usually called from Texture.ts.
  36278. * Passed information to create a WebGLTexture
  36279. * @param url defines a value which contains one of the following:
  36280. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36281. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36282. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36283. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36284. * @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)
  36285. * @param scene needed for loading to the correct scene
  36286. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36287. * @param onLoad optional callback to be called upon successful completion
  36288. * @param onError optional callback to be called upon failure
  36289. * @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
  36290. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36291. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36292. * @param forcedExtension defines the extension to use to pick the right loader
  36293. * @param mimeType defines an optional mime type
  36294. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36295. */
  36296. 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;
  36297. /**
  36298. * Loads an image as an HTMLImageElement.
  36299. * @param input url string, ArrayBuffer, or Blob to load
  36300. * @param onLoad callback called when the image successfully loads
  36301. * @param onError callback called when the image fails to load
  36302. * @param offlineProvider offline provider for caching
  36303. * @param mimeType optional mime type
  36304. * @returns the HTMLImageElement of the loaded image
  36305. * @hidden
  36306. */
  36307. 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>;
  36308. /**
  36309. * @hidden
  36310. */
  36311. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36312. private _unpackFlipYCached;
  36313. /**
  36314. * In case you are sharing the context with other applications, it might
  36315. * be interested to not cache the unpack flip y state to ensure a consistent
  36316. * value would be set.
  36317. */
  36318. enableUnpackFlipYCached: boolean;
  36319. /** @hidden */
  36320. _unpackFlipY(value: boolean): void;
  36321. /** @hidden */
  36322. _getUnpackAlignement(): number;
  36323. private _getTextureTarget;
  36324. /**
  36325. * Update the sampling mode of a given texture
  36326. * @param samplingMode defines the required sampling mode
  36327. * @param texture defines the texture to update
  36328. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36329. */
  36330. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36331. /**
  36332. * Update the sampling mode of a given texture
  36333. * @param texture defines the texture to update
  36334. * @param wrapU defines the texture wrap mode of the u coordinates
  36335. * @param wrapV defines the texture wrap mode of the v coordinates
  36336. * @param wrapR defines the texture wrap mode of the r coordinates
  36337. */
  36338. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36339. /** @hidden */
  36340. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36341. width: number;
  36342. height: number;
  36343. layers?: number;
  36344. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36345. /** @hidden */
  36346. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36347. /** @hidden */
  36348. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36349. /**
  36350. * Update a portion of an internal texture
  36351. * @param texture defines the texture to update
  36352. * @param imageData defines the data to store into the texture
  36353. * @param xOffset defines the x coordinates of the update rectangle
  36354. * @param yOffset defines the y coordinates of the update rectangle
  36355. * @param width defines the width of the update rectangle
  36356. * @param height defines the height of the update rectangle
  36357. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36358. * @param lod defines the lod level to update (0 by default)
  36359. */
  36360. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36361. /** @hidden */
  36362. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36363. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36364. private _prepareWebGLTexture;
  36365. /** @hidden */
  36366. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36367. private _getDepthStencilBuffer;
  36368. /** @hidden */
  36369. _releaseFramebufferObjects(texture: InternalTexture): void;
  36370. /** @hidden */
  36371. _releaseTexture(texture: InternalTexture): void;
  36372. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36373. protected _setProgram(program: WebGLProgram): void;
  36374. protected _boundUniforms: {
  36375. [key: number]: WebGLUniformLocation;
  36376. };
  36377. /**
  36378. * Binds an effect to the webGL context
  36379. * @param effect defines the effect to bind
  36380. */
  36381. bindSamplers(effect: Effect): void;
  36382. private _activateCurrentTexture;
  36383. /** @hidden */
  36384. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36385. /** @hidden */
  36386. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36387. /**
  36388. * Unbind all textures from the webGL context
  36389. */
  36390. unbindAllTextures(): void;
  36391. /**
  36392. * Sets a texture to the according uniform.
  36393. * @param channel The texture channel
  36394. * @param uniform The uniform to set
  36395. * @param texture The texture to apply
  36396. */
  36397. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36398. private _bindSamplerUniformToChannel;
  36399. private _getTextureWrapMode;
  36400. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36401. /**
  36402. * Sets an array of texture to the webGL context
  36403. * @param channel defines the channel where the texture array must be set
  36404. * @param uniform defines the associated uniform location
  36405. * @param textures defines the array of textures to bind
  36406. */
  36407. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36408. /** @hidden */
  36409. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36410. private _setTextureParameterFloat;
  36411. private _setTextureParameterInteger;
  36412. /**
  36413. * Unbind all vertex attributes from the webGL context
  36414. */
  36415. unbindAllAttributes(): void;
  36416. /**
  36417. * 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
  36418. */
  36419. releaseEffects(): void;
  36420. /**
  36421. * Dispose and release all associated resources
  36422. */
  36423. dispose(): void;
  36424. /**
  36425. * Attach a new callback raised when context lost event is fired
  36426. * @param callback defines the callback to call
  36427. */
  36428. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36429. /**
  36430. * Attach a new callback raised when context restored event is fired
  36431. * @param callback defines the callback to call
  36432. */
  36433. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36434. /**
  36435. * Get the current error code of the webGL context
  36436. * @returns the error code
  36437. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36438. */
  36439. getError(): number;
  36440. private _canRenderToFloatFramebuffer;
  36441. private _canRenderToHalfFloatFramebuffer;
  36442. private _canRenderToFramebuffer;
  36443. /** @hidden */
  36444. _getWebGLTextureType(type: number): number;
  36445. /** @hidden */
  36446. _getInternalFormat(format: number): number;
  36447. /** @hidden */
  36448. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36449. /** @hidden */
  36450. _getRGBAMultiSampleBufferFormat(type: number): number;
  36451. /** @hidden */
  36452. _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;
  36453. /**
  36454. * Loads a file from a url
  36455. * @param url url to load
  36456. * @param onSuccess callback called when the file successfully loads
  36457. * @param onProgress callback called while file is loading (if the server supports this mode)
  36458. * @param offlineProvider defines the offline provider for caching
  36459. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36460. * @param onError callback called when the file fails to load
  36461. * @returns a file request object
  36462. * @hidden
  36463. */
  36464. 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;
  36465. /**
  36466. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36467. * @param x defines the x coordinate of the rectangle where pixels must be read
  36468. * @param y defines the y coordinate of the rectangle where pixels must be read
  36469. * @param width defines the width of the rectangle where pixels must be read
  36470. * @param height defines the height of the rectangle where pixels must be read
  36471. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36472. * @returns a Uint8Array containing RGBA colors
  36473. */
  36474. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36475. private static _IsSupported;
  36476. private static _HasMajorPerformanceCaveat;
  36477. /**
  36478. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36479. */
  36480. static get IsSupported(): boolean;
  36481. /**
  36482. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36483. * @returns true if the engine can be created
  36484. * @ignorenaming
  36485. */
  36486. static isSupported(): boolean;
  36487. /**
  36488. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  36489. */
  36490. static get HasMajorPerformanceCaveat(): boolean;
  36491. /**
  36492. * Find the next highest power of two.
  36493. * @param x Number to start search from.
  36494. * @return Next highest power of two.
  36495. */
  36496. static CeilingPOT(x: number): number;
  36497. /**
  36498. * Find the next lowest power of two.
  36499. * @param x Number to start search from.
  36500. * @return Next lowest power of two.
  36501. */
  36502. static FloorPOT(x: number): number;
  36503. /**
  36504. * Find the nearest power of two.
  36505. * @param x Number to start search from.
  36506. * @return Next nearest power of two.
  36507. */
  36508. static NearestPOT(x: number): number;
  36509. /**
  36510. * Get the closest exponent of two
  36511. * @param value defines the value to approximate
  36512. * @param max defines the maximum value to return
  36513. * @param mode defines how to define the closest value
  36514. * @returns closest exponent of two of the given value
  36515. */
  36516. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36517. /**
  36518. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36519. * @param func - the function to be called
  36520. * @param requester - the object that will request the next frame. Falls back to window.
  36521. * @returns frame number
  36522. */
  36523. static QueueNewFrame(func: () => void, requester?: any): number;
  36524. /**
  36525. * Gets host document
  36526. * @returns the host document object
  36527. */
  36528. getHostDocument(): Nullable<Document>;
  36529. }
  36530. }
  36531. declare module BABYLON {
  36532. /**
  36533. * Class representing spherical harmonics coefficients to the 3rd degree
  36534. */
  36535. export class SphericalHarmonics {
  36536. /**
  36537. * Defines whether or not the harmonics have been prescaled for rendering.
  36538. */
  36539. preScaled: boolean;
  36540. /**
  36541. * The l0,0 coefficients of the spherical harmonics
  36542. */
  36543. l00: Vector3;
  36544. /**
  36545. * The l1,-1 coefficients of the spherical harmonics
  36546. */
  36547. l1_1: Vector3;
  36548. /**
  36549. * The l1,0 coefficients of the spherical harmonics
  36550. */
  36551. l10: Vector3;
  36552. /**
  36553. * The l1,1 coefficients of the spherical harmonics
  36554. */
  36555. l11: Vector3;
  36556. /**
  36557. * The l2,-2 coefficients of the spherical harmonics
  36558. */
  36559. l2_2: Vector3;
  36560. /**
  36561. * The l2,-1 coefficients of the spherical harmonics
  36562. */
  36563. l2_1: Vector3;
  36564. /**
  36565. * The l2,0 coefficients of the spherical harmonics
  36566. */
  36567. l20: Vector3;
  36568. /**
  36569. * The l2,1 coefficients of the spherical harmonics
  36570. */
  36571. l21: Vector3;
  36572. /**
  36573. * The l2,2 coefficients of the spherical harmonics
  36574. */
  36575. l22: Vector3;
  36576. /**
  36577. * Adds a light to the spherical harmonics
  36578. * @param direction the direction of the light
  36579. * @param color the color of the light
  36580. * @param deltaSolidAngle the delta solid angle of the light
  36581. */
  36582. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36583. /**
  36584. * Scales the spherical harmonics by the given amount
  36585. * @param scale the amount to scale
  36586. */
  36587. scaleInPlace(scale: number): void;
  36588. /**
  36589. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36590. *
  36591. * ```
  36592. * E_lm = A_l * L_lm
  36593. * ```
  36594. *
  36595. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36596. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36597. * the scaling factors are given in equation 9.
  36598. */
  36599. convertIncidentRadianceToIrradiance(): void;
  36600. /**
  36601. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36602. *
  36603. * ```
  36604. * L = (1/pi) * E * rho
  36605. * ```
  36606. *
  36607. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36608. */
  36609. convertIrradianceToLambertianRadiance(): void;
  36610. /**
  36611. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36612. * required operations at run time.
  36613. *
  36614. * This is simply done by scaling back the SH with Ylm constants parameter.
  36615. * The trigonometric part being applied by the shader at run time.
  36616. */
  36617. preScaleForRendering(): void;
  36618. /**
  36619. * Constructs a spherical harmonics from an array.
  36620. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36621. * @returns the spherical harmonics
  36622. */
  36623. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36624. /**
  36625. * Gets the spherical harmonics from polynomial
  36626. * @param polynomial the spherical polynomial
  36627. * @returns the spherical harmonics
  36628. */
  36629. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36630. }
  36631. /**
  36632. * Class representing spherical polynomial coefficients to the 3rd degree
  36633. */
  36634. export class SphericalPolynomial {
  36635. private _harmonics;
  36636. /**
  36637. * The spherical harmonics used to create the polynomials.
  36638. */
  36639. get preScaledHarmonics(): SphericalHarmonics;
  36640. /**
  36641. * The x coefficients of the spherical polynomial
  36642. */
  36643. x: Vector3;
  36644. /**
  36645. * The y coefficients of the spherical polynomial
  36646. */
  36647. y: Vector3;
  36648. /**
  36649. * The z coefficients of the spherical polynomial
  36650. */
  36651. z: Vector3;
  36652. /**
  36653. * The xx coefficients of the spherical polynomial
  36654. */
  36655. xx: Vector3;
  36656. /**
  36657. * The yy coefficients of the spherical polynomial
  36658. */
  36659. yy: Vector3;
  36660. /**
  36661. * The zz coefficients of the spherical polynomial
  36662. */
  36663. zz: Vector3;
  36664. /**
  36665. * The xy coefficients of the spherical polynomial
  36666. */
  36667. xy: Vector3;
  36668. /**
  36669. * The yz coefficients of the spherical polynomial
  36670. */
  36671. yz: Vector3;
  36672. /**
  36673. * The zx coefficients of the spherical polynomial
  36674. */
  36675. zx: Vector3;
  36676. /**
  36677. * Adds an ambient color to the spherical polynomial
  36678. * @param color the color to add
  36679. */
  36680. addAmbient(color: Color3): void;
  36681. /**
  36682. * Scales the spherical polynomial by the given amount
  36683. * @param scale the amount to scale
  36684. */
  36685. scaleInPlace(scale: number): void;
  36686. /**
  36687. * Gets the spherical polynomial from harmonics
  36688. * @param harmonics the spherical harmonics
  36689. * @returns the spherical polynomial
  36690. */
  36691. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36692. /**
  36693. * Constructs a spherical polynomial from an array.
  36694. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36695. * @returns the spherical polynomial
  36696. */
  36697. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36698. }
  36699. }
  36700. declare module BABYLON {
  36701. /**
  36702. * Defines the source of the internal texture
  36703. */
  36704. export enum InternalTextureSource {
  36705. /**
  36706. * The source of the texture data is unknown
  36707. */
  36708. Unknown = 0,
  36709. /**
  36710. * Texture data comes from an URL
  36711. */
  36712. Url = 1,
  36713. /**
  36714. * Texture data is only used for temporary storage
  36715. */
  36716. Temp = 2,
  36717. /**
  36718. * Texture data comes from raw data (ArrayBuffer)
  36719. */
  36720. Raw = 3,
  36721. /**
  36722. * Texture content is dynamic (video or dynamic texture)
  36723. */
  36724. Dynamic = 4,
  36725. /**
  36726. * Texture content is generated by rendering to it
  36727. */
  36728. RenderTarget = 5,
  36729. /**
  36730. * Texture content is part of a multi render target process
  36731. */
  36732. MultiRenderTarget = 6,
  36733. /**
  36734. * Texture data comes from a cube data file
  36735. */
  36736. Cube = 7,
  36737. /**
  36738. * Texture data comes from a raw cube data
  36739. */
  36740. CubeRaw = 8,
  36741. /**
  36742. * Texture data come from a prefiltered cube data file
  36743. */
  36744. CubePrefiltered = 9,
  36745. /**
  36746. * Texture content is raw 3D data
  36747. */
  36748. Raw3D = 10,
  36749. /**
  36750. * Texture content is raw 2D array data
  36751. */
  36752. Raw2DArray = 11,
  36753. /**
  36754. * Texture content is a depth texture
  36755. */
  36756. Depth = 12,
  36757. /**
  36758. * Texture data comes from a raw cube data encoded with RGBD
  36759. */
  36760. CubeRawRGBD = 13
  36761. }
  36762. /**
  36763. * Class used to store data associated with WebGL texture data for the engine
  36764. * This class should not be used directly
  36765. */
  36766. export class InternalTexture {
  36767. /** @hidden */
  36768. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36769. /**
  36770. * Defines if the texture is ready
  36771. */
  36772. isReady: boolean;
  36773. /**
  36774. * Defines if the texture is a cube texture
  36775. */
  36776. isCube: boolean;
  36777. /**
  36778. * Defines if the texture contains 3D data
  36779. */
  36780. is3D: boolean;
  36781. /**
  36782. * Defines if the texture contains 2D array data
  36783. */
  36784. is2DArray: boolean;
  36785. /**
  36786. * Defines if the texture contains multiview data
  36787. */
  36788. isMultiview: boolean;
  36789. /**
  36790. * Gets the URL used to load this texture
  36791. */
  36792. url: string;
  36793. /**
  36794. * Gets the sampling mode of the texture
  36795. */
  36796. samplingMode: number;
  36797. /**
  36798. * Gets a boolean indicating if the texture needs mipmaps generation
  36799. */
  36800. generateMipMaps: boolean;
  36801. /**
  36802. * Gets the number of samples used by the texture (WebGL2+ only)
  36803. */
  36804. samples: number;
  36805. /**
  36806. * Gets the type of the texture (int, float...)
  36807. */
  36808. type: number;
  36809. /**
  36810. * Gets the format of the texture (RGB, RGBA...)
  36811. */
  36812. format: number;
  36813. /**
  36814. * Observable called when the texture is loaded
  36815. */
  36816. onLoadedObservable: Observable<InternalTexture>;
  36817. /**
  36818. * Gets the width of the texture
  36819. */
  36820. width: number;
  36821. /**
  36822. * Gets the height of the texture
  36823. */
  36824. height: number;
  36825. /**
  36826. * Gets the depth of the texture
  36827. */
  36828. depth: number;
  36829. /**
  36830. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36831. */
  36832. baseWidth: number;
  36833. /**
  36834. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36835. */
  36836. baseHeight: number;
  36837. /**
  36838. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36839. */
  36840. baseDepth: number;
  36841. /**
  36842. * Gets a boolean indicating if the texture is inverted on Y axis
  36843. */
  36844. invertY: boolean;
  36845. /** @hidden */
  36846. _invertVScale: boolean;
  36847. /** @hidden */
  36848. _associatedChannel: number;
  36849. /** @hidden */
  36850. _source: InternalTextureSource;
  36851. /** @hidden */
  36852. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36853. /** @hidden */
  36854. _bufferView: Nullable<ArrayBufferView>;
  36855. /** @hidden */
  36856. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36857. /** @hidden */
  36858. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36859. /** @hidden */
  36860. _size: number;
  36861. /** @hidden */
  36862. _extension: string;
  36863. /** @hidden */
  36864. _files: Nullable<string[]>;
  36865. /** @hidden */
  36866. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36867. /** @hidden */
  36868. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36869. /** @hidden */
  36870. _framebuffer: Nullable<WebGLFramebuffer>;
  36871. /** @hidden */
  36872. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36873. /** @hidden */
  36874. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36875. /** @hidden */
  36876. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36877. /** @hidden */
  36878. _attachments: Nullable<number[]>;
  36879. /** @hidden */
  36880. _textureArray: Nullable<InternalTexture[]>;
  36881. /** @hidden */
  36882. _cachedCoordinatesMode: Nullable<number>;
  36883. /** @hidden */
  36884. _cachedWrapU: Nullable<number>;
  36885. /** @hidden */
  36886. _cachedWrapV: Nullable<number>;
  36887. /** @hidden */
  36888. _cachedWrapR: Nullable<number>;
  36889. /** @hidden */
  36890. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36891. /** @hidden */
  36892. _isDisabled: boolean;
  36893. /** @hidden */
  36894. _compression: Nullable<string>;
  36895. /** @hidden */
  36896. _generateStencilBuffer: boolean;
  36897. /** @hidden */
  36898. _generateDepthBuffer: boolean;
  36899. /** @hidden */
  36900. _comparisonFunction: number;
  36901. /** @hidden */
  36902. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36903. /** @hidden */
  36904. _lodGenerationScale: number;
  36905. /** @hidden */
  36906. _lodGenerationOffset: number;
  36907. /** @hidden */
  36908. _depthStencilTexture: Nullable<InternalTexture>;
  36909. /** @hidden */
  36910. _colorTextureArray: Nullable<WebGLTexture>;
  36911. /** @hidden */
  36912. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36913. /** @hidden */
  36914. _lodTextureHigh: Nullable<BaseTexture>;
  36915. /** @hidden */
  36916. _lodTextureMid: Nullable<BaseTexture>;
  36917. /** @hidden */
  36918. _lodTextureLow: Nullable<BaseTexture>;
  36919. /** @hidden */
  36920. _isRGBD: boolean;
  36921. /** @hidden */
  36922. _linearSpecularLOD: boolean;
  36923. /** @hidden */
  36924. _irradianceTexture: Nullable<BaseTexture>;
  36925. /** @hidden */
  36926. _webGLTexture: Nullable<WebGLTexture>;
  36927. /** @hidden */
  36928. _references: number;
  36929. /** @hidden */
  36930. _gammaSpace: Nullable<boolean>;
  36931. private _engine;
  36932. /**
  36933. * Gets the Engine the texture belongs to.
  36934. * @returns The babylon engine
  36935. */
  36936. getEngine(): ThinEngine;
  36937. /**
  36938. * Gets the data source type of the texture
  36939. */
  36940. get source(): InternalTextureSource;
  36941. /**
  36942. * Creates a new InternalTexture
  36943. * @param engine defines the engine to use
  36944. * @param source defines the type of data that will be used
  36945. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36946. */
  36947. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36948. /**
  36949. * Increments the number of references (ie. the number of Texture that point to it)
  36950. */
  36951. incrementReferences(): void;
  36952. /**
  36953. * Change the size of the texture (not the size of the content)
  36954. * @param width defines the new width
  36955. * @param height defines the new height
  36956. * @param depth defines the new depth (1 by default)
  36957. */
  36958. updateSize(width: int, height: int, depth?: int): void;
  36959. /** @hidden */
  36960. _rebuild(): void;
  36961. /** @hidden */
  36962. _swapAndDie(target: InternalTexture): void;
  36963. /**
  36964. * Dispose the current allocated resources
  36965. */
  36966. dispose(): void;
  36967. }
  36968. }
  36969. declare module BABYLON {
  36970. /**
  36971. * Class used to work with sound analyzer using fast fourier transform (FFT)
  36972. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36973. */
  36974. export class Analyser {
  36975. /**
  36976. * Gets or sets the smoothing
  36977. * @ignorenaming
  36978. */
  36979. SMOOTHING: number;
  36980. /**
  36981. * Gets or sets the FFT table size
  36982. * @ignorenaming
  36983. */
  36984. FFT_SIZE: number;
  36985. /**
  36986. * Gets or sets the bar graph amplitude
  36987. * @ignorenaming
  36988. */
  36989. BARGRAPHAMPLITUDE: number;
  36990. /**
  36991. * Gets or sets the position of the debug canvas
  36992. * @ignorenaming
  36993. */
  36994. DEBUGCANVASPOS: {
  36995. x: number;
  36996. y: number;
  36997. };
  36998. /**
  36999. * Gets or sets the debug canvas size
  37000. * @ignorenaming
  37001. */
  37002. DEBUGCANVASSIZE: {
  37003. width: number;
  37004. height: number;
  37005. };
  37006. private _byteFreqs;
  37007. private _byteTime;
  37008. private _floatFreqs;
  37009. private _webAudioAnalyser;
  37010. private _debugCanvas;
  37011. private _debugCanvasContext;
  37012. private _scene;
  37013. private _registerFunc;
  37014. private _audioEngine;
  37015. /**
  37016. * Creates a new analyser
  37017. * @param scene defines hosting scene
  37018. */
  37019. constructor(scene: Scene);
  37020. /**
  37021. * Get the number of data values you will have to play with for the visualization
  37022. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37023. * @returns a number
  37024. */
  37025. getFrequencyBinCount(): number;
  37026. /**
  37027. * Gets the current frequency data as a byte array
  37028. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37029. * @returns a Uint8Array
  37030. */
  37031. getByteFrequencyData(): Uint8Array;
  37032. /**
  37033. * Gets the current waveform as a byte array
  37034. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37035. * @returns a Uint8Array
  37036. */
  37037. getByteTimeDomainData(): Uint8Array;
  37038. /**
  37039. * Gets the current frequency data as a float array
  37040. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37041. * @returns a Float32Array
  37042. */
  37043. getFloatFrequencyData(): Float32Array;
  37044. /**
  37045. * Renders the debug canvas
  37046. */
  37047. drawDebugCanvas(): void;
  37048. /**
  37049. * Stops rendering the debug canvas and removes it
  37050. */
  37051. stopDebugCanvas(): void;
  37052. /**
  37053. * Connects two audio nodes
  37054. * @param inputAudioNode defines first node to connect
  37055. * @param outputAudioNode defines second node to connect
  37056. */
  37057. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37058. /**
  37059. * Releases all associated resources
  37060. */
  37061. dispose(): void;
  37062. }
  37063. }
  37064. declare module BABYLON {
  37065. /**
  37066. * This represents an audio engine and it is responsible
  37067. * to play, synchronize and analyse sounds throughout the application.
  37068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37069. */
  37070. export interface IAudioEngine extends IDisposable {
  37071. /**
  37072. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37073. */
  37074. readonly canUseWebAudio: boolean;
  37075. /**
  37076. * Gets the current AudioContext if available.
  37077. */
  37078. readonly audioContext: Nullable<AudioContext>;
  37079. /**
  37080. * The master gain node defines the global audio volume of your audio engine.
  37081. */
  37082. readonly masterGain: GainNode;
  37083. /**
  37084. * Gets whether or not mp3 are supported by your browser.
  37085. */
  37086. readonly isMP3supported: boolean;
  37087. /**
  37088. * Gets whether or not ogg are supported by your browser.
  37089. */
  37090. readonly isOGGsupported: boolean;
  37091. /**
  37092. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37093. * @ignoreNaming
  37094. */
  37095. WarnedWebAudioUnsupported: boolean;
  37096. /**
  37097. * Defines if the audio engine relies on a custom unlocked button.
  37098. * In this case, the embedded button will not be displayed.
  37099. */
  37100. useCustomUnlockedButton: boolean;
  37101. /**
  37102. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37103. */
  37104. readonly unlocked: boolean;
  37105. /**
  37106. * Event raised when audio has been unlocked on the browser.
  37107. */
  37108. onAudioUnlockedObservable: Observable<AudioEngine>;
  37109. /**
  37110. * Event raised when audio has been locked on the browser.
  37111. */
  37112. onAudioLockedObservable: Observable<AudioEngine>;
  37113. /**
  37114. * Flags the audio engine in Locked state.
  37115. * This happens due to new browser policies preventing audio to autoplay.
  37116. */
  37117. lock(): void;
  37118. /**
  37119. * Unlocks the audio engine once a user action has been done on the dom.
  37120. * This is helpful to resume play once browser policies have been satisfied.
  37121. */
  37122. unlock(): void;
  37123. /**
  37124. * Gets the global volume sets on the master gain.
  37125. * @returns the global volume if set or -1 otherwise
  37126. */
  37127. getGlobalVolume(): number;
  37128. /**
  37129. * Sets the global volume of your experience (sets on the master gain).
  37130. * @param newVolume Defines the new global volume of the application
  37131. */
  37132. setGlobalVolume(newVolume: number): void;
  37133. /**
  37134. * Connect the audio engine to an audio analyser allowing some amazing
  37135. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37136. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37137. * @param analyser The analyser to connect to the engine
  37138. */
  37139. connectToAnalyser(analyser: Analyser): void;
  37140. }
  37141. /**
  37142. * This represents the default audio engine used in babylon.
  37143. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37144. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37145. */
  37146. export class AudioEngine implements IAudioEngine {
  37147. private _audioContext;
  37148. private _audioContextInitialized;
  37149. private _muteButton;
  37150. private _hostElement;
  37151. /**
  37152. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37153. */
  37154. canUseWebAudio: boolean;
  37155. /**
  37156. * The master gain node defines the global audio volume of your audio engine.
  37157. */
  37158. masterGain: GainNode;
  37159. /**
  37160. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37161. * @ignoreNaming
  37162. */
  37163. WarnedWebAudioUnsupported: boolean;
  37164. /**
  37165. * Gets whether or not mp3 are supported by your browser.
  37166. */
  37167. isMP3supported: boolean;
  37168. /**
  37169. * Gets whether or not ogg are supported by your browser.
  37170. */
  37171. isOGGsupported: boolean;
  37172. /**
  37173. * Gets whether audio has been unlocked on the device.
  37174. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37175. * a user interaction has happened.
  37176. */
  37177. unlocked: boolean;
  37178. /**
  37179. * Defines if the audio engine relies on a custom unlocked button.
  37180. * In this case, the embedded button will not be displayed.
  37181. */
  37182. useCustomUnlockedButton: boolean;
  37183. /**
  37184. * Event raised when audio has been unlocked on the browser.
  37185. */
  37186. onAudioUnlockedObservable: Observable<AudioEngine>;
  37187. /**
  37188. * Event raised when audio has been locked on the browser.
  37189. */
  37190. onAudioLockedObservable: Observable<AudioEngine>;
  37191. /**
  37192. * Gets the current AudioContext if available.
  37193. */
  37194. get audioContext(): Nullable<AudioContext>;
  37195. private _connectedAnalyser;
  37196. /**
  37197. * Instantiates a new audio engine.
  37198. *
  37199. * There should be only one per page as some browsers restrict the number
  37200. * of audio contexts you can create.
  37201. * @param hostElement defines the host element where to display the mute icon if necessary
  37202. */
  37203. constructor(hostElement?: Nullable<HTMLElement>);
  37204. /**
  37205. * Flags the audio engine in Locked state.
  37206. * This happens due to new browser policies preventing audio to autoplay.
  37207. */
  37208. lock(): void;
  37209. /**
  37210. * Unlocks the audio engine once a user action has been done on the dom.
  37211. * This is helpful to resume play once browser policies have been satisfied.
  37212. */
  37213. unlock(): void;
  37214. private _resumeAudioContext;
  37215. private _initializeAudioContext;
  37216. private _tryToRun;
  37217. private _triggerRunningState;
  37218. private _triggerSuspendedState;
  37219. private _displayMuteButton;
  37220. private _moveButtonToTopLeft;
  37221. private _onResize;
  37222. private _hideMuteButton;
  37223. /**
  37224. * Destroy and release the resources associated with the audio ccontext.
  37225. */
  37226. dispose(): void;
  37227. /**
  37228. * Gets the global volume sets on the master gain.
  37229. * @returns the global volume if set or -1 otherwise
  37230. */
  37231. getGlobalVolume(): number;
  37232. /**
  37233. * Sets the global volume of your experience (sets on the master gain).
  37234. * @param newVolume Defines the new global volume of the application
  37235. */
  37236. setGlobalVolume(newVolume: number): void;
  37237. /**
  37238. * Connect the audio engine to an audio analyser allowing some amazing
  37239. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37241. * @param analyser The analyser to connect to the engine
  37242. */
  37243. connectToAnalyser(analyser: Analyser): void;
  37244. }
  37245. }
  37246. declare module BABYLON {
  37247. /**
  37248. * Interface used to present a loading screen while loading a scene
  37249. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37250. */
  37251. export interface ILoadingScreen {
  37252. /**
  37253. * Function called to display the loading screen
  37254. */
  37255. displayLoadingUI: () => void;
  37256. /**
  37257. * Function called to hide the loading screen
  37258. */
  37259. hideLoadingUI: () => void;
  37260. /**
  37261. * Gets or sets the color to use for the background
  37262. */
  37263. loadingUIBackgroundColor: string;
  37264. /**
  37265. * Gets or sets the text to display while loading
  37266. */
  37267. loadingUIText: string;
  37268. }
  37269. /**
  37270. * Class used for the default loading screen
  37271. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37272. */
  37273. export class DefaultLoadingScreen implements ILoadingScreen {
  37274. private _renderingCanvas;
  37275. private _loadingText;
  37276. private _loadingDivBackgroundColor;
  37277. private _loadingDiv;
  37278. private _loadingTextDiv;
  37279. /** Gets or sets the logo url to use for the default loading screen */
  37280. static DefaultLogoUrl: string;
  37281. /** Gets or sets the spinner url to use for the default loading screen */
  37282. static DefaultSpinnerUrl: string;
  37283. /**
  37284. * Creates a new default loading screen
  37285. * @param _renderingCanvas defines the canvas used to render the scene
  37286. * @param _loadingText defines the default text to display
  37287. * @param _loadingDivBackgroundColor defines the default background color
  37288. */
  37289. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37290. /**
  37291. * Function called to display the loading screen
  37292. */
  37293. displayLoadingUI(): void;
  37294. /**
  37295. * Function called to hide the loading screen
  37296. */
  37297. hideLoadingUI(): void;
  37298. /**
  37299. * Gets or sets the text to display while loading
  37300. */
  37301. set loadingUIText(text: string);
  37302. get loadingUIText(): string;
  37303. /**
  37304. * Gets or sets the color to use for the background
  37305. */
  37306. get loadingUIBackgroundColor(): string;
  37307. set loadingUIBackgroundColor(color: string);
  37308. private _resizeLoadingUI;
  37309. }
  37310. }
  37311. declare module BABYLON {
  37312. /**
  37313. * Interface for any object that can request an animation frame
  37314. */
  37315. export interface ICustomAnimationFrameRequester {
  37316. /**
  37317. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37318. */
  37319. renderFunction?: Function;
  37320. /**
  37321. * Called to request the next frame to render to
  37322. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37323. */
  37324. requestAnimationFrame: Function;
  37325. /**
  37326. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37327. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37328. */
  37329. requestID?: number;
  37330. }
  37331. }
  37332. declare module BABYLON {
  37333. /**
  37334. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37335. */
  37336. export class PerformanceMonitor {
  37337. private _enabled;
  37338. private _rollingFrameTime;
  37339. private _lastFrameTimeMs;
  37340. /**
  37341. * constructor
  37342. * @param frameSampleSize The number of samples required to saturate the sliding window
  37343. */
  37344. constructor(frameSampleSize?: number);
  37345. /**
  37346. * Samples current frame
  37347. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37348. */
  37349. sampleFrame(timeMs?: number): void;
  37350. /**
  37351. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37352. */
  37353. get averageFrameTime(): number;
  37354. /**
  37355. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37356. */
  37357. get averageFrameTimeVariance(): number;
  37358. /**
  37359. * Returns the frame time of the most recent frame
  37360. */
  37361. get instantaneousFrameTime(): number;
  37362. /**
  37363. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37364. */
  37365. get averageFPS(): number;
  37366. /**
  37367. * Returns the average framerate in frames per second using the most recent frame time
  37368. */
  37369. get instantaneousFPS(): number;
  37370. /**
  37371. * Returns true if enough samples have been taken to completely fill the sliding window
  37372. */
  37373. get isSaturated(): boolean;
  37374. /**
  37375. * Enables contributions to the sliding window sample set
  37376. */
  37377. enable(): void;
  37378. /**
  37379. * Disables contributions to the sliding window sample set
  37380. * Samples will not be interpolated over the disabled period
  37381. */
  37382. disable(): void;
  37383. /**
  37384. * Returns true if sampling is enabled
  37385. */
  37386. get isEnabled(): boolean;
  37387. /**
  37388. * Resets performance monitor
  37389. */
  37390. reset(): void;
  37391. }
  37392. /**
  37393. * RollingAverage
  37394. *
  37395. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37396. */
  37397. export class RollingAverage {
  37398. /**
  37399. * Current average
  37400. */
  37401. average: number;
  37402. /**
  37403. * Current variance
  37404. */
  37405. variance: number;
  37406. protected _samples: Array<number>;
  37407. protected _sampleCount: number;
  37408. protected _pos: number;
  37409. protected _m2: number;
  37410. /**
  37411. * constructor
  37412. * @param length The number of samples required to saturate the sliding window
  37413. */
  37414. constructor(length: number);
  37415. /**
  37416. * Adds a sample to the sample set
  37417. * @param v The sample value
  37418. */
  37419. add(v: number): void;
  37420. /**
  37421. * Returns previously added values or null if outside of history or outside the sliding window domain
  37422. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37423. * @return Value previously recorded with add() or null if outside of range
  37424. */
  37425. history(i: number): number;
  37426. /**
  37427. * Returns true if enough samples have been taken to completely fill the sliding window
  37428. * @return true if sample-set saturated
  37429. */
  37430. isSaturated(): boolean;
  37431. /**
  37432. * Resets the rolling average (equivalent to 0 samples taken so far)
  37433. */
  37434. reset(): void;
  37435. /**
  37436. * Wraps a value around the sample range boundaries
  37437. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37438. * @return Wrapped position in sample range
  37439. */
  37440. protected _wrapPosition(i: number): number;
  37441. }
  37442. }
  37443. declare module BABYLON {
  37444. /**
  37445. * This class is used to track a performance counter which is number based.
  37446. * The user has access to many properties which give statistics of different nature.
  37447. *
  37448. * The implementer can track two kinds of Performance Counter: time and count.
  37449. * 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.
  37450. * 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.
  37451. */
  37452. export class PerfCounter {
  37453. /**
  37454. * Gets or sets a global boolean to turn on and off all the counters
  37455. */
  37456. static Enabled: boolean;
  37457. /**
  37458. * Returns the smallest value ever
  37459. */
  37460. get min(): number;
  37461. /**
  37462. * Returns the biggest value ever
  37463. */
  37464. get max(): number;
  37465. /**
  37466. * Returns the average value since the performance counter is running
  37467. */
  37468. get average(): number;
  37469. /**
  37470. * Returns the average value of the last second the counter was monitored
  37471. */
  37472. get lastSecAverage(): number;
  37473. /**
  37474. * Returns the current value
  37475. */
  37476. get current(): number;
  37477. /**
  37478. * Gets the accumulated total
  37479. */
  37480. get total(): number;
  37481. /**
  37482. * Gets the total value count
  37483. */
  37484. get count(): number;
  37485. /**
  37486. * Creates a new counter
  37487. */
  37488. constructor();
  37489. /**
  37490. * Call this method to start monitoring a new frame.
  37491. * 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.
  37492. */
  37493. fetchNewFrame(): void;
  37494. /**
  37495. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37496. * @param newCount the count value to add to the monitored count
  37497. * @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.
  37498. */
  37499. addCount(newCount: number, fetchResult: boolean): void;
  37500. /**
  37501. * Start monitoring this performance counter
  37502. */
  37503. beginMonitoring(): void;
  37504. /**
  37505. * Compute the time lapsed since the previous beginMonitoring() call.
  37506. * @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
  37507. */
  37508. endMonitoring(newFrame?: boolean): void;
  37509. private _fetchResult;
  37510. private _startMonitoringTime;
  37511. private _min;
  37512. private _max;
  37513. private _average;
  37514. private _current;
  37515. private _totalValueCount;
  37516. private _totalAccumulated;
  37517. private _lastSecAverage;
  37518. private _lastSecAccumulated;
  37519. private _lastSecTime;
  37520. private _lastSecValueCount;
  37521. }
  37522. }
  37523. declare module BABYLON {
  37524. interface ThinEngine {
  37525. /** @hidden */
  37526. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37527. }
  37528. }
  37529. declare module BABYLON {
  37530. /**
  37531. * Defines the interface used by display changed events
  37532. */
  37533. export interface IDisplayChangedEventArgs {
  37534. /** Gets the vrDisplay object (if any) */
  37535. vrDisplay: Nullable<any>;
  37536. /** Gets a boolean indicating if webVR is supported */
  37537. vrSupported: boolean;
  37538. }
  37539. /**
  37540. * Defines the interface used by objects containing a viewport (like a camera)
  37541. */
  37542. interface IViewportOwnerLike {
  37543. /**
  37544. * Gets or sets the viewport
  37545. */
  37546. viewport: IViewportLike;
  37547. }
  37548. /**
  37549. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37550. */
  37551. export class Engine extends ThinEngine {
  37552. /** Defines that alpha blending is disabled */
  37553. static readonly ALPHA_DISABLE: number;
  37554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37555. static readonly ALPHA_ADD: number;
  37556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37557. static readonly ALPHA_COMBINE: number;
  37558. /** Defines that alpha blending to DEST - SRC * DEST */
  37559. static readonly ALPHA_SUBTRACT: number;
  37560. /** Defines that alpha blending to SRC * DEST */
  37561. static readonly ALPHA_MULTIPLY: number;
  37562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37563. static readonly ALPHA_MAXIMIZED: number;
  37564. /** Defines that alpha blending to SRC + DEST */
  37565. static readonly ALPHA_ONEONE: number;
  37566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37567. static readonly ALPHA_PREMULTIPLIED: number;
  37568. /**
  37569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37571. */
  37572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37574. static readonly ALPHA_INTERPOLATE: number;
  37575. /**
  37576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37578. */
  37579. static readonly ALPHA_SCREENMODE: number;
  37580. /** Defines that the ressource is not delayed*/
  37581. static readonly DELAYLOADSTATE_NONE: number;
  37582. /** Defines that the ressource was successfully delay loaded */
  37583. static readonly DELAYLOADSTATE_LOADED: number;
  37584. /** Defines that the ressource is currently delay loading */
  37585. static readonly DELAYLOADSTATE_LOADING: number;
  37586. /** Defines that the ressource is delayed and has not started loading */
  37587. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37588. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37589. static readonly NEVER: number;
  37590. /** 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 */
  37591. static readonly ALWAYS: number;
  37592. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37593. static readonly LESS: number;
  37594. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37595. static readonly EQUAL: number;
  37596. /** 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 */
  37597. static readonly LEQUAL: number;
  37598. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37599. static readonly GREATER: number;
  37600. /** 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 */
  37601. static readonly GEQUAL: number;
  37602. /** 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 */
  37603. static readonly NOTEQUAL: number;
  37604. /** Passed to stencilOperation to specify that stencil value must be kept */
  37605. static readonly KEEP: number;
  37606. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37607. static readonly REPLACE: number;
  37608. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37609. static readonly INCR: number;
  37610. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37611. static readonly DECR: number;
  37612. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37613. static readonly INVERT: number;
  37614. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37615. static readonly INCR_WRAP: number;
  37616. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37617. static readonly DECR_WRAP: number;
  37618. /** Texture is not repeating outside of 0..1 UVs */
  37619. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37620. /** Texture is repeating outside of 0..1 UVs */
  37621. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37622. /** Texture is repeating and mirrored */
  37623. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37624. /** ALPHA */
  37625. static readonly TEXTUREFORMAT_ALPHA: number;
  37626. /** LUMINANCE */
  37627. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37628. /** LUMINANCE_ALPHA */
  37629. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37630. /** RGB */
  37631. static readonly TEXTUREFORMAT_RGB: number;
  37632. /** RGBA */
  37633. static readonly TEXTUREFORMAT_RGBA: number;
  37634. /** RED */
  37635. static readonly TEXTUREFORMAT_RED: number;
  37636. /** RED (2nd reference) */
  37637. static readonly TEXTUREFORMAT_R: number;
  37638. /** RG */
  37639. static readonly TEXTUREFORMAT_RG: number;
  37640. /** RED_INTEGER */
  37641. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37642. /** RED_INTEGER (2nd reference) */
  37643. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37644. /** RG_INTEGER */
  37645. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37646. /** RGB_INTEGER */
  37647. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37648. /** RGBA_INTEGER */
  37649. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37650. /** UNSIGNED_BYTE */
  37651. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37652. /** UNSIGNED_BYTE (2nd reference) */
  37653. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37654. /** FLOAT */
  37655. static readonly TEXTURETYPE_FLOAT: number;
  37656. /** HALF_FLOAT */
  37657. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37658. /** BYTE */
  37659. static readonly TEXTURETYPE_BYTE: number;
  37660. /** SHORT */
  37661. static readonly TEXTURETYPE_SHORT: number;
  37662. /** UNSIGNED_SHORT */
  37663. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37664. /** INT */
  37665. static readonly TEXTURETYPE_INT: number;
  37666. /** UNSIGNED_INT */
  37667. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37668. /** UNSIGNED_SHORT_4_4_4_4 */
  37669. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37670. /** UNSIGNED_SHORT_5_5_5_1 */
  37671. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37672. /** UNSIGNED_SHORT_5_6_5 */
  37673. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37674. /** UNSIGNED_INT_2_10_10_10_REV */
  37675. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37676. /** UNSIGNED_INT_24_8 */
  37677. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37678. /** UNSIGNED_INT_10F_11F_11F_REV */
  37679. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37680. /** UNSIGNED_INT_5_9_9_9_REV */
  37681. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37682. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37683. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37684. /** nearest is mag = nearest and min = nearest and mip = linear */
  37685. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37686. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37687. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37688. /** Trilinear is mag = linear and min = linear and mip = linear */
  37689. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37690. /** nearest is mag = nearest and min = nearest and mip = linear */
  37691. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37692. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37693. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37694. /** Trilinear is mag = linear and min = linear and mip = linear */
  37695. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37696. /** mag = nearest and min = nearest and mip = nearest */
  37697. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37698. /** mag = nearest and min = linear and mip = nearest */
  37699. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37700. /** mag = nearest and min = linear and mip = linear */
  37701. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37702. /** mag = nearest and min = linear and mip = none */
  37703. static readonly TEXTURE_NEAREST_LINEAR: number;
  37704. /** mag = nearest and min = nearest and mip = none */
  37705. static readonly TEXTURE_NEAREST_NEAREST: number;
  37706. /** mag = linear and min = nearest and mip = nearest */
  37707. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37708. /** mag = linear and min = nearest and mip = linear */
  37709. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37710. /** mag = linear and min = linear and mip = none */
  37711. static readonly TEXTURE_LINEAR_LINEAR: number;
  37712. /** mag = linear and min = nearest and mip = none */
  37713. static readonly TEXTURE_LINEAR_NEAREST: number;
  37714. /** Explicit coordinates mode */
  37715. static readonly TEXTURE_EXPLICIT_MODE: number;
  37716. /** Spherical coordinates mode */
  37717. static readonly TEXTURE_SPHERICAL_MODE: number;
  37718. /** Planar coordinates mode */
  37719. static readonly TEXTURE_PLANAR_MODE: number;
  37720. /** Cubic coordinates mode */
  37721. static readonly TEXTURE_CUBIC_MODE: number;
  37722. /** Projection coordinates mode */
  37723. static readonly TEXTURE_PROJECTION_MODE: number;
  37724. /** Skybox coordinates mode */
  37725. static readonly TEXTURE_SKYBOX_MODE: number;
  37726. /** Inverse Cubic coordinates mode */
  37727. static readonly TEXTURE_INVCUBIC_MODE: number;
  37728. /** Equirectangular coordinates mode */
  37729. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37730. /** Equirectangular Fixed coordinates mode */
  37731. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37732. /** Equirectangular Fixed Mirrored coordinates mode */
  37733. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37734. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37735. static readonly SCALEMODE_FLOOR: number;
  37736. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37737. static readonly SCALEMODE_NEAREST: number;
  37738. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37739. static readonly SCALEMODE_CEILING: number;
  37740. /**
  37741. * Returns the current npm package of the sdk
  37742. */
  37743. static get NpmPackage(): string;
  37744. /**
  37745. * Returns the current version of the framework
  37746. */
  37747. static get Version(): string;
  37748. /** Gets the list of created engines */
  37749. static get Instances(): Engine[];
  37750. /**
  37751. * Gets the latest created engine
  37752. */
  37753. static get LastCreatedEngine(): Nullable<Engine>;
  37754. /**
  37755. * Gets the latest created scene
  37756. */
  37757. static get LastCreatedScene(): Nullable<Scene>;
  37758. /**
  37759. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37760. * @param flag defines which part of the materials must be marked as dirty
  37761. * @param predicate defines a predicate used to filter which materials should be affected
  37762. */
  37763. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37764. /**
  37765. * Method called to create the default loading screen.
  37766. * This can be overriden in your own app.
  37767. * @param canvas The rendering canvas element
  37768. * @returns The loading screen
  37769. */
  37770. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37771. /**
  37772. * Method called to create the default rescale post process on each engine.
  37773. */
  37774. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37775. /**
  37776. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37777. **/
  37778. enableOfflineSupport: boolean;
  37779. /**
  37780. * 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)
  37781. **/
  37782. disableManifestCheck: boolean;
  37783. /**
  37784. * Gets the list of created scenes
  37785. */
  37786. scenes: Scene[];
  37787. /**
  37788. * Event raised when a new scene is created
  37789. */
  37790. onNewSceneAddedObservable: Observable<Scene>;
  37791. /**
  37792. * Gets the list of created postprocesses
  37793. */
  37794. postProcesses: PostProcess[];
  37795. /**
  37796. * Gets a boolean indicating if the pointer is currently locked
  37797. */
  37798. isPointerLock: boolean;
  37799. /**
  37800. * Observable event triggered each time the rendering canvas is resized
  37801. */
  37802. onResizeObservable: Observable<Engine>;
  37803. /**
  37804. * Observable event triggered each time the canvas loses focus
  37805. */
  37806. onCanvasBlurObservable: Observable<Engine>;
  37807. /**
  37808. * Observable event triggered each time the canvas gains focus
  37809. */
  37810. onCanvasFocusObservable: Observable<Engine>;
  37811. /**
  37812. * Observable event triggered each time the canvas receives pointerout event
  37813. */
  37814. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37815. /**
  37816. * Observable raised when the engine begins a new frame
  37817. */
  37818. onBeginFrameObservable: Observable<Engine>;
  37819. /**
  37820. * If set, will be used to request the next animation frame for the render loop
  37821. */
  37822. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37823. /**
  37824. * Observable raised when the engine ends the current frame
  37825. */
  37826. onEndFrameObservable: Observable<Engine>;
  37827. /**
  37828. * Observable raised when the engine is about to compile a shader
  37829. */
  37830. onBeforeShaderCompilationObservable: Observable<Engine>;
  37831. /**
  37832. * Observable raised when the engine has jsut compiled a shader
  37833. */
  37834. onAfterShaderCompilationObservable: Observable<Engine>;
  37835. /**
  37836. * Gets the audio engine
  37837. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37838. * @ignorenaming
  37839. */
  37840. static audioEngine: IAudioEngine;
  37841. /**
  37842. * Default AudioEngine factory responsible of creating the Audio Engine.
  37843. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37844. */
  37845. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37846. /**
  37847. * Default offline support factory responsible of creating a tool used to store data locally.
  37848. * By default, this will create a Database object if the workload has been embedded.
  37849. */
  37850. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37851. private _loadingScreen;
  37852. private _pointerLockRequested;
  37853. private _rescalePostProcess;
  37854. private _deterministicLockstep;
  37855. private _lockstepMaxSteps;
  37856. private _timeStep;
  37857. protected get _supportsHardwareTextureRescaling(): boolean;
  37858. private _fps;
  37859. private _deltaTime;
  37860. /** @hidden */
  37861. _drawCalls: PerfCounter;
  37862. /** 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 */
  37863. canvasTabIndex: number;
  37864. /**
  37865. * Turn this value on if you want to pause FPS computation when in background
  37866. */
  37867. disablePerformanceMonitorInBackground: boolean;
  37868. private _performanceMonitor;
  37869. /**
  37870. * Gets the performance monitor attached to this engine
  37871. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37872. */
  37873. get performanceMonitor(): PerformanceMonitor;
  37874. private _onFocus;
  37875. private _onBlur;
  37876. private _onCanvasPointerOut;
  37877. private _onCanvasBlur;
  37878. private _onCanvasFocus;
  37879. private _onFullscreenChange;
  37880. private _onPointerLockChange;
  37881. /**
  37882. * Gets the HTML element used to attach event listeners
  37883. * @returns a HTML element
  37884. */
  37885. getInputElement(): Nullable<HTMLElement>;
  37886. /**
  37887. * Creates a new engine
  37888. * @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
  37889. * @param antialias defines enable antialiasing (default: false)
  37890. * @param options defines further options to be sent to the getContext() function
  37891. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  37892. */
  37893. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  37894. /**
  37895. * Gets current aspect ratio
  37896. * @param viewportOwner defines the camera to use to get the aspect ratio
  37897. * @param useScreen defines if screen size must be used (or the current render target if any)
  37898. * @returns a number defining the aspect ratio
  37899. */
  37900. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  37901. /**
  37902. * Gets current screen aspect ratio
  37903. * @returns a number defining the aspect ratio
  37904. */
  37905. getScreenAspectRatio(): number;
  37906. /**
  37907. * Gets the client rect of the HTML canvas attached with the current webGL context
  37908. * @returns a client rectanglee
  37909. */
  37910. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  37911. /**
  37912. * Gets the client rect of the HTML element used for events
  37913. * @returns a client rectanglee
  37914. */
  37915. getInputElementClientRect(): Nullable<ClientRect>;
  37916. /**
  37917. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  37918. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37919. * @returns true if engine is in deterministic lock step mode
  37920. */
  37921. isDeterministicLockStep(): boolean;
  37922. /**
  37923. * Gets the max steps when engine is running in deterministic lock step
  37924. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37925. * @returns the max steps
  37926. */
  37927. getLockstepMaxSteps(): number;
  37928. /**
  37929. * Returns the time in ms between steps when using deterministic lock step.
  37930. * @returns time step in (ms)
  37931. */
  37932. getTimeStep(): number;
  37933. /**
  37934. * Force the mipmap generation for the given render target texture
  37935. * @param texture defines the render target texture to use
  37936. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  37937. */
  37938. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  37939. /** States */
  37940. /**
  37941. * Set various states to the webGL context
  37942. * @param culling defines backface culling state
  37943. * @param zOffset defines the value to apply to zOffset (0 by default)
  37944. * @param force defines if states must be applied even if cache is up to date
  37945. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  37946. */
  37947. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  37948. /**
  37949. * Set the z offset to apply to current rendering
  37950. * @param value defines the offset to apply
  37951. */
  37952. setZOffset(value: number): void;
  37953. /**
  37954. * Gets the current value of the zOffset
  37955. * @returns the current zOffset state
  37956. */
  37957. getZOffset(): number;
  37958. /**
  37959. * Enable or disable depth buffering
  37960. * @param enable defines the state to set
  37961. */
  37962. setDepthBuffer(enable: boolean): void;
  37963. /**
  37964. * Gets a boolean indicating if depth writing is enabled
  37965. * @returns the current depth writing state
  37966. */
  37967. getDepthWrite(): boolean;
  37968. /**
  37969. * Enable or disable depth writing
  37970. * @param enable defines the state to set
  37971. */
  37972. setDepthWrite(enable: boolean): void;
  37973. /**
  37974. * Gets a boolean indicating if stencil buffer is enabled
  37975. * @returns the current stencil buffer state
  37976. */
  37977. getStencilBuffer(): boolean;
  37978. /**
  37979. * Enable or disable the stencil buffer
  37980. * @param enable defines if the stencil buffer must be enabled or disabled
  37981. */
  37982. setStencilBuffer(enable: boolean): void;
  37983. /**
  37984. * Gets the current stencil mask
  37985. * @returns a number defining the new stencil mask to use
  37986. */
  37987. getStencilMask(): number;
  37988. /**
  37989. * Sets the current stencil mask
  37990. * @param mask defines the new stencil mask to use
  37991. */
  37992. setStencilMask(mask: number): void;
  37993. /**
  37994. * Gets the current stencil function
  37995. * @returns a number defining the stencil function to use
  37996. */
  37997. getStencilFunction(): number;
  37998. /**
  37999. * Gets the current stencil reference value
  38000. * @returns a number defining the stencil reference value to use
  38001. */
  38002. getStencilFunctionReference(): number;
  38003. /**
  38004. * Gets the current stencil mask
  38005. * @returns a number defining the stencil mask to use
  38006. */
  38007. getStencilFunctionMask(): number;
  38008. /**
  38009. * Sets the current stencil function
  38010. * @param stencilFunc defines the new stencil function to use
  38011. */
  38012. setStencilFunction(stencilFunc: number): void;
  38013. /**
  38014. * Sets the current stencil reference
  38015. * @param reference defines the new stencil reference to use
  38016. */
  38017. setStencilFunctionReference(reference: number): void;
  38018. /**
  38019. * Sets the current stencil mask
  38020. * @param mask defines the new stencil mask to use
  38021. */
  38022. setStencilFunctionMask(mask: number): void;
  38023. /**
  38024. * Gets the current stencil operation when stencil fails
  38025. * @returns a number defining stencil operation to use when stencil fails
  38026. */
  38027. getStencilOperationFail(): number;
  38028. /**
  38029. * Gets the current stencil operation when depth fails
  38030. * @returns a number defining stencil operation to use when depth fails
  38031. */
  38032. getStencilOperationDepthFail(): number;
  38033. /**
  38034. * Gets the current stencil operation when stencil passes
  38035. * @returns a number defining stencil operation to use when stencil passes
  38036. */
  38037. getStencilOperationPass(): number;
  38038. /**
  38039. * Sets the stencil operation to use when stencil fails
  38040. * @param operation defines the stencil operation to use when stencil fails
  38041. */
  38042. setStencilOperationFail(operation: number): void;
  38043. /**
  38044. * Sets the stencil operation to use when depth fails
  38045. * @param operation defines the stencil operation to use when depth fails
  38046. */
  38047. setStencilOperationDepthFail(operation: number): void;
  38048. /**
  38049. * Sets the stencil operation to use when stencil passes
  38050. * @param operation defines the stencil operation to use when stencil passes
  38051. */
  38052. setStencilOperationPass(operation: number): void;
  38053. /**
  38054. * Sets a boolean indicating if the dithering state is enabled or disabled
  38055. * @param value defines the dithering state
  38056. */
  38057. setDitheringState(value: boolean): void;
  38058. /**
  38059. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38060. * @param value defines the rasterizer state
  38061. */
  38062. setRasterizerState(value: boolean): void;
  38063. /**
  38064. * Gets the current depth function
  38065. * @returns a number defining the depth function
  38066. */
  38067. getDepthFunction(): Nullable<number>;
  38068. /**
  38069. * Sets the current depth function
  38070. * @param depthFunc defines the function to use
  38071. */
  38072. setDepthFunction(depthFunc: number): void;
  38073. /**
  38074. * Sets the current depth function to GREATER
  38075. */
  38076. setDepthFunctionToGreater(): void;
  38077. /**
  38078. * Sets the current depth function to GEQUAL
  38079. */
  38080. setDepthFunctionToGreaterOrEqual(): void;
  38081. /**
  38082. * Sets the current depth function to LESS
  38083. */
  38084. setDepthFunctionToLess(): void;
  38085. /**
  38086. * Sets the current depth function to LEQUAL
  38087. */
  38088. setDepthFunctionToLessOrEqual(): void;
  38089. private _cachedStencilBuffer;
  38090. private _cachedStencilFunction;
  38091. private _cachedStencilMask;
  38092. private _cachedStencilOperationPass;
  38093. private _cachedStencilOperationFail;
  38094. private _cachedStencilOperationDepthFail;
  38095. private _cachedStencilReference;
  38096. /**
  38097. * Caches the the state of the stencil buffer
  38098. */
  38099. cacheStencilState(): void;
  38100. /**
  38101. * Restores the state of the stencil buffer
  38102. */
  38103. restoreStencilState(): void;
  38104. /**
  38105. * Directly set the WebGL Viewport
  38106. * @param x defines the x coordinate of the viewport (in screen space)
  38107. * @param y defines the y coordinate of the viewport (in screen space)
  38108. * @param width defines the width of the viewport (in screen space)
  38109. * @param height defines the height of the viewport (in screen space)
  38110. * @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
  38111. */
  38112. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38113. /**
  38114. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38115. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38116. * @param y defines the y-coordinate of the corner of the clear rectangle
  38117. * @param width defines the width of the clear rectangle
  38118. * @param height defines the height of the clear rectangle
  38119. * @param clearColor defines the clear color
  38120. */
  38121. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38122. /**
  38123. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38124. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38125. * @param y defines the y-coordinate of the corner of the clear rectangle
  38126. * @param width defines the width of the clear rectangle
  38127. * @param height defines the height of the clear rectangle
  38128. */
  38129. enableScissor(x: number, y: number, width: number, height: number): void;
  38130. /**
  38131. * Disable previously set scissor test rectangle
  38132. */
  38133. disableScissor(): void;
  38134. protected _reportDrawCall(): void;
  38135. /**
  38136. * Initializes a webVR display and starts listening to display change events
  38137. * The onVRDisplayChangedObservable will be notified upon these changes
  38138. * @returns The onVRDisplayChangedObservable
  38139. */
  38140. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38141. /** @hidden */
  38142. _prepareVRComponent(): void;
  38143. /** @hidden */
  38144. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38145. /** @hidden */
  38146. _submitVRFrame(): void;
  38147. /**
  38148. * Call this function to leave webVR mode
  38149. * Will do nothing if webVR is not supported or if there is no webVR device
  38150. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38151. */
  38152. disableVR(): void;
  38153. /**
  38154. * Gets a boolean indicating that the system is in VR mode and is presenting
  38155. * @returns true if VR mode is engaged
  38156. */
  38157. isVRPresenting(): boolean;
  38158. /** @hidden */
  38159. _requestVRFrame(): void;
  38160. /** @hidden */
  38161. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38162. /**
  38163. * Gets the source code of the vertex shader associated with a specific webGL program
  38164. * @param program defines the program to use
  38165. * @returns a string containing the source code of the vertex shader associated with the program
  38166. */
  38167. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38168. /**
  38169. * Gets the source code of the fragment shader associated with a specific webGL program
  38170. * @param program defines the program to use
  38171. * @returns a string containing the source code of the fragment shader associated with the program
  38172. */
  38173. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38174. /**
  38175. * Sets a depth stencil texture from a render target to the according uniform.
  38176. * @param channel The texture channel
  38177. * @param uniform The uniform to set
  38178. * @param texture The render target texture containing the depth stencil texture to apply
  38179. */
  38180. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38181. /**
  38182. * Sets a texture to the webGL context from a postprocess
  38183. * @param channel defines the channel to use
  38184. * @param postProcess defines the source postprocess
  38185. */
  38186. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38187. /**
  38188. * Binds the output of the passed in post process to the texture channel specified
  38189. * @param channel The channel the texture should be bound to
  38190. * @param postProcess The post process which's output should be bound
  38191. */
  38192. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38193. protected _rebuildBuffers(): void;
  38194. /** @hidden */
  38195. _renderFrame(): void;
  38196. _renderLoop(): void;
  38197. /** @hidden */
  38198. _renderViews(): boolean;
  38199. /**
  38200. * Toggle full screen mode
  38201. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38202. */
  38203. switchFullscreen(requestPointerLock: boolean): void;
  38204. /**
  38205. * Enters full screen mode
  38206. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38207. */
  38208. enterFullscreen(requestPointerLock: boolean): void;
  38209. /**
  38210. * Exits full screen mode
  38211. */
  38212. exitFullscreen(): void;
  38213. /**
  38214. * Enters Pointerlock mode
  38215. */
  38216. enterPointerlock(): void;
  38217. /**
  38218. * Exits Pointerlock mode
  38219. */
  38220. exitPointerlock(): void;
  38221. /**
  38222. * Begin a new frame
  38223. */
  38224. beginFrame(): void;
  38225. /**
  38226. * Enf the current frame
  38227. */
  38228. endFrame(): void;
  38229. resize(): void;
  38230. /**
  38231. * Force a specific size of the canvas
  38232. * @param width defines the new canvas' width
  38233. * @param height defines the new canvas' height
  38234. * @returns true if the size was changed
  38235. */
  38236. setSize(width: number, height: number): boolean;
  38237. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38238. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38239. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38240. _releaseTexture(texture: InternalTexture): void;
  38241. /**
  38242. * @hidden
  38243. * Rescales a texture
  38244. * @param source input texutre
  38245. * @param destination destination texture
  38246. * @param scene scene to use to render the resize
  38247. * @param internalFormat format to use when resizing
  38248. * @param onComplete callback to be called when resize has completed
  38249. */
  38250. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38251. /**
  38252. * Gets the current framerate
  38253. * @returns a number representing the framerate
  38254. */
  38255. getFps(): number;
  38256. /**
  38257. * Gets the time spent between current and previous frame
  38258. * @returns a number representing the delta time in ms
  38259. */
  38260. getDeltaTime(): number;
  38261. private _measureFps;
  38262. /** @hidden */
  38263. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38264. /**
  38265. * Updates the sample count of a render target texture
  38266. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38267. * @param texture defines the texture to update
  38268. * @param samples defines the sample count to set
  38269. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38270. */
  38271. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38272. /**
  38273. * Updates a depth texture Comparison Mode and Function.
  38274. * If the comparison Function is equal to 0, the mode will be set to none.
  38275. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38276. * @param texture The texture to set the comparison function for
  38277. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38278. */
  38279. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38280. /**
  38281. * Creates a webGL buffer to use with instanciation
  38282. * @param capacity defines the size of the buffer
  38283. * @returns the webGL buffer
  38284. */
  38285. createInstancesBuffer(capacity: number): DataBuffer;
  38286. /**
  38287. * Delete a webGL buffer used with instanciation
  38288. * @param buffer defines the webGL buffer to delete
  38289. */
  38290. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38291. private _clientWaitAsync;
  38292. /** @hidden */
  38293. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38294. dispose(): void;
  38295. private _disableTouchAction;
  38296. /**
  38297. * Display the loading screen
  38298. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38299. */
  38300. displayLoadingUI(): void;
  38301. /**
  38302. * Hide the loading screen
  38303. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38304. */
  38305. hideLoadingUI(): void;
  38306. /**
  38307. * Gets the current loading screen object
  38308. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38309. */
  38310. get loadingScreen(): ILoadingScreen;
  38311. /**
  38312. * Sets the current loading screen object
  38313. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38314. */
  38315. set loadingScreen(loadingScreen: ILoadingScreen);
  38316. /**
  38317. * Sets the current loading screen text
  38318. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38319. */
  38320. set loadingUIText(text: string);
  38321. /**
  38322. * Sets the current loading screen background color
  38323. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38324. */
  38325. set loadingUIBackgroundColor(color: string);
  38326. /** Pointerlock and fullscreen */
  38327. /**
  38328. * Ask the browser to promote the current element to pointerlock mode
  38329. * @param element defines the DOM element to promote
  38330. */
  38331. static _RequestPointerlock(element: HTMLElement): void;
  38332. /**
  38333. * Asks the browser to exit pointerlock mode
  38334. */
  38335. static _ExitPointerlock(): void;
  38336. /**
  38337. * Ask the browser to promote the current element to fullscreen rendering mode
  38338. * @param element defines the DOM element to promote
  38339. */
  38340. static _RequestFullscreen(element: HTMLElement): void;
  38341. /**
  38342. * Asks the browser to exit fullscreen mode
  38343. */
  38344. static _ExitFullscreen(): void;
  38345. }
  38346. }
  38347. declare module BABYLON {
  38348. /**
  38349. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38350. * during the life time of the application.
  38351. */
  38352. export class EngineStore {
  38353. /** Gets the list of created engines */
  38354. static Instances: Engine[];
  38355. /** @hidden */
  38356. static _LastCreatedScene: Nullable<Scene>;
  38357. /**
  38358. * Gets the latest created engine
  38359. */
  38360. static get LastCreatedEngine(): Nullable<Engine>;
  38361. /**
  38362. * Gets the latest created scene
  38363. */
  38364. static get LastCreatedScene(): Nullable<Scene>;
  38365. /**
  38366. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38367. * @ignorenaming
  38368. */
  38369. static UseFallbackTexture: boolean;
  38370. /**
  38371. * Texture content used if a texture cannot loaded
  38372. * @ignorenaming
  38373. */
  38374. static FallbackTexture: string;
  38375. }
  38376. }
  38377. declare module BABYLON {
  38378. /**
  38379. * Helper class that provides a small promise polyfill
  38380. */
  38381. export class PromisePolyfill {
  38382. /**
  38383. * Static function used to check if the polyfill is required
  38384. * If this is the case then the function will inject the polyfill to window.Promise
  38385. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38386. */
  38387. static Apply(force?: boolean): void;
  38388. }
  38389. }
  38390. declare module BABYLON {
  38391. /**
  38392. * Interface for screenshot methods with describe argument called `size` as object with options
  38393. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38394. */
  38395. export interface IScreenshotSize {
  38396. /**
  38397. * number in pixels for canvas height
  38398. */
  38399. height?: number;
  38400. /**
  38401. * multiplier allowing render at a higher or lower resolution
  38402. * If value is defined then height and width will be ignored and taken from camera
  38403. */
  38404. precision?: number;
  38405. /**
  38406. * number in pixels for canvas width
  38407. */
  38408. width?: number;
  38409. }
  38410. }
  38411. declare module BABYLON {
  38412. interface IColor4Like {
  38413. r: float;
  38414. g: float;
  38415. b: float;
  38416. a: float;
  38417. }
  38418. /**
  38419. * Class containing a set of static utilities functions
  38420. */
  38421. export class Tools {
  38422. /**
  38423. * Gets or sets the base URL to use to load assets
  38424. */
  38425. static get BaseUrl(): string;
  38426. static set BaseUrl(value: string);
  38427. /**
  38428. * Enable/Disable Custom HTTP Request Headers globally.
  38429. * default = false
  38430. * @see CustomRequestHeaders
  38431. */
  38432. static UseCustomRequestHeaders: boolean;
  38433. /**
  38434. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38435. * i.e. when loading files, where the server/service expects an Authorization header
  38436. */
  38437. static CustomRequestHeaders: {
  38438. [key: string]: string;
  38439. };
  38440. /**
  38441. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38442. */
  38443. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38444. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38445. /**
  38446. * Default behaviour for cors in the application.
  38447. * It can be a string if the expected behavior is identical in the entire app.
  38448. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38449. */
  38450. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38451. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38452. /**
  38453. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38454. * @ignorenaming
  38455. */
  38456. static get UseFallbackTexture(): boolean;
  38457. static set UseFallbackTexture(value: boolean);
  38458. /**
  38459. * Use this object to register external classes like custom textures or material
  38460. * to allow the laoders to instantiate them
  38461. */
  38462. static get RegisteredExternalClasses(): {
  38463. [key: string]: Object;
  38464. };
  38465. static set RegisteredExternalClasses(classes: {
  38466. [key: string]: Object;
  38467. });
  38468. /**
  38469. * Texture content used if a texture cannot loaded
  38470. * @ignorenaming
  38471. */
  38472. static get fallbackTexture(): string;
  38473. static set fallbackTexture(value: string);
  38474. /**
  38475. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38476. * @param u defines the coordinate on X axis
  38477. * @param v defines the coordinate on Y axis
  38478. * @param width defines the width of the source data
  38479. * @param height defines the height of the source data
  38480. * @param pixels defines the source byte array
  38481. * @param color defines the output color
  38482. */
  38483. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38484. /**
  38485. * Interpolates between a and b via alpha
  38486. * @param a The lower value (returned when alpha = 0)
  38487. * @param b The upper value (returned when alpha = 1)
  38488. * @param alpha The interpolation-factor
  38489. * @return The mixed value
  38490. */
  38491. static Mix(a: number, b: number, alpha: number): number;
  38492. /**
  38493. * Tries to instantiate a new object from a given class name
  38494. * @param className defines the class name to instantiate
  38495. * @returns the new object or null if the system was not able to do the instantiation
  38496. */
  38497. static Instantiate(className: string): any;
  38498. /**
  38499. * Provides a slice function that will work even on IE
  38500. * @param data defines the array to slice
  38501. * @param start defines the start of the data (optional)
  38502. * @param end defines the end of the data (optional)
  38503. * @returns the new sliced array
  38504. */
  38505. static Slice<T>(data: T, start?: number, end?: number): T;
  38506. /**
  38507. * Polyfill for setImmediate
  38508. * @param action defines the action to execute after the current execution block
  38509. */
  38510. static SetImmediate(action: () => void): void;
  38511. /**
  38512. * Function indicating if a number is an exponent of 2
  38513. * @param value defines the value to test
  38514. * @returns true if the value is an exponent of 2
  38515. */
  38516. static IsExponentOfTwo(value: number): boolean;
  38517. private static _tmpFloatArray;
  38518. /**
  38519. * Returns the nearest 32-bit single precision float representation of a Number
  38520. * @param value A Number. If the parameter is of a different type, it will get converted
  38521. * to a number or to NaN if it cannot be converted
  38522. * @returns number
  38523. */
  38524. static FloatRound(value: number): number;
  38525. /**
  38526. * Extracts the filename from a path
  38527. * @param path defines the path to use
  38528. * @returns the filename
  38529. */
  38530. static GetFilename(path: string): string;
  38531. /**
  38532. * Extracts the "folder" part of a path (everything before the filename).
  38533. * @param uri The URI to extract the info from
  38534. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38535. * @returns The "folder" part of the path
  38536. */
  38537. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38538. /**
  38539. * Extracts text content from a DOM element hierarchy
  38540. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38541. */
  38542. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38543. /**
  38544. * Convert an angle in radians to degrees
  38545. * @param angle defines the angle to convert
  38546. * @returns the angle in degrees
  38547. */
  38548. static ToDegrees(angle: number): number;
  38549. /**
  38550. * Convert an angle in degrees to radians
  38551. * @param angle defines the angle to convert
  38552. * @returns the angle in radians
  38553. */
  38554. static ToRadians(angle: number): number;
  38555. /**
  38556. * Returns an array if obj is not an array
  38557. * @param obj defines the object to evaluate as an array
  38558. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38559. * @returns either obj directly if obj is an array or a new array containing obj
  38560. */
  38561. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38562. /**
  38563. * Gets the pointer prefix to use
  38564. * @param engine defines the engine we are finding the prefix for
  38565. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38566. */
  38567. static GetPointerPrefix(engine: Engine): string;
  38568. /**
  38569. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38570. * @param url define the url we are trying
  38571. * @param element define the dom element where to configure the cors policy
  38572. */
  38573. static SetCorsBehavior(url: string | string[], element: {
  38574. crossOrigin: string | null;
  38575. }): void;
  38576. /**
  38577. * Removes unwanted characters from an url
  38578. * @param url defines the url to clean
  38579. * @returns the cleaned url
  38580. */
  38581. static CleanUrl(url: string): string;
  38582. /**
  38583. * Gets or sets a function used to pre-process url before using them to load assets
  38584. */
  38585. static get PreprocessUrl(): (url: string) => string;
  38586. static set PreprocessUrl(processor: (url: string) => string);
  38587. /**
  38588. * Loads an image as an HTMLImageElement.
  38589. * @param input url string, ArrayBuffer, or Blob to load
  38590. * @param onLoad callback called when the image successfully loads
  38591. * @param onError callback called when the image fails to load
  38592. * @param offlineProvider offline provider for caching
  38593. * @param mimeType optional mime type
  38594. * @returns the HTMLImageElement of the loaded image
  38595. */
  38596. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38597. /**
  38598. * Loads a file from a url
  38599. * @param url url string, ArrayBuffer, or Blob to load
  38600. * @param onSuccess callback called when the file successfully loads
  38601. * @param onProgress callback called while file is loading (if the server supports this mode)
  38602. * @param offlineProvider defines the offline provider for caching
  38603. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38604. * @param onError callback called when the file fails to load
  38605. * @returns a file request object
  38606. */
  38607. 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;
  38608. /**
  38609. * Loads a file from a url
  38610. * @param url the file url to load
  38611. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38612. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38613. */
  38614. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38615. /**
  38616. * Load a script (identified by an url). When the url returns, the
  38617. * content of this file is added into a new script element, attached to the DOM (body element)
  38618. * @param scriptUrl defines the url of the script to laod
  38619. * @param onSuccess defines the callback called when the script is loaded
  38620. * @param onError defines the callback to call if an error occurs
  38621. * @param scriptId defines the id of the script element
  38622. */
  38623. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38624. /**
  38625. * Load an asynchronous script (identified by an url). When the url returns, the
  38626. * content of this file is added into a new script element, attached to the DOM (body element)
  38627. * @param scriptUrl defines the url of the script to laod
  38628. * @param scriptId defines the id of the script element
  38629. * @returns a promise request object
  38630. */
  38631. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38632. /**
  38633. * Loads a file from a blob
  38634. * @param fileToLoad defines the blob to use
  38635. * @param callback defines the callback to call when data is loaded
  38636. * @param progressCallback defines the callback to call during loading process
  38637. * @returns a file request object
  38638. */
  38639. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38640. /**
  38641. * Reads a file from a File object
  38642. * @param file defines the file to load
  38643. * @param onSuccess defines the callback to call when data is loaded
  38644. * @param onProgress defines the callback to call during loading process
  38645. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38646. * @param onError defines the callback to call when an error occurs
  38647. * @returns a file request object
  38648. */
  38649. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38650. /**
  38651. * Creates a data url from a given string content
  38652. * @param content defines the content to convert
  38653. * @returns the new data url link
  38654. */
  38655. static FileAsURL(content: string): string;
  38656. /**
  38657. * Format the given number to a specific decimal format
  38658. * @param value defines the number to format
  38659. * @param decimals defines the number of decimals to use
  38660. * @returns the formatted string
  38661. */
  38662. static Format(value: number, decimals?: number): string;
  38663. /**
  38664. * Tries to copy an object by duplicating every property
  38665. * @param source defines the source object
  38666. * @param destination defines the target object
  38667. * @param doNotCopyList defines a list of properties to avoid
  38668. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38669. */
  38670. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38671. /**
  38672. * Gets a boolean indicating if the given object has no own property
  38673. * @param obj defines the object to test
  38674. * @returns true if object has no own property
  38675. */
  38676. static IsEmpty(obj: any): boolean;
  38677. /**
  38678. * Function used to register events at window level
  38679. * @param windowElement defines the Window object to use
  38680. * @param events defines the events to register
  38681. */
  38682. static RegisterTopRootEvents(windowElement: Window, events: {
  38683. name: string;
  38684. handler: Nullable<(e: FocusEvent) => any>;
  38685. }[]): void;
  38686. /**
  38687. * Function used to unregister events from window level
  38688. * @param windowElement defines the Window object to use
  38689. * @param events defines the events to unregister
  38690. */
  38691. static UnregisterTopRootEvents(windowElement: Window, events: {
  38692. name: string;
  38693. handler: Nullable<(e: FocusEvent) => any>;
  38694. }[]): void;
  38695. /**
  38696. * @ignore
  38697. */
  38698. static _ScreenshotCanvas: HTMLCanvasElement;
  38699. /**
  38700. * Dumps the current bound framebuffer
  38701. * @param width defines the rendering width
  38702. * @param height defines the rendering height
  38703. * @param engine defines the hosting engine
  38704. * @param successCallback defines the callback triggered once the data are available
  38705. * @param mimeType defines the mime type of the result
  38706. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38707. */
  38708. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38709. /**
  38710. * Converts the canvas data to blob.
  38711. * This acts as a polyfill for browsers not supporting the to blob function.
  38712. * @param canvas Defines the canvas to extract the data from
  38713. * @param successCallback Defines the callback triggered once the data are available
  38714. * @param mimeType Defines the mime type of the result
  38715. */
  38716. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38717. /**
  38718. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38719. * @param successCallback defines the callback triggered once the data are available
  38720. * @param mimeType defines the mime type of the result
  38721. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38722. */
  38723. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38724. /**
  38725. * Downloads a blob in the browser
  38726. * @param blob defines the blob to download
  38727. * @param fileName defines the name of the downloaded file
  38728. */
  38729. static Download(blob: Blob, fileName: string): void;
  38730. /**
  38731. * Captures a screenshot of the current rendering
  38732. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38733. * @param engine defines the rendering engine
  38734. * @param camera defines the source camera
  38735. * @param size This parameter can be set to a single number or to an object with the
  38736. * following (optional) properties: precision, width, height. If a single number is passed,
  38737. * it will be used for both width and height. If an object is passed, the screenshot size
  38738. * will be derived from the parameters. The precision property is a multiplier allowing
  38739. * rendering at a higher or lower resolution
  38740. * @param successCallback defines the callback receives a single parameter which contains the
  38741. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38742. * src parameter of an <img> to display it
  38743. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38744. * Check your browser for supported MIME types
  38745. */
  38746. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38747. /**
  38748. * Captures a screenshot of the current rendering
  38749. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38750. * @param engine defines the rendering engine
  38751. * @param camera defines the source camera
  38752. * @param size This parameter can be set to a single number or to an object with the
  38753. * following (optional) properties: precision, width, height. If a single number is passed,
  38754. * it will be used for both width and height. If an object is passed, the screenshot size
  38755. * will be derived from the parameters. The precision property is a multiplier allowing
  38756. * rendering at a higher or lower resolution
  38757. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38758. * Check your browser for supported MIME types
  38759. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38760. * to the src parameter of an <img> to display it
  38761. */
  38762. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38763. /**
  38764. * Generates an image screenshot from the specified camera.
  38765. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38766. * @param engine The engine to use for rendering
  38767. * @param camera The camera to use for rendering
  38768. * @param size This parameter can be set to a single number or to an object with the
  38769. * following (optional) properties: precision, width, height. If a single number is passed,
  38770. * it will be used for both width and height. If an object is passed, the screenshot size
  38771. * will be derived from the parameters. The precision property is a multiplier allowing
  38772. * rendering at a higher or lower resolution
  38773. * @param successCallback The callback receives a single parameter which contains the
  38774. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38775. * src parameter of an <img> to display it
  38776. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38777. * Check your browser for supported MIME types
  38778. * @param samples Texture samples (default: 1)
  38779. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38780. * @param fileName A name for for the downloaded file.
  38781. */
  38782. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38783. /**
  38784. * Generates an image screenshot from the specified camera.
  38785. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38786. * @param engine The engine to use for rendering
  38787. * @param camera The camera to use for rendering
  38788. * @param size This parameter can be set to a single number or to an object with the
  38789. * following (optional) properties: precision, width, height. If a single number is passed,
  38790. * it will be used for both width and height. If an object is passed, the screenshot size
  38791. * will be derived from the parameters. The precision property is a multiplier allowing
  38792. * rendering at a higher or lower resolution
  38793. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38794. * Check your browser for supported MIME types
  38795. * @param samples Texture samples (default: 1)
  38796. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38797. * @param fileName A name for for the downloaded file.
  38798. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38799. * to the src parameter of an <img> to display it
  38800. */
  38801. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38802. /**
  38803. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38804. * Be aware Math.random() could cause collisions, but:
  38805. * "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"
  38806. * @returns a pseudo random id
  38807. */
  38808. static RandomId(): string;
  38809. /**
  38810. * Test if the given uri is a base64 string
  38811. * @param uri The uri to test
  38812. * @return True if the uri is a base64 string or false otherwise
  38813. */
  38814. static IsBase64(uri: string): boolean;
  38815. /**
  38816. * Decode the given base64 uri.
  38817. * @param uri The uri to decode
  38818. * @return The decoded base64 data.
  38819. */
  38820. static DecodeBase64(uri: string): ArrayBuffer;
  38821. /**
  38822. * Gets the absolute url.
  38823. * @param url the input url
  38824. * @return the absolute url
  38825. */
  38826. static GetAbsoluteUrl(url: string): string;
  38827. /**
  38828. * No log
  38829. */
  38830. static readonly NoneLogLevel: number;
  38831. /**
  38832. * Only message logs
  38833. */
  38834. static readonly MessageLogLevel: number;
  38835. /**
  38836. * Only warning logs
  38837. */
  38838. static readonly WarningLogLevel: number;
  38839. /**
  38840. * Only error logs
  38841. */
  38842. static readonly ErrorLogLevel: number;
  38843. /**
  38844. * All logs
  38845. */
  38846. static readonly AllLogLevel: number;
  38847. /**
  38848. * Gets a value indicating the number of loading errors
  38849. * @ignorenaming
  38850. */
  38851. static get errorsCount(): number;
  38852. /**
  38853. * Callback called when a new log is added
  38854. */
  38855. static OnNewCacheEntry: (entry: string) => void;
  38856. /**
  38857. * Log a message to the console
  38858. * @param message defines the message to log
  38859. */
  38860. static Log(message: string): void;
  38861. /**
  38862. * Write a warning message to the console
  38863. * @param message defines the message to log
  38864. */
  38865. static Warn(message: string): void;
  38866. /**
  38867. * Write an error message to the console
  38868. * @param message defines the message to log
  38869. */
  38870. static Error(message: string): void;
  38871. /**
  38872. * Gets current log cache (list of logs)
  38873. */
  38874. static get LogCache(): string;
  38875. /**
  38876. * Clears the log cache
  38877. */
  38878. static ClearLogCache(): void;
  38879. /**
  38880. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  38881. */
  38882. static set LogLevels(level: number);
  38883. /**
  38884. * Checks if the window object exists
  38885. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  38886. */
  38887. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  38888. /**
  38889. * No performance log
  38890. */
  38891. static readonly PerformanceNoneLogLevel: number;
  38892. /**
  38893. * Use user marks to log performance
  38894. */
  38895. static readonly PerformanceUserMarkLogLevel: number;
  38896. /**
  38897. * Log performance to the console
  38898. */
  38899. static readonly PerformanceConsoleLogLevel: number;
  38900. private static _performance;
  38901. /**
  38902. * Sets the current performance log level
  38903. */
  38904. static set PerformanceLogLevel(level: number);
  38905. private static _StartPerformanceCounterDisabled;
  38906. private static _EndPerformanceCounterDisabled;
  38907. private static _StartUserMark;
  38908. private static _EndUserMark;
  38909. private static _StartPerformanceConsole;
  38910. private static _EndPerformanceConsole;
  38911. /**
  38912. * Starts a performance counter
  38913. */
  38914. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38915. /**
  38916. * Ends a specific performance coutner
  38917. */
  38918. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  38919. /**
  38920. * Gets either window.performance.now() if supported or Date.now() else
  38921. */
  38922. static get Now(): number;
  38923. /**
  38924. * This method will return the name of the class used to create the instance of the given object.
  38925. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  38926. * @param object the object to get the class name from
  38927. * @param isType defines if the object is actually a type
  38928. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  38929. */
  38930. static GetClassName(object: any, isType?: boolean): string;
  38931. /**
  38932. * Gets the first element of an array satisfying a given predicate
  38933. * @param array defines the array to browse
  38934. * @param predicate defines the predicate to use
  38935. * @returns null if not found or the element
  38936. */
  38937. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  38938. /**
  38939. * This method will return the name of the full name of the class, including its owning module (if any).
  38940. * 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).
  38941. * @param object the object to get the class name from
  38942. * @param isType defines if the object is actually a type
  38943. * @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.
  38944. * @ignorenaming
  38945. */
  38946. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  38947. /**
  38948. * Returns a promise that resolves after the given amount of time.
  38949. * @param delay Number of milliseconds to delay
  38950. * @returns Promise that resolves after the given amount of time
  38951. */
  38952. static DelayAsync(delay: number): Promise<void>;
  38953. /**
  38954. * Utility function to detect if the current user agent is Safari
  38955. * @returns whether or not the current user agent is safari
  38956. */
  38957. static IsSafari(): boolean;
  38958. }
  38959. /**
  38960. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  38961. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  38962. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  38963. * @param name The name of the class, case should be preserved
  38964. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  38965. */
  38966. export function className(name: string, module?: string): (target: Object) => void;
  38967. /**
  38968. * An implementation of a loop for asynchronous functions.
  38969. */
  38970. export class AsyncLoop {
  38971. /**
  38972. * Defines the number of iterations for the loop
  38973. */
  38974. iterations: number;
  38975. /**
  38976. * Defines the current index of the loop.
  38977. */
  38978. index: number;
  38979. private _done;
  38980. private _fn;
  38981. private _successCallback;
  38982. /**
  38983. * Constructor.
  38984. * @param iterations the number of iterations.
  38985. * @param func the function to run each iteration
  38986. * @param successCallback the callback that will be called upon succesful execution
  38987. * @param offset starting offset.
  38988. */
  38989. constructor(
  38990. /**
  38991. * Defines the number of iterations for the loop
  38992. */
  38993. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  38994. /**
  38995. * Execute the next iteration. Must be called after the last iteration was finished.
  38996. */
  38997. executeNext(): void;
  38998. /**
  38999. * Break the loop and run the success callback.
  39000. */
  39001. breakLoop(): void;
  39002. /**
  39003. * Create and run an async loop.
  39004. * @param iterations the number of iterations.
  39005. * @param fn the function to run each iteration
  39006. * @param successCallback the callback that will be called upon succesful execution
  39007. * @param offset starting offset.
  39008. * @returns the created async loop object
  39009. */
  39010. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39011. /**
  39012. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39013. * @param iterations total number of iterations
  39014. * @param syncedIterations number of synchronous iterations in each async iteration.
  39015. * @param fn the function to call each iteration.
  39016. * @param callback a success call back that will be called when iterating stops.
  39017. * @param breakFunction a break condition (optional)
  39018. * @param timeout timeout settings for the setTimeout function. default - 0.
  39019. * @returns the created async loop object
  39020. */
  39021. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39022. }
  39023. }
  39024. declare module BABYLON {
  39025. /**
  39026. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39027. * The underlying implementation relies on an associative array to ensure the best performances.
  39028. * The value can be anything including 'null' but except 'undefined'
  39029. */
  39030. export class StringDictionary<T> {
  39031. /**
  39032. * This will clear this dictionary and copy the content from the 'source' one.
  39033. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39034. * @param source the dictionary to take the content from and copy to this dictionary
  39035. */
  39036. copyFrom(source: StringDictionary<T>): void;
  39037. /**
  39038. * Get a value based from its key
  39039. * @param key the given key to get the matching value from
  39040. * @return the value if found, otherwise undefined is returned
  39041. */
  39042. get(key: string): T | undefined;
  39043. /**
  39044. * Get a value from its key or add it if it doesn't exist.
  39045. * This method will ensure you that a given key/data will be present in the dictionary.
  39046. * @param key the given key to get the matching value from
  39047. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39048. * The factory will only be invoked if there's no data for the given key.
  39049. * @return the value corresponding to the key.
  39050. */
  39051. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39052. /**
  39053. * Get a value from its key if present in the dictionary otherwise add it
  39054. * @param key the key to get the value from
  39055. * @param val if there's no such key/value pair in the dictionary add it with this value
  39056. * @return the value corresponding to the key
  39057. */
  39058. getOrAdd(key: string, val: T): T;
  39059. /**
  39060. * Check if there's a given key in the dictionary
  39061. * @param key the key to check for
  39062. * @return true if the key is present, false otherwise
  39063. */
  39064. contains(key: string): boolean;
  39065. /**
  39066. * Add a new key and its corresponding value
  39067. * @param key the key to add
  39068. * @param value the value corresponding to the key
  39069. * @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
  39070. */
  39071. add(key: string, value: T): boolean;
  39072. /**
  39073. * Update a specific value associated to a key
  39074. * @param key defines the key to use
  39075. * @param value defines the value to store
  39076. * @returns true if the value was updated (or false if the key was not found)
  39077. */
  39078. set(key: string, value: T): boolean;
  39079. /**
  39080. * Get the element of the given key and remove it from the dictionary
  39081. * @param key defines the key to search
  39082. * @returns the value associated with the key or null if not found
  39083. */
  39084. getAndRemove(key: string): Nullable<T>;
  39085. /**
  39086. * Remove a key/value from the dictionary.
  39087. * @param key the key to remove
  39088. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39089. */
  39090. remove(key: string): boolean;
  39091. /**
  39092. * Clear the whole content of the dictionary
  39093. */
  39094. clear(): void;
  39095. /**
  39096. * Gets the current count
  39097. */
  39098. get count(): number;
  39099. /**
  39100. * Execute a callback on each key/val of the dictionary.
  39101. * Note that you can remove any element in this dictionary in the callback implementation
  39102. * @param callback the callback to execute on a given key/value pair
  39103. */
  39104. forEach(callback: (key: string, val: T) => void): void;
  39105. /**
  39106. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39107. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39108. * Note that you can remove any element in this dictionary in the callback implementation
  39109. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39110. * @returns the first item
  39111. */
  39112. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39113. private _count;
  39114. private _data;
  39115. }
  39116. }
  39117. declare module BABYLON {
  39118. /** @hidden */
  39119. export interface ICollisionCoordinator {
  39120. createCollider(): Collider;
  39121. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39122. init(scene: Scene): void;
  39123. }
  39124. /** @hidden */
  39125. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39126. private _scene;
  39127. private _scaledPosition;
  39128. private _scaledVelocity;
  39129. private _finalPosition;
  39130. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39131. createCollider(): Collider;
  39132. init(scene: Scene): void;
  39133. private _collideWithWorld;
  39134. }
  39135. }
  39136. declare module BABYLON {
  39137. /**
  39138. * Class used to manage all inputs for the scene.
  39139. */
  39140. export class InputManager {
  39141. /** The distance in pixel that you have to move to prevent some events */
  39142. static DragMovementThreshold: number;
  39143. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39144. static LongPressDelay: number;
  39145. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39146. static DoubleClickDelay: number;
  39147. /** If you need to check double click without raising a single click at first click, enable this flag */
  39148. static ExclusiveDoubleClickMode: boolean;
  39149. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  39150. private _alreadyAttached;
  39151. private _wheelEventName;
  39152. private _onPointerMove;
  39153. private _onPointerDown;
  39154. private _onPointerUp;
  39155. private _initClickEvent;
  39156. private _initActionManager;
  39157. private _delayedSimpleClick;
  39158. private _delayedSimpleClickTimeout;
  39159. private _previousDelayedSimpleClickTimeout;
  39160. private _meshPickProceed;
  39161. private _previousButtonPressed;
  39162. private _currentPickResult;
  39163. private _previousPickResult;
  39164. private _totalPointersPressed;
  39165. private _doubleClickOccured;
  39166. private _pointerOverMesh;
  39167. private _pickedDownMesh;
  39168. private _pickedUpMesh;
  39169. private _pointerX;
  39170. private _pointerY;
  39171. private _unTranslatedPointerX;
  39172. private _unTranslatedPointerY;
  39173. private _startingPointerPosition;
  39174. private _previousStartingPointerPosition;
  39175. private _startingPointerTime;
  39176. private _previousStartingPointerTime;
  39177. private _pointerCaptures;
  39178. private _meshUnderPointerId;
  39179. private _onKeyDown;
  39180. private _onKeyUp;
  39181. private _onCanvasFocusObserver;
  39182. private _onCanvasBlurObserver;
  39183. private _scene;
  39184. /**
  39185. * Creates a new InputManager
  39186. * @param scene defines the hosting scene
  39187. */
  39188. constructor(scene: Scene);
  39189. /**
  39190. * Gets the mesh that is currently under the pointer
  39191. */
  39192. get meshUnderPointer(): Nullable<AbstractMesh>;
  39193. /**
  39194. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  39195. * @param pointerId the pointer id to use
  39196. * @returns The mesh under this pointer id or null if not found
  39197. */
  39198. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  39199. /**
  39200. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39201. */
  39202. get unTranslatedPointer(): Vector2;
  39203. /**
  39204. * Gets or sets the current on-screen X position of the pointer
  39205. */
  39206. get pointerX(): number;
  39207. set pointerX(value: number);
  39208. /**
  39209. * Gets or sets the current on-screen Y position of the pointer
  39210. */
  39211. get pointerY(): number;
  39212. set pointerY(value: number);
  39213. private _updatePointerPosition;
  39214. private _processPointerMove;
  39215. private _setRayOnPointerInfo;
  39216. private _checkPrePointerObservable;
  39217. /**
  39218. * Use this method to simulate a pointer move on a mesh
  39219. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39220. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39221. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39222. */
  39223. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39224. /**
  39225. * Use this method to simulate a pointer down on a mesh
  39226. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39227. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39228. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39229. */
  39230. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39231. private _processPointerDown;
  39232. /** @hidden */
  39233. _isPointerSwiping(): boolean;
  39234. /**
  39235. * Use this method to simulate a pointer up on a mesh
  39236. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39237. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39238. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39239. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39240. */
  39241. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39242. private _processPointerUp;
  39243. /**
  39244. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39245. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39246. * @returns true if the pointer was captured
  39247. */
  39248. isPointerCaptured(pointerId?: number): boolean;
  39249. /**
  39250. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39251. * @param attachUp defines if you want to attach events to pointerup
  39252. * @param attachDown defines if you want to attach events to pointerdown
  39253. * @param attachMove defines if you want to attach events to pointermove
  39254. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39255. */
  39256. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39257. /**
  39258. * Detaches all event handlers
  39259. */
  39260. detachControl(): void;
  39261. /**
  39262. * Force the value of meshUnderPointer
  39263. * @param mesh defines the mesh to use
  39264. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  39265. */
  39266. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  39267. /**
  39268. * Gets the mesh under the pointer
  39269. * @returns a Mesh or null if no mesh is under the pointer
  39270. */
  39271. getPointerOverMesh(): Nullable<AbstractMesh>;
  39272. }
  39273. }
  39274. declare module BABYLON {
  39275. /**
  39276. * This class defines the direct association between an animation and a target
  39277. */
  39278. export class TargetedAnimation {
  39279. /**
  39280. * Animation to perform
  39281. */
  39282. animation: Animation;
  39283. /**
  39284. * Target to animate
  39285. */
  39286. target: any;
  39287. /**
  39288. * Returns the string "TargetedAnimation"
  39289. * @returns "TargetedAnimation"
  39290. */
  39291. getClassName(): string;
  39292. /**
  39293. * Serialize the object
  39294. * @returns the JSON object representing the current entity
  39295. */
  39296. serialize(): any;
  39297. }
  39298. /**
  39299. * Use this class to create coordinated animations on multiple targets
  39300. */
  39301. export class AnimationGroup implements IDisposable {
  39302. /** The name of the animation group */
  39303. name: string;
  39304. private _scene;
  39305. private _targetedAnimations;
  39306. private _animatables;
  39307. private _from;
  39308. private _to;
  39309. private _isStarted;
  39310. private _isPaused;
  39311. private _speedRatio;
  39312. private _loopAnimation;
  39313. private _isAdditive;
  39314. /**
  39315. * Gets or sets the unique id of the node
  39316. */
  39317. uniqueId: number;
  39318. /**
  39319. * This observable will notify when one animation have ended
  39320. */
  39321. onAnimationEndObservable: Observable<TargetedAnimation>;
  39322. /**
  39323. * Observer raised when one animation loops
  39324. */
  39325. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39326. /**
  39327. * Observer raised when all animations have looped
  39328. */
  39329. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39330. /**
  39331. * This observable will notify when all animations have ended.
  39332. */
  39333. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39334. /**
  39335. * This observable will notify when all animations have paused.
  39336. */
  39337. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39338. /**
  39339. * This observable will notify when all animations are playing.
  39340. */
  39341. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39342. /**
  39343. * Gets the first frame
  39344. */
  39345. get from(): number;
  39346. /**
  39347. * Gets the last frame
  39348. */
  39349. get to(): number;
  39350. /**
  39351. * Define if the animations are started
  39352. */
  39353. get isStarted(): boolean;
  39354. /**
  39355. * Gets a value indicating that the current group is playing
  39356. */
  39357. get isPlaying(): boolean;
  39358. /**
  39359. * Gets or sets the speed ratio to use for all animations
  39360. */
  39361. get speedRatio(): number;
  39362. /**
  39363. * Gets or sets the speed ratio to use for all animations
  39364. */
  39365. set speedRatio(value: number);
  39366. /**
  39367. * Gets or sets if all animations should loop or not
  39368. */
  39369. get loopAnimation(): boolean;
  39370. set loopAnimation(value: boolean);
  39371. /**
  39372. * Gets or sets if all animations should be evaluated additively
  39373. */
  39374. get isAdditive(): boolean;
  39375. set isAdditive(value: boolean);
  39376. /**
  39377. * Gets the targeted animations for this animation group
  39378. */
  39379. get targetedAnimations(): Array<TargetedAnimation>;
  39380. /**
  39381. * returning the list of animatables controlled by this animation group.
  39382. */
  39383. get animatables(): Array<Animatable>;
  39384. /**
  39385. * Gets the list of target animations
  39386. */
  39387. get children(): TargetedAnimation[];
  39388. /**
  39389. * Instantiates a new Animation Group.
  39390. * This helps managing several animations at once.
  39391. * @see https://doc.babylonjs.com/how_to/group
  39392. * @param name Defines the name of the group
  39393. * @param scene Defines the scene the group belongs to
  39394. */
  39395. constructor(
  39396. /** The name of the animation group */
  39397. name: string, scene?: Nullable<Scene>);
  39398. /**
  39399. * Add an animation (with its target) in the group
  39400. * @param animation defines the animation we want to add
  39401. * @param target defines the target of the animation
  39402. * @returns the TargetedAnimation object
  39403. */
  39404. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39405. /**
  39406. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39407. * It can add constant keys at begin or end
  39408. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39409. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39410. * @returns the animation group
  39411. */
  39412. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39413. private _animationLoopCount;
  39414. private _animationLoopFlags;
  39415. private _processLoop;
  39416. /**
  39417. * Start all animations on given targets
  39418. * @param loop defines if animations must loop
  39419. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39420. * @param from defines the from key (optional)
  39421. * @param to defines the to key (optional)
  39422. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39423. * @returns the current animation group
  39424. */
  39425. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39426. /**
  39427. * Pause all animations
  39428. * @returns the animation group
  39429. */
  39430. pause(): AnimationGroup;
  39431. /**
  39432. * Play all animations to initial state
  39433. * This function will start() the animations if they were not started or will restart() them if they were paused
  39434. * @param loop defines if animations must loop
  39435. * @returns the animation group
  39436. */
  39437. play(loop?: boolean): AnimationGroup;
  39438. /**
  39439. * Reset all animations to initial state
  39440. * @returns the animation group
  39441. */
  39442. reset(): AnimationGroup;
  39443. /**
  39444. * Restart animations from key 0
  39445. * @returns the animation group
  39446. */
  39447. restart(): AnimationGroup;
  39448. /**
  39449. * Stop all animations
  39450. * @returns the animation group
  39451. */
  39452. stop(): AnimationGroup;
  39453. /**
  39454. * Set animation weight for all animatables
  39455. * @param weight defines the weight to use
  39456. * @return the animationGroup
  39457. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39458. */
  39459. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39460. /**
  39461. * Synchronize and normalize all animatables with a source animatable
  39462. * @param root defines the root animatable to synchronize with
  39463. * @return the animationGroup
  39464. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39465. */
  39466. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39467. /**
  39468. * Goes to a specific frame in this animation group
  39469. * @param frame the frame number to go to
  39470. * @return the animationGroup
  39471. */
  39472. goToFrame(frame: number): AnimationGroup;
  39473. /**
  39474. * Dispose all associated resources
  39475. */
  39476. dispose(): void;
  39477. private _checkAnimationGroupEnded;
  39478. /**
  39479. * Clone the current animation group and returns a copy
  39480. * @param newName defines the name of the new group
  39481. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39482. * @returns the new aniamtion group
  39483. */
  39484. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39485. /**
  39486. * Serializes the animationGroup to an object
  39487. * @returns Serialized object
  39488. */
  39489. serialize(): any;
  39490. /**
  39491. * Returns a new AnimationGroup object parsed from the source provided.
  39492. * @param parsedAnimationGroup defines the source
  39493. * @param scene defines the scene that will receive the animationGroup
  39494. * @returns a new AnimationGroup
  39495. */
  39496. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39497. /**
  39498. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39499. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39500. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39501. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39502. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39503. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39504. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39505. */
  39506. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39507. /**
  39508. * Returns the string "AnimationGroup"
  39509. * @returns "AnimationGroup"
  39510. */
  39511. getClassName(): string;
  39512. /**
  39513. * Creates a detailled string about the object
  39514. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39515. * @returns a string representing the object
  39516. */
  39517. toString(fullDetails?: boolean): string;
  39518. }
  39519. }
  39520. declare module BABYLON {
  39521. /**
  39522. * Define an interface for all classes that will hold resources
  39523. */
  39524. export interface IDisposable {
  39525. /**
  39526. * Releases all held resources
  39527. */
  39528. dispose(): void;
  39529. }
  39530. /** Interface defining initialization parameters for Scene class */
  39531. export interface SceneOptions {
  39532. /**
  39533. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39534. * It will improve performance when the number of geometries becomes important.
  39535. */
  39536. useGeometryUniqueIdsMap?: boolean;
  39537. /**
  39538. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39539. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39540. */
  39541. useMaterialMeshMap?: boolean;
  39542. /**
  39543. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39544. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39545. */
  39546. useClonedMeshMap?: boolean;
  39547. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39548. virtual?: boolean;
  39549. }
  39550. /**
  39551. * Represents a scene to be rendered by the engine.
  39552. * @see https://doc.babylonjs.com/features/scene
  39553. */
  39554. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  39555. /** The fog is deactivated */
  39556. static readonly FOGMODE_NONE: number;
  39557. /** The fog density is following an exponential function */
  39558. static readonly FOGMODE_EXP: number;
  39559. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39560. static readonly FOGMODE_EXP2: number;
  39561. /** The fog density is following a linear function. */
  39562. static readonly FOGMODE_LINEAR: number;
  39563. /**
  39564. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39565. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39566. */
  39567. static MinDeltaTime: number;
  39568. /**
  39569. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39570. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39571. */
  39572. static MaxDeltaTime: number;
  39573. /**
  39574. * Factory used to create the default material.
  39575. * @param name The name of the material to create
  39576. * @param scene The scene to create the material for
  39577. * @returns The default material
  39578. */
  39579. static DefaultMaterialFactory(scene: Scene): Material;
  39580. /**
  39581. * Factory used to create the a collision coordinator.
  39582. * @returns The collision coordinator
  39583. */
  39584. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39585. /** @hidden */
  39586. _inputManager: InputManager;
  39587. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39588. cameraToUseForPointers: Nullable<Camera>;
  39589. /** @hidden */
  39590. readonly _isScene: boolean;
  39591. /** @hidden */
  39592. _blockEntityCollection: boolean;
  39593. /**
  39594. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39595. */
  39596. autoClear: boolean;
  39597. /**
  39598. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39599. */
  39600. autoClearDepthAndStencil: boolean;
  39601. /**
  39602. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39603. */
  39604. clearColor: Color4;
  39605. /**
  39606. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39607. */
  39608. ambientColor: Color3;
  39609. /**
  39610. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39611. * It should only be one of the following (if not the default embedded one):
  39612. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39613. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39614. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39615. * The material properties need to be setup according to the type of texture in use.
  39616. */
  39617. environmentBRDFTexture: BaseTexture;
  39618. /**
  39619. * Texture used in all pbr material as the reflection texture.
  39620. * As in the majority of the scene they are the same (exception for multi room and so on),
  39621. * this is easier to reference from here than from all the materials.
  39622. */
  39623. get environmentTexture(): Nullable<BaseTexture>;
  39624. /**
  39625. * Texture used in all pbr material as the reflection texture.
  39626. * As in the majority of the scene they are the same (exception for multi room and so on),
  39627. * this is easier to set here than in all the materials.
  39628. */
  39629. set environmentTexture(value: Nullable<BaseTexture>);
  39630. /** @hidden */
  39631. protected _environmentIntensity: number;
  39632. /**
  39633. * Intensity of the environment in all pbr material.
  39634. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39635. * As in the majority of the scene they are the same (exception for multi room and so on),
  39636. * this is easier to reference from here than from all the materials.
  39637. */
  39638. get environmentIntensity(): number;
  39639. /**
  39640. * Intensity of the environment in all pbr material.
  39641. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39642. * As in the majority of the scene they are the same (exception for multi room and so on),
  39643. * this is easier to set here than in all the materials.
  39644. */
  39645. set environmentIntensity(value: number);
  39646. /** @hidden */
  39647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39648. /**
  39649. * Default image processing configuration used either in the rendering
  39650. * Forward main pass or through the imageProcessingPostProcess if present.
  39651. * As in the majority of the scene they are the same (exception for multi camera),
  39652. * this is easier to reference from here than from all the materials and post process.
  39653. *
  39654. * No setter as we it is a shared configuration, you can set the values instead.
  39655. */
  39656. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39657. private _forceWireframe;
  39658. /**
  39659. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39660. */
  39661. set forceWireframe(value: boolean);
  39662. get forceWireframe(): boolean;
  39663. private _skipFrustumClipping;
  39664. /**
  39665. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39666. */
  39667. set skipFrustumClipping(value: boolean);
  39668. get skipFrustumClipping(): boolean;
  39669. private _forcePointsCloud;
  39670. /**
  39671. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39672. */
  39673. set forcePointsCloud(value: boolean);
  39674. get forcePointsCloud(): boolean;
  39675. /**
  39676. * Gets or sets the active clipplane 1
  39677. */
  39678. clipPlane: Nullable<Plane>;
  39679. /**
  39680. * Gets or sets the active clipplane 2
  39681. */
  39682. clipPlane2: Nullable<Plane>;
  39683. /**
  39684. * Gets or sets the active clipplane 3
  39685. */
  39686. clipPlane3: Nullable<Plane>;
  39687. /**
  39688. * Gets or sets the active clipplane 4
  39689. */
  39690. clipPlane4: Nullable<Plane>;
  39691. /**
  39692. * Gets or sets the active clipplane 5
  39693. */
  39694. clipPlane5: Nullable<Plane>;
  39695. /**
  39696. * Gets or sets the active clipplane 6
  39697. */
  39698. clipPlane6: Nullable<Plane>;
  39699. /**
  39700. * Gets or sets a boolean indicating if animations are enabled
  39701. */
  39702. animationsEnabled: boolean;
  39703. private _animationPropertiesOverride;
  39704. /**
  39705. * Gets or sets the animation properties override
  39706. */
  39707. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39708. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39709. /**
  39710. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39711. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39712. */
  39713. useConstantAnimationDeltaTime: boolean;
  39714. /**
  39715. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39716. * Please note that it requires to run a ray cast through the scene on every frame
  39717. */
  39718. constantlyUpdateMeshUnderPointer: boolean;
  39719. /**
  39720. * Defines the HTML cursor to use when hovering over interactive elements
  39721. */
  39722. hoverCursor: string;
  39723. /**
  39724. * Defines the HTML default cursor to use (empty by default)
  39725. */
  39726. defaultCursor: string;
  39727. /**
  39728. * Defines whether cursors are handled by the scene.
  39729. */
  39730. doNotHandleCursors: boolean;
  39731. /**
  39732. * This is used to call preventDefault() on pointer down
  39733. * in order to block unwanted artifacts like system double clicks
  39734. */
  39735. preventDefaultOnPointerDown: boolean;
  39736. /**
  39737. * This is used to call preventDefault() on pointer up
  39738. * in order to block unwanted artifacts like system double clicks
  39739. */
  39740. preventDefaultOnPointerUp: boolean;
  39741. /**
  39742. * Gets or sets user defined metadata
  39743. */
  39744. metadata: any;
  39745. /**
  39746. * For internal use only. Please do not use.
  39747. */
  39748. reservedDataStore: any;
  39749. /**
  39750. * Gets the name of the plugin used to load this scene (null by default)
  39751. */
  39752. loadingPluginName: string;
  39753. /**
  39754. * Use this array to add regular expressions used to disable offline support for specific urls
  39755. */
  39756. disableOfflineSupportExceptionRules: RegExp[];
  39757. /**
  39758. * An event triggered when the scene is disposed.
  39759. */
  39760. onDisposeObservable: Observable<Scene>;
  39761. private _onDisposeObserver;
  39762. /** Sets a function to be executed when this scene is disposed. */
  39763. set onDispose(callback: () => void);
  39764. /**
  39765. * An event triggered before rendering the scene (right after animations and physics)
  39766. */
  39767. onBeforeRenderObservable: Observable<Scene>;
  39768. private _onBeforeRenderObserver;
  39769. /** Sets a function to be executed before rendering this scene */
  39770. set beforeRender(callback: Nullable<() => void>);
  39771. /**
  39772. * An event triggered after rendering the scene
  39773. */
  39774. onAfterRenderObservable: Observable<Scene>;
  39775. /**
  39776. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39777. */
  39778. onAfterRenderCameraObservable: Observable<Camera>;
  39779. private _onAfterRenderObserver;
  39780. /** Sets a function to be executed after rendering this scene */
  39781. set afterRender(callback: Nullable<() => void>);
  39782. /**
  39783. * An event triggered before animating the scene
  39784. */
  39785. onBeforeAnimationsObservable: Observable<Scene>;
  39786. /**
  39787. * An event triggered after animations processing
  39788. */
  39789. onAfterAnimationsObservable: Observable<Scene>;
  39790. /**
  39791. * An event triggered before draw calls are ready to be sent
  39792. */
  39793. onBeforeDrawPhaseObservable: Observable<Scene>;
  39794. /**
  39795. * An event triggered after draw calls have been sent
  39796. */
  39797. onAfterDrawPhaseObservable: Observable<Scene>;
  39798. /**
  39799. * An event triggered when the scene is ready
  39800. */
  39801. onReadyObservable: Observable<Scene>;
  39802. /**
  39803. * An event triggered before rendering a camera
  39804. */
  39805. onBeforeCameraRenderObservable: Observable<Camera>;
  39806. private _onBeforeCameraRenderObserver;
  39807. /** Sets a function to be executed before rendering a camera*/
  39808. set beforeCameraRender(callback: () => void);
  39809. /**
  39810. * An event triggered after rendering a camera
  39811. */
  39812. onAfterCameraRenderObservable: Observable<Camera>;
  39813. private _onAfterCameraRenderObserver;
  39814. /** Sets a function to be executed after rendering a camera*/
  39815. set afterCameraRender(callback: () => void);
  39816. /**
  39817. * An event triggered when active meshes evaluation is about to start
  39818. */
  39819. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  39820. /**
  39821. * An event triggered when active meshes evaluation is done
  39822. */
  39823. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  39824. /**
  39825. * An event triggered when particles rendering is about to start
  39826. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39827. */
  39828. onBeforeParticlesRenderingObservable: Observable<Scene>;
  39829. /**
  39830. * An event triggered when particles rendering is done
  39831. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  39832. */
  39833. onAfterParticlesRenderingObservable: Observable<Scene>;
  39834. /**
  39835. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  39836. */
  39837. onDataLoadedObservable: Observable<Scene>;
  39838. /**
  39839. * An event triggered when a camera is created
  39840. */
  39841. onNewCameraAddedObservable: Observable<Camera>;
  39842. /**
  39843. * An event triggered when a camera is removed
  39844. */
  39845. onCameraRemovedObservable: Observable<Camera>;
  39846. /**
  39847. * An event triggered when a light is created
  39848. */
  39849. onNewLightAddedObservable: Observable<Light>;
  39850. /**
  39851. * An event triggered when a light is removed
  39852. */
  39853. onLightRemovedObservable: Observable<Light>;
  39854. /**
  39855. * An event triggered when a geometry is created
  39856. */
  39857. onNewGeometryAddedObservable: Observable<Geometry>;
  39858. /**
  39859. * An event triggered when a geometry is removed
  39860. */
  39861. onGeometryRemovedObservable: Observable<Geometry>;
  39862. /**
  39863. * An event triggered when a transform node is created
  39864. */
  39865. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  39866. /**
  39867. * An event triggered when a transform node is removed
  39868. */
  39869. onTransformNodeRemovedObservable: Observable<TransformNode>;
  39870. /**
  39871. * An event triggered when a mesh is created
  39872. */
  39873. onNewMeshAddedObservable: Observable<AbstractMesh>;
  39874. /**
  39875. * An event triggered when a mesh is removed
  39876. */
  39877. onMeshRemovedObservable: Observable<AbstractMesh>;
  39878. /**
  39879. * An event triggered when a skeleton is created
  39880. */
  39881. onNewSkeletonAddedObservable: Observable<Skeleton>;
  39882. /**
  39883. * An event triggered when a skeleton is removed
  39884. */
  39885. onSkeletonRemovedObservable: Observable<Skeleton>;
  39886. /**
  39887. * An event triggered when a material is created
  39888. */
  39889. onNewMaterialAddedObservable: Observable<Material>;
  39890. /**
  39891. * An event triggered when a material is removed
  39892. */
  39893. onMaterialRemovedObservable: Observable<Material>;
  39894. /**
  39895. * An event triggered when a texture is created
  39896. */
  39897. onNewTextureAddedObservable: Observable<BaseTexture>;
  39898. /**
  39899. * An event triggered when a texture is removed
  39900. */
  39901. onTextureRemovedObservable: Observable<BaseTexture>;
  39902. /**
  39903. * An event triggered when render targets are about to be rendered
  39904. * Can happen multiple times per frame.
  39905. */
  39906. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  39907. /**
  39908. * An event triggered when render targets were rendered.
  39909. * Can happen multiple times per frame.
  39910. */
  39911. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  39912. /**
  39913. * An event triggered before calculating deterministic simulation step
  39914. */
  39915. onBeforeStepObservable: Observable<Scene>;
  39916. /**
  39917. * An event triggered after calculating deterministic simulation step
  39918. */
  39919. onAfterStepObservable: Observable<Scene>;
  39920. /**
  39921. * An event triggered when the activeCamera property is updated
  39922. */
  39923. onActiveCameraChanged: Observable<Scene>;
  39924. /**
  39925. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  39926. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39927. * 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)
  39928. */
  39929. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39930. /**
  39931. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  39932. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  39933. * 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)
  39934. */
  39935. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  39936. /**
  39937. * This Observable will when a mesh has been imported into the scene.
  39938. */
  39939. onMeshImportedObservable: Observable<AbstractMesh>;
  39940. /**
  39941. * This Observable will when an animation file has been imported into the scene.
  39942. */
  39943. onAnimationFileImportedObservable: Observable<Scene>;
  39944. /**
  39945. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  39946. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  39947. */
  39948. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  39949. /** @hidden */
  39950. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  39951. /**
  39952. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  39953. */
  39954. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  39955. /**
  39956. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  39957. */
  39958. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  39959. /**
  39960. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  39961. */
  39962. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  39963. /** Callback called when a pointer move is detected */
  39964. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39965. /** Callback called when a pointer down is detected */
  39966. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  39967. /** Callback called when a pointer up is detected */
  39968. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  39969. /** Callback called when a pointer pick is detected */
  39970. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  39971. /**
  39972. * 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).
  39973. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  39974. */
  39975. onPrePointerObservable: Observable<PointerInfoPre>;
  39976. /**
  39977. * Observable event triggered each time an input event is received from the rendering canvas
  39978. */
  39979. onPointerObservable: Observable<PointerInfo>;
  39980. /**
  39981. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  39982. */
  39983. get unTranslatedPointer(): Vector2;
  39984. /**
  39985. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  39986. */
  39987. static get DragMovementThreshold(): number;
  39988. static set DragMovementThreshold(value: number);
  39989. /**
  39990. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  39991. */
  39992. static get LongPressDelay(): number;
  39993. static set LongPressDelay(value: number);
  39994. /**
  39995. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  39996. */
  39997. static get DoubleClickDelay(): number;
  39998. static set DoubleClickDelay(value: number);
  39999. /** If you need to check double click without raising a single click at first click, enable this flag */
  40000. static get ExclusiveDoubleClickMode(): boolean;
  40001. static set ExclusiveDoubleClickMode(value: boolean);
  40002. /** @hidden */
  40003. _mirroredCameraPosition: Nullable<Vector3>;
  40004. /**
  40005. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40006. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40007. */
  40008. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40009. /**
  40010. * Observable event triggered each time an keyboard event is received from the hosting window
  40011. */
  40012. onKeyboardObservable: Observable<KeyboardInfo>;
  40013. private _useRightHandedSystem;
  40014. /**
  40015. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40016. */
  40017. set useRightHandedSystem(value: boolean);
  40018. get useRightHandedSystem(): boolean;
  40019. private _timeAccumulator;
  40020. private _currentStepId;
  40021. private _currentInternalStep;
  40022. /**
  40023. * Sets the step Id used by deterministic lock step
  40024. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40025. * @param newStepId defines the step Id
  40026. */
  40027. setStepId(newStepId: number): void;
  40028. /**
  40029. * Gets the step Id used by deterministic lock step
  40030. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40031. * @returns the step Id
  40032. */
  40033. getStepId(): number;
  40034. /**
  40035. * Gets the internal step used by deterministic lock step
  40036. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40037. * @returns the internal step
  40038. */
  40039. getInternalStep(): number;
  40040. private _fogEnabled;
  40041. /**
  40042. * Gets or sets a boolean indicating if fog is enabled on this scene
  40043. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40044. * (Default is true)
  40045. */
  40046. set fogEnabled(value: boolean);
  40047. get fogEnabled(): boolean;
  40048. private _fogMode;
  40049. /**
  40050. * Gets or sets the fog mode to use
  40051. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40052. * | mode | value |
  40053. * | --- | --- |
  40054. * | FOGMODE_NONE | 0 |
  40055. * | FOGMODE_EXP | 1 |
  40056. * | FOGMODE_EXP2 | 2 |
  40057. * | FOGMODE_LINEAR | 3 |
  40058. */
  40059. set fogMode(value: number);
  40060. get fogMode(): number;
  40061. /**
  40062. * Gets or sets the fog color to use
  40063. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40064. * (Default is Color3(0.2, 0.2, 0.3))
  40065. */
  40066. fogColor: Color3;
  40067. /**
  40068. * Gets or sets the fog density to use
  40069. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40070. * (Default is 0.1)
  40071. */
  40072. fogDensity: number;
  40073. /**
  40074. * Gets or sets the fog start distance to use
  40075. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40076. * (Default is 0)
  40077. */
  40078. fogStart: number;
  40079. /**
  40080. * Gets or sets the fog end distance to use
  40081. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40082. * (Default is 1000)
  40083. */
  40084. fogEnd: number;
  40085. /**
  40086. * Flag indicating that the frame buffer binding is handled by another component
  40087. */
  40088. prePass: boolean;
  40089. private _shadowsEnabled;
  40090. /**
  40091. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40092. */
  40093. set shadowsEnabled(value: boolean);
  40094. get shadowsEnabled(): boolean;
  40095. private _lightsEnabled;
  40096. /**
  40097. * Gets or sets a boolean indicating if lights are enabled on this scene
  40098. */
  40099. set lightsEnabled(value: boolean);
  40100. get lightsEnabled(): boolean;
  40101. /** All of the active cameras added to this scene. */
  40102. activeCameras: Camera[];
  40103. /** @hidden */
  40104. _activeCamera: Nullable<Camera>;
  40105. /** Gets or sets the current active camera */
  40106. get activeCamera(): Nullable<Camera>;
  40107. set activeCamera(value: Nullable<Camera>);
  40108. private _defaultMaterial;
  40109. /** The default material used on meshes when no material is affected */
  40110. get defaultMaterial(): Material;
  40111. /** The default material used on meshes when no material is affected */
  40112. set defaultMaterial(value: Material);
  40113. private _texturesEnabled;
  40114. /**
  40115. * Gets or sets a boolean indicating if textures are enabled on this scene
  40116. */
  40117. set texturesEnabled(value: boolean);
  40118. get texturesEnabled(): boolean;
  40119. /**
  40120. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40121. */
  40122. physicsEnabled: boolean;
  40123. /**
  40124. * Gets or sets a boolean indicating if particles are enabled on this scene
  40125. */
  40126. particlesEnabled: boolean;
  40127. /**
  40128. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40129. */
  40130. spritesEnabled: boolean;
  40131. private _skeletonsEnabled;
  40132. /**
  40133. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40134. */
  40135. set skeletonsEnabled(value: boolean);
  40136. get skeletonsEnabled(): boolean;
  40137. /**
  40138. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40139. */
  40140. lensFlaresEnabled: boolean;
  40141. /**
  40142. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40143. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40144. */
  40145. collisionsEnabled: boolean;
  40146. private _collisionCoordinator;
  40147. /** @hidden */
  40148. get collisionCoordinator(): ICollisionCoordinator;
  40149. /**
  40150. * Defines the gravity applied to this scene (used only for collisions)
  40151. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40152. */
  40153. gravity: Vector3;
  40154. /**
  40155. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40156. */
  40157. postProcessesEnabled: boolean;
  40158. /**
  40159. * Gets the current postprocess manager
  40160. */
  40161. postProcessManager: PostProcessManager;
  40162. /**
  40163. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40164. */
  40165. renderTargetsEnabled: boolean;
  40166. /**
  40167. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40168. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40169. */
  40170. dumpNextRenderTargets: boolean;
  40171. /**
  40172. * The list of user defined render targets added to the scene
  40173. */
  40174. customRenderTargets: RenderTargetTexture[];
  40175. /**
  40176. * Defines if texture loading must be delayed
  40177. * If true, textures will only be loaded when they need to be rendered
  40178. */
  40179. useDelayedTextureLoading: boolean;
  40180. /**
  40181. * Gets the list of meshes imported to the scene through SceneLoader
  40182. */
  40183. importedMeshesFiles: String[];
  40184. /**
  40185. * Gets or sets a boolean indicating if probes are enabled on this scene
  40186. */
  40187. probesEnabled: boolean;
  40188. /**
  40189. * Gets or sets the current offline provider to use to store scene data
  40190. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40191. */
  40192. offlineProvider: IOfflineProvider;
  40193. /**
  40194. * Gets or sets the action manager associated with the scene
  40195. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40196. */
  40197. actionManager: AbstractActionManager;
  40198. private _meshesForIntersections;
  40199. /**
  40200. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40201. */
  40202. proceduralTexturesEnabled: boolean;
  40203. private _engine;
  40204. private _totalVertices;
  40205. /** @hidden */
  40206. _activeIndices: PerfCounter;
  40207. /** @hidden */
  40208. _activeParticles: PerfCounter;
  40209. /** @hidden */
  40210. _activeBones: PerfCounter;
  40211. private _animationRatio;
  40212. /** @hidden */
  40213. _animationTimeLast: number;
  40214. /** @hidden */
  40215. _animationTime: number;
  40216. /**
  40217. * Gets or sets a general scale for animation speed
  40218. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40219. */
  40220. animationTimeScale: number;
  40221. /** @hidden */
  40222. _cachedMaterial: Nullable<Material>;
  40223. /** @hidden */
  40224. _cachedEffect: Nullable<Effect>;
  40225. /** @hidden */
  40226. _cachedVisibility: Nullable<number>;
  40227. private _renderId;
  40228. private _frameId;
  40229. private _executeWhenReadyTimeoutId;
  40230. private _intermediateRendering;
  40231. private _viewUpdateFlag;
  40232. private _projectionUpdateFlag;
  40233. /** @hidden */
  40234. _toBeDisposed: Nullable<IDisposable>[];
  40235. private _activeRequests;
  40236. /** @hidden */
  40237. _pendingData: any[];
  40238. private _isDisposed;
  40239. /**
  40240. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40241. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40242. */
  40243. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40244. private _activeMeshes;
  40245. private _processedMaterials;
  40246. private _renderTargets;
  40247. /** @hidden */
  40248. _activeParticleSystems: SmartArray<IParticleSystem>;
  40249. private _activeSkeletons;
  40250. private _softwareSkinnedMeshes;
  40251. private _renderingManager;
  40252. /** @hidden */
  40253. _activeAnimatables: Animatable[];
  40254. private _transformMatrix;
  40255. private _sceneUbo;
  40256. /** @hidden */
  40257. _viewMatrix: Matrix;
  40258. private _projectionMatrix;
  40259. /** @hidden */
  40260. _forcedViewPosition: Nullable<Vector3>;
  40261. /** @hidden */
  40262. _frustumPlanes: Plane[];
  40263. /**
  40264. * Gets the list of frustum planes (built from the active camera)
  40265. */
  40266. get frustumPlanes(): Plane[];
  40267. /**
  40268. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40269. * This is useful if there are more lights that the maximum simulteanous authorized
  40270. */
  40271. requireLightSorting: boolean;
  40272. /** @hidden */
  40273. readonly useMaterialMeshMap: boolean;
  40274. /** @hidden */
  40275. readonly useClonedMeshMap: boolean;
  40276. private _externalData;
  40277. private _uid;
  40278. /**
  40279. * @hidden
  40280. * Backing store of defined scene components.
  40281. */
  40282. _components: ISceneComponent[];
  40283. /**
  40284. * @hidden
  40285. * Backing store of defined scene components.
  40286. */
  40287. _serializableComponents: ISceneSerializableComponent[];
  40288. /**
  40289. * List of components to register on the next registration step.
  40290. */
  40291. private _transientComponents;
  40292. /**
  40293. * Registers the transient components if needed.
  40294. */
  40295. private _registerTransientComponents;
  40296. /**
  40297. * @hidden
  40298. * Add a component to the scene.
  40299. * Note that the ccomponent could be registered on th next frame if this is called after
  40300. * the register component stage.
  40301. * @param component Defines the component to add to the scene
  40302. */
  40303. _addComponent(component: ISceneComponent): void;
  40304. /**
  40305. * @hidden
  40306. * Gets a component from the scene.
  40307. * @param name defines the name of the component to retrieve
  40308. * @returns the component or null if not present
  40309. */
  40310. _getComponent(name: string): Nullable<ISceneComponent>;
  40311. /**
  40312. * @hidden
  40313. * Defines the actions happening before camera updates.
  40314. */
  40315. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40316. /**
  40317. * @hidden
  40318. * Defines the actions happening before clear the canvas.
  40319. */
  40320. _beforeClearStage: Stage<SimpleStageAction>;
  40321. /**
  40322. * @hidden
  40323. * Defines the actions when collecting render targets for the frame.
  40324. */
  40325. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40326. /**
  40327. * @hidden
  40328. * Defines the actions happening for one camera in the frame.
  40329. */
  40330. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40331. /**
  40332. * @hidden
  40333. * Defines the actions happening during the per mesh ready checks.
  40334. */
  40335. _isReadyForMeshStage: Stage<MeshStageAction>;
  40336. /**
  40337. * @hidden
  40338. * Defines the actions happening before evaluate active mesh checks.
  40339. */
  40340. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40341. /**
  40342. * @hidden
  40343. * Defines the actions happening during the evaluate sub mesh checks.
  40344. */
  40345. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40346. /**
  40347. * @hidden
  40348. * Defines the actions happening during the active mesh stage.
  40349. */
  40350. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40351. /**
  40352. * @hidden
  40353. * Defines the actions happening during the per camera render target step.
  40354. */
  40355. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40356. /**
  40357. * @hidden
  40358. * Defines the actions happening just before the active camera is drawing.
  40359. */
  40360. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40361. /**
  40362. * @hidden
  40363. * Defines the actions happening just before a render target is drawing.
  40364. */
  40365. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40366. /**
  40367. * @hidden
  40368. * Defines the actions happening just before a rendering group is drawing.
  40369. */
  40370. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40371. /**
  40372. * @hidden
  40373. * Defines the actions happening just before a mesh is drawing.
  40374. */
  40375. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40376. /**
  40377. * @hidden
  40378. * Defines the actions happening just after a mesh has been drawn.
  40379. */
  40380. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40381. /**
  40382. * @hidden
  40383. * Defines the actions happening just after a rendering group has been drawn.
  40384. */
  40385. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40386. /**
  40387. * @hidden
  40388. * Defines the actions happening just after the active camera has been drawn.
  40389. */
  40390. _afterCameraDrawStage: Stage<CameraStageAction>;
  40391. /**
  40392. * @hidden
  40393. * Defines the actions happening just after a render target has been drawn.
  40394. */
  40395. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40396. /**
  40397. * @hidden
  40398. * Defines the actions happening just after rendering all cameras and computing intersections.
  40399. */
  40400. _afterRenderStage: Stage<SimpleStageAction>;
  40401. /**
  40402. * @hidden
  40403. * Defines the actions happening when a pointer move event happens.
  40404. */
  40405. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40406. /**
  40407. * @hidden
  40408. * Defines the actions happening when a pointer down event happens.
  40409. */
  40410. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40411. /**
  40412. * @hidden
  40413. * Defines the actions happening when a pointer up event happens.
  40414. */
  40415. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40416. /**
  40417. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40418. */
  40419. private geometriesByUniqueId;
  40420. /**
  40421. * Creates a new Scene
  40422. * @param engine defines the engine to use to render this scene
  40423. * @param options defines the scene options
  40424. */
  40425. constructor(engine: Engine, options?: SceneOptions);
  40426. /**
  40427. * Gets a string identifying the name of the class
  40428. * @returns "Scene" string
  40429. */
  40430. getClassName(): string;
  40431. private _defaultMeshCandidates;
  40432. /**
  40433. * @hidden
  40434. */
  40435. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40436. private _defaultSubMeshCandidates;
  40437. /**
  40438. * @hidden
  40439. */
  40440. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40441. /**
  40442. * Sets the default candidate providers for the scene.
  40443. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40444. * and getCollidingSubMeshCandidates to their default function
  40445. */
  40446. setDefaultCandidateProviders(): void;
  40447. /**
  40448. * Gets the mesh that is currently under the pointer
  40449. */
  40450. get meshUnderPointer(): Nullable<AbstractMesh>;
  40451. /**
  40452. * Gets or sets the current on-screen X position of the pointer
  40453. */
  40454. get pointerX(): number;
  40455. set pointerX(value: number);
  40456. /**
  40457. * Gets or sets the current on-screen Y position of the pointer
  40458. */
  40459. get pointerY(): number;
  40460. set pointerY(value: number);
  40461. /**
  40462. * Gets the cached material (ie. the latest rendered one)
  40463. * @returns the cached material
  40464. */
  40465. getCachedMaterial(): Nullable<Material>;
  40466. /**
  40467. * Gets the cached effect (ie. the latest rendered one)
  40468. * @returns the cached effect
  40469. */
  40470. getCachedEffect(): Nullable<Effect>;
  40471. /**
  40472. * Gets the cached visibility state (ie. the latest rendered one)
  40473. * @returns the cached visibility state
  40474. */
  40475. getCachedVisibility(): Nullable<number>;
  40476. /**
  40477. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40478. * @param material defines the current material
  40479. * @param effect defines the current effect
  40480. * @param visibility defines the current visibility state
  40481. * @returns true if one parameter is not cached
  40482. */
  40483. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40484. /**
  40485. * Gets the engine associated with the scene
  40486. * @returns an Engine
  40487. */
  40488. getEngine(): Engine;
  40489. /**
  40490. * Gets the total number of vertices rendered per frame
  40491. * @returns the total number of vertices rendered per frame
  40492. */
  40493. getTotalVertices(): number;
  40494. /**
  40495. * Gets the performance counter for total vertices
  40496. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40497. */
  40498. get totalVerticesPerfCounter(): PerfCounter;
  40499. /**
  40500. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40501. * @returns the total number of active indices rendered per frame
  40502. */
  40503. getActiveIndices(): number;
  40504. /**
  40505. * Gets the performance counter for active indices
  40506. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40507. */
  40508. get totalActiveIndicesPerfCounter(): PerfCounter;
  40509. /**
  40510. * Gets the total number of active particles rendered per frame
  40511. * @returns the total number of active particles rendered per frame
  40512. */
  40513. getActiveParticles(): number;
  40514. /**
  40515. * Gets the performance counter for active particles
  40516. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40517. */
  40518. get activeParticlesPerfCounter(): PerfCounter;
  40519. /**
  40520. * Gets the total number of active bones rendered per frame
  40521. * @returns the total number of active bones rendered per frame
  40522. */
  40523. getActiveBones(): number;
  40524. /**
  40525. * Gets the performance counter for active bones
  40526. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40527. */
  40528. get activeBonesPerfCounter(): PerfCounter;
  40529. /**
  40530. * Gets the array of active meshes
  40531. * @returns an array of AbstractMesh
  40532. */
  40533. getActiveMeshes(): SmartArray<AbstractMesh>;
  40534. /**
  40535. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40536. * @returns a number
  40537. */
  40538. getAnimationRatio(): number;
  40539. /**
  40540. * Gets an unique Id for the current render phase
  40541. * @returns a number
  40542. */
  40543. getRenderId(): number;
  40544. /**
  40545. * Gets an unique Id for the current frame
  40546. * @returns a number
  40547. */
  40548. getFrameId(): number;
  40549. /** Call this function if you want to manually increment the render Id*/
  40550. incrementRenderId(): void;
  40551. private _createUbo;
  40552. /**
  40553. * Use this method to simulate a pointer move on a mesh
  40554. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40555. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40556. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40557. * @returns the current scene
  40558. */
  40559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40560. /**
  40561. * Use this method to simulate a pointer down on a mesh
  40562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40565. * @returns the current scene
  40566. */
  40567. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40568. /**
  40569. * Use this method to simulate a pointer up on a mesh
  40570. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40571. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40572. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40573. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40574. * @returns the current scene
  40575. */
  40576. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40577. /**
  40578. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40579. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40580. * @returns true if the pointer was captured
  40581. */
  40582. isPointerCaptured(pointerId?: number): boolean;
  40583. /**
  40584. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40585. * @param attachUp defines if you want to attach events to pointerup
  40586. * @param attachDown defines if you want to attach events to pointerdown
  40587. * @param attachMove defines if you want to attach events to pointermove
  40588. */
  40589. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40590. /** Detaches all event handlers*/
  40591. detachControl(): void;
  40592. /**
  40593. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40594. * Delay loaded resources are not taking in account
  40595. * @return true if all required resources are ready
  40596. */
  40597. isReady(): boolean;
  40598. /** Resets all cached information relative to material (including effect and visibility) */
  40599. resetCachedMaterial(): void;
  40600. /**
  40601. * Registers a function to be called before every frame render
  40602. * @param func defines the function to register
  40603. */
  40604. registerBeforeRender(func: () => void): void;
  40605. /**
  40606. * Unregisters a function called before every frame render
  40607. * @param func defines the function to unregister
  40608. */
  40609. unregisterBeforeRender(func: () => void): void;
  40610. /**
  40611. * Registers a function to be called after every frame render
  40612. * @param func defines the function to register
  40613. */
  40614. registerAfterRender(func: () => void): void;
  40615. /**
  40616. * Unregisters a function called after every frame render
  40617. * @param func defines the function to unregister
  40618. */
  40619. unregisterAfterRender(func: () => void): void;
  40620. private _executeOnceBeforeRender;
  40621. /**
  40622. * The provided function will run before render once and will be disposed afterwards.
  40623. * A timeout delay can be provided so that the function will be executed in N ms.
  40624. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40625. * @param func The function to be executed.
  40626. * @param timeout optional delay in ms
  40627. */
  40628. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40629. /** @hidden */
  40630. _addPendingData(data: any): void;
  40631. /** @hidden */
  40632. _removePendingData(data: any): void;
  40633. /**
  40634. * Returns the number of items waiting to be loaded
  40635. * @returns the number of items waiting to be loaded
  40636. */
  40637. getWaitingItemsCount(): number;
  40638. /**
  40639. * Returns a boolean indicating if the scene is still loading data
  40640. */
  40641. get isLoading(): boolean;
  40642. /**
  40643. * Registers a function to be executed when the scene is ready
  40644. * @param {Function} func - the function to be executed
  40645. */
  40646. executeWhenReady(func: () => void): void;
  40647. /**
  40648. * Returns a promise that resolves when the scene is ready
  40649. * @returns A promise that resolves when the scene is ready
  40650. */
  40651. whenReadyAsync(): Promise<void>;
  40652. /** @hidden */
  40653. _checkIsReady(): void;
  40654. /**
  40655. * Gets all animatable attached to the scene
  40656. */
  40657. get animatables(): Animatable[];
  40658. /**
  40659. * Resets the last animation time frame.
  40660. * Useful to override when animations start running when loading a scene for the first time.
  40661. */
  40662. resetLastAnimationTimeFrame(): void;
  40663. /**
  40664. * Gets the current view matrix
  40665. * @returns a Matrix
  40666. */
  40667. getViewMatrix(): Matrix;
  40668. /**
  40669. * Gets the current projection matrix
  40670. * @returns a Matrix
  40671. */
  40672. getProjectionMatrix(): Matrix;
  40673. /**
  40674. * Gets the current transform matrix
  40675. * @returns a Matrix made of View * Projection
  40676. */
  40677. getTransformMatrix(): Matrix;
  40678. /**
  40679. * Sets the current transform matrix
  40680. * @param viewL defines the View matrix to use
  40681. * @param projectionL defines the Projection matrix to use
  40682. * @param viewR defines the right View matrix to use (if provided)
  40683. * @param projectionR defines the right Projection matrix to use (if provided)
  40684. */
  40685. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40686. /**
  40687. * Gets the uniform buffer used to store scene data
  40688. * @returns a UniformBuffer
  40689. */
  40690. getSceneUniformBuffer(): UniformBuffer;
  40691. /**
  40692. * Gets an unique (relatively to the current scene) Id
  40693. * @returns an unique number for the scene
  40694. */
  40695. getUniqueId(): number;
  40696. /**
  40697. * Add a mesh to the list of scene's meshes
  40698. * @param newMesh defines the mesh to add
  40699. * @param recursive if all child meshes should also be added to the scene
  40700. */
  40701. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40702. /**
  40703. * Remove a mesh for the list of scene's meshes
  40704. * @param toRemove defines the mesh to remove
  40705. * @param recursive if all child meshes should also be removed from the scene
  40706. * @returns the index where the mesh was in the mesh list
  40707. */
  40708. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40709. /**
  40710. * Add a transform node to the list of scene's transform nodes
  40711. * @param newTransformNode defines the transform node to add
  40712. */
  40713. addTransformNode(newTransformNode: TransformNode): void;
  40714. /**
  40715. * Remove a transform node for the list of scene's transform nodes
  40716. * @param toRemove defines the transform node to remove
  40717. * @returns the index where the transform node was in the transform node list
  40718. */
  40719. removeTransformNode(toRemove: TransformNode): number;
  40720. /**
  40721. * Remove a skeleton for the list of scene's skeletons
  40722. * @param toRemove defines the skeleton to remove
  40723. * @returns the index where the skeleton was in the skeleton list
  40724. */
  40725. removeSkeleton(toRemove: Skeleton): number;
  40726. /**
  40727. * Remove a morph target for the list of scene's morph targets
  40728. * @param toRemove defines the morph target to remove
  40729. * @returns the index where the morph target was in the morph target list
  40730. */
  40731. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40732. /**
  40733. * Remove a light for the list of scene's lights
  40734. * @param toRemove defines the light to remove
  40735. * @returns the index where the light was in the light list
  40736. */
  40737. removeLight(toRemove: Light): number;
  40738. /**
  40739. * Remove a camera for the list of scene's cameras
  40740. * @param toRemove defines the camera to remove
  40741. * @returns the index where the camera was in the camera list
  40742. */
  40743. removeCamera(toRemove: Camera): number;
  40744. /**
  40745. * Remove a particle system for the list of scene's particle systems
  40746. * @param toRemove defines the particle system to remove
  40747. * @returns the index where the particle system was in the particle system list
  40748. */
  40749. removeParticleSystem(toRemove: IParticleSystem): number;
  40750. /**
  40751. * Remove a animation for the list of scene's animations
  40752. * @param toRemove defines the animation to remove
  40753. * @returns the index where the animation was in the animation list
  40754. */
  40755. removeAnimation(toRemove: Animation): number;
  40756. /**
  40757. * Will stop the animation of the given target
  40758. * @param target - the target
  40759. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40760. * @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)
  40761. */
  40762. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40763. /**
  40764. * Removes the given animation group from this scene.
  40765. * @param toRemove The animation group to remove
  40766. * @returns The index of the removed animation group
  40767. */
  40768. removeAnimationGroup(toRemove: AnimationGroup): number;
  40769. /**
  40770. * Removes the given multi-material from this scene.
  40771. * @param toRemove The multi-material to remove
  40772. * @returns The index of the removed multi-material
  40773. */
  40774. removeMultiMaterial(toRemove: MultiMaterial): number;
  40775. /**
  40776. * Removes the given material from this scene.
  40777. * @param toRemove The material to remove
  40778. * @returns The index of the removed material
  40779. */
  40780. removeMaterial(toRemove: Material): number;
  40781. /**
  40782. * Removes the given action manager from this scene.
  40783. * @param toRemove The action manager to remove
  40784. * @returns The index of the removed action manager
  40785. */
  40786. removeActionManager(toRemove: AbstractActionManager): number;
  40787. /**
  40788. * Removes the given texture from this scene.
  40789. * @param toRemove The texture to remove
  40790. * @returns The index of the removed texture
  40791. */
  40792. removeTexture(toRemove: BaseTexture): number;
  40793. /**
  40794. * Adds the given light to this scene
  40795. * @param newLight The light to add
  40796. */
  40797. addLight(newLight: Light): void;
  40798. /**
  40799. * Sorts the list list based on light priorities
  40800. */
  40801. sortLightsByPriority(): void;
  40802. /**
  40803. * Adds the given camera to this scene
  40804. * @param newCamera The camera to add
  40805. */
  40806. addCamera(newCamera: Camera): void;
  40807. /**
  40808. * Adds the given skeleton to this scene
  40809. * @param newSkeleton The skeleton to add
  40810. */
  40811. addSkeleton(newSkeleton: Skeleton): void;
  40812. /**
  40813. * Adds the given particle system to this scene
  40814. * @param newParticleSystem The particle system to add
  40815. */
  40816. addParticleSystem(newParticleSystem: IParticleSystem): void;
  40817. /**
  40818. * Adds the given animation to this scene
  40819. * @param newAnimation The animation to add
  40820. */
  40821. addAnimation(newAnimation: Animation): void;
  40822. /**
  40823. * Adds the given animation group to this scene.
  40824. * @param newAnimationGroup The animation group to add
  40825. */
  40826. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  40827. /**
  40828. * Adds the given multi-material to this scene
  40829. * @param newMultiMaterial The multi-material to add
  40830. */
  40831. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  40832. /**
  40833. * Adds the given material to this scene
  40834. * @param newMaterial The material to add
  40835. */
  40836. addMaterial(newMaterial: Material): void;
  40837. /**
  40838. * Adds the given morph target to this scene
  40839. * @param newMorphTargetManager The morph target to add
  40840. */
  40841. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  40842. /**
  40843. * Adds the given geometry to this scene
  40844. * @param newGeometry The geometry to add
  40845. */
  40846. addGeometry(newGeometry: Geometry): void;
  40847. /**
  40848. * Adds the given action manager to this scene
  40849. * @param newActionManager The action manager to add
  40850. */
  40851. addActionManager(newActionManager: AbstractActionManager): void;
  40852. /**
  40853. * Adds the given texture to this scene.
  40854. * @param newTexture The texture to add
  40855. */
  40856. addTexture(newTexture: BaseTexture): void;
  40857. /**
  40858. * Switch active camera
  40859. * @param newCamera defines the new active camera
  40860. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  40861. */
  40862. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  40863. /**
  40864. * sets the active camera of the scene using its ID
  40865. * @param id defines the camera's ID
  40866. * @return the new active camera or null if none found.
  40867. */
  40868. setActiveCameraByID(id: string): Nullable<Camera>;
  40869. /**
  40870. * sets the active camera of the scene using its name
  40871. * @param name defines the camera's name
  40872. * @returns the new active camera or null if none found.
  40873. */
  40874. setActiveCameraByName(name: string): Nullable<Camera>;
  40875. /**
  40876. * get an animation group using its name
  40877. * @param name defines the material's name
  40878. * @return the animation group or null if none found.
  40879. */
  40880. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  40881. /**
  40882. * Get a material using its unique id
  40883. * @param uniqueId defines the material's unique id
  40884. * @return the material or null if none found.
  40885. */
  40886. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  40887. /**
  40888. * get a material using its id
  40889. * @param id defines the material's ID
  40890. * @return the material or null if none found.
  40891. */
  40892. getMaterialByID(id: string): Nullable<Material>;
  40893. /**
  40894. * Gets a the last added material using a given id
  40895. * @param id defines the material's ID
  40896. * @return the last material with the given id or null if none found.
  40897. */
  40898. getLastMaterialByID(id: string): Nullable<Material>;
  40899. /**
  40900. * Gets a material using its name
  40901. * @param name defines the material's name
  40902. * @return the material or null if none found.
  40903. */
  40904. getMaterialByName(name: string): Nullable<Material>;
  40905. /**
  40906. * Get a texture using its unique id
  40907. * @param uniqueId defines the texture's unique id
  40908. * @return the texture or null if none found.
  40909. */
  40910. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  40911. /**
  40912. * Gets a camera using its id
  40913. * @param id defines the id to look for
  40914. * @returns the camera or null if not found
  40915. */
  40916. getCameraByID(id: string): Nullable<Camera>;
  40917. /**
  40918. * Gets a camera using its unique id
  40919. * @param uniqueId defines the unique id to look for
  40920. * @returns the camera or null if not found
  40921. */
  40922. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  40923. /**
  40924. * Gets a camera using its name
  40925. * @param name defines the camera's name
  40926. * @return the camera or null if none found.
  40927. */
  40928. getCameraByName(name: string): Nullable<Camera>;
  40929. /**
  40930. * Gets a bone using its id
  40931. * @param id defines the bone's id
  40932. * @return the bone or null if not found
  40933. */
  40934. getBoneByID(id: string): Nullable<Bone>;
  40935. /**
  40936. * Gets a bone using its id
  40937. * @param name defines the bone's name
  40938. * @return the bone or null if not found
  40939. */
  40940. getBoneByName(name: string): Nullable<Bone>;
  40941. /**
  40942. * Gets a light node using its name
  40943. * @param name defines the the light's name
  40944. * @return the light or null if none found.
  40945. */
  40946. getLightByName(name: string): Nullable<Light>;
  40947. /**
  40948. * Gets a light node using its id
  40949. * @param id defines the light's id
  40950. * @return the light or null if none found.
  40951. */
  40952. getLightByID(id: string): Nullable<Light>;
  40953. /**
  40954. * Gets a light node using its scene-generated unique ID
  40955. * @param uniqueId defines the light's unique id
  40956. * @return the light or null if none found.
  40957. */
  40958. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  40959. /**
  40960. * Gets a particle system by id
  40961. * @param id defines the particle system id
  40962. * @return the corresponding system or null if none found
  40963. */
  40964. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  40965. /**
  40966. * Gets a geometry using its ID
  40967. * @param id defines the geometry's id
  40968. * @return the geometry or null if none found.
  40969. */
  40970. getGeometryByID(id: string): Nullable<Geometry>;
  40971. private _getGeometryByUniqueID;
  40972. /**
  40973. * Add a new geometry to this scene
  40974. * @param geometry defines the geometry to be added to the scene.
  40975. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  40976. * @return a boolean defining if the geometry was added or not
  40977. */
  40978. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  40979. /**
  40980. * Removes an existing geometry
  40981. * @param geometry defines the geometry to be removed from the scene
  40982. * @return a boolean defining if the geometry was removed or not
  40983. */
  40984. removeGeometry(geometry: Geometry): boolean;
  40985. /**
  40986. * Gets the list of geometries attached to the scene
  40987. * @returns an array of Geometry
  40988. */
  40989. getGeometries(): Geometry[];
  40990. /**
  40991. * Gets the first added mesh found of a given ID
  40992. * @param id defines the id to search for
  40993. * @return the mesh found or null if not found at all
  40994. */
  40995. getMeshByID(id: string): Nullable<AbstractMesh>;
  40996. /**
  40997. * Gets a list of meshes using their id
  40998. * @param id defines the id to search for
  40999. * @returns a list of meshes
  41000. */
  41001. getMeshesByID(id: string): Array<AbstractMesh>;
  41002. /**
  41003. * Gets the first added transform node found of a given ID
  41004. * @param id defines the id to search for
  41005. * @return the found transform node or null if not found at all.
  41006. */
  41007. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41008. /**
  41009. * Gets a transform node with its auto-generated unique id
  41010. * @param uniqueId efines the unique id to search for
  41011. * @return the found transform node or null if not found at all.
  41012. */
  41013. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41014. /**
  41015. * Gets a list of transform nodes using their id
  41016. * @param id defines the id to search for
  41017. * @returns a list of transform nodes
  41018. */
  41019. getTransformNodesByID(id: string): Array<TransformNode>;
  41020. /**
  41021. * Gets a mesh with its auto-generated unique id
  41022. * @param uniqueId defines the unique id to search for
  41023. * @return the found mesh or null if not found at all.
  41024. */
  41025. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41026. /**
  41027. * Gets a the last added mesh using a given id
  41028. * @param id defines the id to search for
  41029. * @return the found mesh or null if not found at all.
  41030. */
  41031. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41032. /**
  41033. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41034. * @param id defines the id to search for
  41035. * @return the found node or null if not found at all
  41036. */
  41037. getLastEntryByID(id: string): Nullable<Node>;
  41038. /**
  41039. * Gets a node (Mesh, Camera, Light) using a given id
  41040. * @param id defines the id to search for
  41041. * @return the found node or null if not found at all
  41042. */
  41043. getNodeByID(id: string): Nullable<Node>;
  41044. /**
  41045. * Gets a node (Mesh, Camera, Light) using a given name
  41046. * @param name defines the name to search for
  41047. * @return the found node or null if not found at all.
  41048. */
  41049. getNodeByName(name: string): Nullable<Node>;
  41050. /**
  41051. * Gets a mesh using a given name
  41052. * @param name defines the name to search for
  41053. * @return the found mesh or null if not found at all.
  41054. */
  41055. getMeshByName(name: string): Nullable<AbstractMesh>;
  41056. /**
  41057. * Gets a transform node using a given name
  41058. * @param name defines the name to search for
  41059. * @return the found transform node or null if not found at all.
  41060. */
  41061. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41062. /**
  41063. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41064. * @param id defines the id to search for
  41065. * @return the found skeleton or null if not found at all.
  41066. */
  41067. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41068. /**
  41069. * Gets a skeleton using a given auto generated unique id
  41070. * @param uniqueId defines the unique id to search for
  41071. * @return the found skeleton or null if not found at all.
  41072. */
  41073. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41074. /**
  41075. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41076. * @param id defines the id to search for
  41077. * @return the found skeleton or null if not found at all.
  41078. */
  41079. getSkeletonById(id: string): Nullable<Skeleton>;
  41080. /**
  41081. * Gets a skeleton using a given name
  41082. * @param name defines the name to search for
  41083. * @return the found skeleton or null if not found at all.
  41084. */
  41085. getSkeletonByName(name: string): Nullable<Skeleton>;
  41086. /**
  41087. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41088. * @param id defines the id to search for
  41089. * @return the found morph target manager or null if not found at all.
  41090. */
  41091. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41092. /**
  41093. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41094. * @param id defines the id to search for
  41095. * @return the found morph target or null if not found at all.
  41096. */
  41097. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41098. /**
  41099. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41100. * @param name defines the name to search for
  41101. * @return the found morph target or null if not found at all.
  41102. */
  41103. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41104. /**
  41105. * Gets a post process using a given name (if many are found, this function will pick the first one)
  41106. * @param name defines the name to search for
  41107. * @return the found post process or null if not found at all.
  41108. */
  41109. getPostProcessByName(name: string): Nullable<PostProcess>;
  41110. /**
  41111. * Gets a boolean indicating if the given mesh is active
  41112. * @param mesh defines the mesh to look for
  41113. * @returns true if the mesh is in the active list
  41114. */
  41115. isActiveMesh(mesh: AbstractMesh): boolean;
  41116. /**
  41117. * Return a unique id as a string which can serve as an identifier for the scene
  41118. */
  41119. get uid(): string;
  41120. /**
  41121. * Add an externaly attached data from its key.
  41122. * This method call will fail and return false, if such key already exists.
  41123. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41124. * @param key the unique key that identifies the data
  41125. * @param data the data object to associate to the key for this Engine instance
  41126. * @return true if no such key were already present and the data was added successfully, false otherwise
  41127. */
  41128. addExternalData<T>(key: string, data: T): boolean;
  41129. /**
  41130. * Get an externaly attached data from its key
  41131. * @param key the unique key that identifies the data
  41132. * @return the associated data, if present (can be null), or undefined if not present
  41133. */
  41134. getExternalData<T>(key: string): Nullable<T>;
  41135. /**
  41136. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41137. * @param key the unique key that identifies the data
  41138. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41139. * @return the associated data, can be null if the factory returned null.
  41140. */
  41141. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41142. /**
  41143. * Remove an externaly attached data from the Engine instance
  41144. * @param key the unique key that identifies the data
  41145. * @return true if the data was successfully removed, false if it doesn't exist
  41146. */
  41147. removeExternalData(key: string): boolean;
  41148. private _evaluateSubMesh;
  41149. /**
  41150. * Clear the processed materials smart array preventing retention point in material dispose.
  41151. */
  41152. freeProcessedMaterials(): void;
  41153. private _preventFreeActiveMeshesAndRenderingGroups;
  41154. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41155. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41156. * when disposing several meshes in a row or a hierarchy of meshes.
  41157. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41158. */
  41159. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41160. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41161. /**
  41162. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41163. */
  41164. freeActiveMeshes(): void;
  41165. /**
  41166. * Clear the info related to rendering groups preventing retention points during dispose.
  41167. */
  41168. freeRenderingGroups(): void;
  41169. /** @hidden */
  41170. _isInIntermediateRendering(): boolean;
  41171. /**
  41172. * Lambda returning the list of potentially active meshes.
  41173. */
  41174. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41175. /**
  41176. * Lambda returning the list of potentially active sub meshes.
  41177. */
  41178. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41179. /**
  41180. * Lambda returning the list of potentially intersecting sub meshes.
  41181. */
  41182. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41183. /**
  41184. * Lambda returning the list of potentially colliding sub meshes.
  41185. */
  41186. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41187. private _activeMeshesFrozen;
  41188. private _skipEvaluateActiveMeshesCompletely;
  41189. /**
  41190. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41191. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41192. * @returns the current scene
  41193. */
  41194. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41195. /**
  41196. * Use this function to restart evaluating active meshes on every frame
  41197. * @returns the current scene
  41198. */
  41199. unfreezeActiveMeshes(): Scene;
  41200. private _evaluateActiveMeshes;
  41201. private _activeMesh;
  41202. /**
  41203. * Update the transform matrix to update from the current active camera
  41204. * @param force defines a boolean used to force the update even if cache is up to date
  41205. */
  41206. updateTransformMatrix(force?: boolean): void;
  41207. private _bindFrameBuffer;
  41208. /** @hidden */
  41209. _allowPostProcessClearColor: boolean;
  41210. /** @hidden */
  41211. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41212. private _processSubCameras;
  41213. private _checkIntersections;
  41214. /** @hidden */
  41215. _advancePhysicsEngineStep(step: number): void;
  41216. /**
  41217. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41218. */
  41219. getDeterministicFrameTime: () => number;
  41220. /** @hidden */
  41221. _animate(): void;
  41222. /** Execute all animations (for a frame) */
  41223. animate(): void;
  41224. /**
  41225. * Render the scene
  41226. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41227. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41228. */
  41229. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41230. /**
  41231. * Freeze all materials
  41232. * A frozen material will not be updatable but should be faster to render
  41233. */
  41234. freezeMaterials(): void;
  41235. /**
  41236. * Unfreeze all materials
  41237. * A frozen material will not be updatable but should be faster to render
  41238. */
  41239. unfreezeMaterials(): void;
  41240. /**
  41241. * Releases all held ressources
  41242. */
  41243. dispose(): void;
  41244. /**
  41245. * Gets if the scene is already disposed
  41246. */
  41247. get isDisposed(): boolean;
  41248. /**
  41249. * Call this function to reduce memory footprint of the scene.
  41250. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41251. */
  41252. clearCachedVertexData(): void;
  41253. /**
  41254. * This function will remove the local cached buffer data from texture.
  41255. * It will save memory but will prevent the texture from being rebuilt
  41256. */
  41257. cleanCachedTextureBuffer(): void;
  41258. /**
  41259. * Get the world extend vectors with an optional filter
  41260. *
  41261. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41262. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41263. */
  41264. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41265. min: Vector3;
  41266. max: Vector3;
  41267. };
  41268. /**
  41269. * Creates a ray that can be used to pick in the scene
  41270. * @param x defines the x coordinate of the origin (on-screen)
  41271. * @param y defines the y coordinate of the origin (on-screen)
  41272. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41273. * @param camera defines the camera to use for the picking
  41274. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41275. * @returns a Ray
  41276. */
  41277. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41278. /**
  41279. * Creates a ray that can be used to pick in the scene
  41280. * @param x defines the x coordinate of the origin (on-screen)
  41281. * @param y defines the y coordinate of the origin (on-screen)
  41282. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41283. * @param result defines the ray where to store the picking ray
  41284. * @param camera defines the camera to use for the picking
  41285. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41286. * @returns the current scene
  41287. */
  41288. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41289. /**
  41290. * Creates a ray that can be used to pick in the scene
  41291. * @param x defines the x coordinate of the origin (on-screen)
  41292. * @param y defines the y coordinate of the origin (on-screen)
  41293. * @param camera defines the camera to use for the picking
  41294. * @returns a Ray
  41295. */
  41296. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41297. /**
  41298. * Creates a ray that can be used to pick in the scene
  41299. * @param x defines the x coordinate of the origin (on-screen)
  41300. * @param y defines the y coordinate of the origin (on-screen)
  41301. * @param result defines the ray where to store the picking ray
  41302. * @param camera defines the camera to use for the picking
  41303. * @returns the current scene
  41304. */
  41305. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41306. /** Launch a ray to try to pick a mesh in the scene
  41307. * @param x position on screen
  41308. * @param y position on screen
  41309. * @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
  41310. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41311. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41312. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41313. * @returns a PickingInfo
  41314. */
  41315. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41316. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41317. * @param x position on screen
  41318. * @param y position on screen
  41319. * @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
  41320. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41321. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41322. * @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)
  41323. */
  41324. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41325. /** Use the given ray to pick a mesh in the scene
  41326. * @param ray The ray to use to pick meshes
  41327. * @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
  41328. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41329. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41330. * @returns a PickingInfo
  41331. */
  41332. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41333. /**
  41334. * Launch a ray to try to pick a mesh in the scene
  41335. * @param x X position on screen
  41336. * @param y Y position on screen
  41337. * @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
  41338. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41339. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41340. * @returns an array of PickingInfo
  41341. */
  41342. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41343. /**
  41344. * Launch a ray to try to pick a mesh in the scene
  41345. * @param ray Ray to use
  41346. * @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
  41347. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41348. * @returns an array of PickingInfo
  41349. */
  41350. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41351. /**
  41352. * Force the value of meshUnderPointer
  41353. * @param mesh defines the mesh to use
  41354. * @param pointerId optional pointer id when using more than one pointer
  41355. */
  41356. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  41357. /**
  41358. * Gets the mesh under the pointer
  41359. * @returns a Mesh or null if no mesh is under the pointer
  41360. */
  41361. getPointerOverMesh(): Nullable<AbstractMesh>;
  41362. /** @hidden */
  41363. _rebuildGeometries(): void;
  41364. /** @hidden */
  41365. _rebuildTextures(): void;
  41366. private _getByTags;
  41367. /**
  41368. * Get a list of meshes by tags
  41369. * @param tagsQuery defines the tags query to use
  41370. * @param forEach defines a predicate used to filter results
  41371. * @returns an array of Mesh
  41372. */
  41373. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41374. /**
  41375. * Get a list of cameras by tags
  41376. * @param tagsQuery defines the tags query to use
  41377. * @param forEach defines a predicate used to filter results
  41378. * @returns an array of Camera
  41379. */
  41380. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41381. /**
  41382. * Get a list of lights by tags
  41383. * @param tagsQuery defines the tags query to use
  41384. * @param forEach defines a predicate used to filter results
  41385. * @returns an array of Light
  41386. */
  41387. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41388. /**
  41389. * Get a list of materials by tags
  41390. * @param tagsQuery defines the tags query to use
  41391. * @param forEach defines a predicate used to filter results
  41392. * @returns an array of Material
  41393. */
  41394. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41395. /**
  41396. * Get a list of transform nodes by tags
  41397. * @param tagsQuery defines the tags query to use
  41398. * @param forEach defines a predicate used to filter results
  41399. * @returns an array of TransformNode
  41400. */
  41401. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  41402. /**
  41403. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41404. * This allowed control for front to back rendering or reversly depending of the special needs.
  41405. *
  41406. * @param renderingGroupId The rendering group id corresponding to its index
  41407. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41408. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41409. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41410. */
  41411. 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;
  41412. /**
  41413. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41414. *
  41415. * @param renderingGroupId The rendering group id corresponding to its index
  41416. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41417. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41418. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41419. */
  41420. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41421. /**
  41422. * Gets the current auto clear configuration for one rendering group of the rendering
  41423. * manager.
  41424. * @param index the rendering group index to get the information for
  41425. * @returns The auto clear setup for the requested rendering group
  41426. */
  41427. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41428. private _blockMaterialDirtyMechanism;
  41429. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41430. get blockMaterialDirtyMechanism(): boolean;
  41431. set blockMaterialDirtyMechanism(value: boolean);
  41432. /**
  41433. * Will flag all materials as dirty to trigger new shader compilation
  41434. * @param flag defines the flag used to specify which material part must be marked as dirty
  41435. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41436. */
  41437. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41438. /** @hidden */
  41439. _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;
  41440. /** @hidden */
  41441. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41442. /** @hidden */
  41443. _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;
  41444. /** @hidden */
  41445. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41446. /** @hidden */
  41447. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41448. /** @hidden */
  41449. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41450. }
  41451. }
  41452. declare module BABYLON {
  41453. /**
  41454. * Set of assets to keep when moving a scene into an asset container.
  41455. */
  41456. export class KeepAssets extends AbstractScene {
  41457. }
  41458. /**
  41459. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41460. */
  41461. export class InstantiatedEntries {
  41462. /**
  41463. * List of new root nodes (eg. nodes with no parent)
  41464. */
  41465. rootNodes: TransformNode[];
  41466. /**
  41467. * List of new skeletons
  41468. */
  41469. skeletons: Skeleton[];
  41470. /**
  41471. * List of new animation groups
  41472. */
  41473. animationGroups: AnimationGroup[];
  41474. }
  41475. /**
  41476. * Container with a set of assets that can be added or removed from a scene.
  41477. */
  41478. export class AssetContainer extends AbstractScene {
  41479. private _wasAddedToScene;
  41480. /**
  41481. * The scene the AssetContainer belongs to.
  41482. */
  41483. scene: Scene;
  41484. /**
  41485. * Instantiates an AssetContainer.
  41486. * @param scene The scene the AssetContainer belongs to.
  41487. */
  41488. constructor(scene: Scene);
  41489. /**
  41490. * Instantiate or clone all meshes and add the new ones to the scene.
  41491. * Skeletons and animation groups will all be cloned
  41492. * @param nameFunction defines an optional function used to get new names for clones
  41493. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41494. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41495. */
  41496. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41497. /**
  41498. * Adds all the assets from the container to the scene.
  41499. */
  41500. addAllToScene(): void;
  41501. /**
  41502. * Removes all the assets in the container from the scene
  41503. */
  41504. removeAllFromScene(): void;
  41505. /**
  41506. * Disposes all the assets in the container
  41507. */
  41508. dispose(): void;
  41509. private _moveAssets;
  41510. /**
  41511. * Removes all the assets contained in the scene and adds them to the container.
  41512. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41513. */
  41514. moveAllFromScene(keepAssets?: KeepAssets): void;
  41515. /**
  41516. * 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.
  41517. * @returns the root mesh
  41518. */
  41519. createRootMesh(): Mesh;
  41520. /**
  41521. * Merge animations (direct and animation groups) from this asset container into a scene
  41522. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41523. * @param animatables set of animatables to retarget to a node from the scene
  41524. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41525. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41526. */
  41527. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41528. }
  41529. }
  41530. declare module BABYLON {
  41531. /**
  41532. * Defines how the parser contract is defined.
  41533. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41534. */
  41535. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41536. /**
  41537. * Defines how the individual parser contract is defined.
  41538. * These parser can parse an individual asset
  41539. */
  41540. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41541. /**
  41542. * Base class of the scene acting as a container for the different elements composing a scene.
  41543. * This class is dynamically extended by the different components of the scene increasing
  41544. * flexibility and reducing coupling
  41545. */
  41546. export abstract class AbstractScene {
  41547. /**
  41548. * Stores the list of available parsers in the application.
  41549. */
  41550. private static _BabylonFileParsers;
  41551. /**
  41552. * Stores the list of available individual parsers in the application.
  41553. */
  41554. private static _IndividualBabylonFileParsers;
  41555. /**
  41556. * Adds a parser in the list of available ones
  41557. * @param name Defines the name of the parser
  41558. * @param parser Defines the parser to add
  41559. */
  41560. static AddParser(name: string, parser: BabylonFileParser): void;
  41561. /**
  41562. * Gets a general parser from the list of avaialble ones
  41563. * @param name Defines the name of the parser
  41564. * @returns the requested parser or null
  41565. */
  41566. static GetParser(name: string): Nullable<BabylonFileParser>;
  41567. /**
  41568. * Adds n individual parser in the list of available ones
  41569. * @param name Defines the name of the parser
  41570. * @param parser Defines the parser to add
  41571. */
  41572. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41573. /**
  41574. * Gets an individual parser from the list of avaialble ones
  41575. * @param name Defines the name of the parser
  41576. * @returns the requested parser or null
  41577. */
  41578. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41579. /**
  41580. * Parser json data and populate both a scene and its associated container object
  41581. * @param jsonData Defines the data to parse
  41582. * @param scene Defines the scene to parse the data for
  41583. * @param container Defines the container attached to the parsing sequence
  41584. * @param rootUrl Defines the root url of the data
  41585. */
  41586. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41587. /**
  41588. * Gets the list of root nodes (ie. nodes with no parent)
  41589. */
  41590. rootNodes: Node[];
  41591. /** All of the cameras added to this scene
  41592. * @see https://doc.babylonjs.com/babylon101/cameras
  41593. */
  41594. cameras: Camera[];
  41595. /**
  41596. * All of the lights added to this scene
  41597. * @see https://doc.babylonjs.com/babylon101/lights
  41598. */
  41599. lights: Light[];
  41600. /**
  41601. * All of the (abstract) meshes added to this scene
  41602. */
  41603. meshes: AbstractMesh[];
  41604. /**
  41605. * The list of skeletons added to the scene
  41606. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41607. */
  41608. skeletons: Skeleton[];
  41609. /**
  41610. * All of the particle systems added to this scene
  41611. * @see https://doc.babylonjs.com/babylon101/particles
  41612. */
  41613. particleSystems: IParticleSystem[];
  41614. /**
  41615. * Gets a list of Animations associated with the scene
  41616. */
  41617. animations: Animation[];
  41618. /**
  41619. * All of the animation groups added to this scene
  41620. * @see https://doc.babylonjs.com/how_to/group
  41621. */
  41622. animationGroups: AnimationGroup[];
  41623. /**
  41624. * All of the multi-materials added to this scene
  41625. * @see https://doc.babylonjs.com/how_to/multi_materials
  41626. */
  41627. multiMaterials: MultiMaterial[];
  41628. /**
  41629. * All of the materials added to this scene
  41630. * In the context of a Scene, it is not supposed to be modified manually.
  41631. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41632. * Note also that the order of the Material within the array is not significant and might change.
  41633. * @see https://doc.babylonjs.com/babylon101/materials
  41634. */
  41635. materials: Material[];
  41636. /**
  41637. * The list of morph target managers added to the scene
  41638. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41639. */
  41640. morphTargetManagers: MorphTargetManager[];
  41641. /**
  41642. * The list of geometries used in the scene.
  41643. */
  41644. geometries: Geometry[];
  41645. /**
  41646. * All of the tranform nodes added to this scene
  41647. * In the context of a Scene, it is not supposed to be modified manually.
  41648. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41649. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41650. * @see https://doc.babylonjs.com/how_to/transformnode
  41651. */
  41652. transformNodes: TransformNode[];
  41653. /**
  41654. * ActionManagers available on the scene.
  41655. */
  41656. actionManagers: AbstractActionManager[];
  41657. /**
  41658. * Textures to keep.
  41659. */
  41660. textures: BaseTexture[];
  41661. /** @hidden */
  41662. protected _environmentTexture: Nullable<BaseTexture>;
  41663. /**
  41664. * Texture used in all pbr material as the reflection texture.
  41665. * As in the majority of the scene they are the same (exception for multi room and so on),
  41666. * this is easier to reference from here than from all the materials.
  41667. */
  41668. get environmentTexture(): Nullable<BaseTexture>;
  41669. set environmentTexture(value: Nullable<BaseTexture>);
  41670. /**
  41671. * The list of postprocesses added to the scene
  41672. */
  41673. postProcesses: PostProcess[];
  41674. /**
  41675. * @returns all meshes, lights, cameras, transformNodes and bones
  41676. */
  41677. getNodes(): Array<Node>;
  41678. }
  41679. }
  41680. declare module BABYLON {
  41681. /**
  41682. * Interface used to define options for Sound class
  41683. */
  41684. export interface ISoundOptions {
  41685. /**
  41686. * Does the sound autoplay once loaded.
  41687. */
  41688. autoplay?: boolean;
  41689. /**
  41690. * Does the sound loop after it finishes playing once.
  41691. */
  41692. loop?: boolean;
  41693. /**
  41694. * Sound's volume
  41695. */
  41696. volume?: number;
  41697. /**
  41698. * Is it a spatial sound?
  41699. */
  41700. spatialSound?: boolean;
  41701. /**
  41702. * Maximum distance to hear that sound
  41703. */
  41704. maxDistance?: number;
  41705. /**
  41706. * Uses user defined attenuation function
  41707. */
  41708. useCustomAttenuation?: boolean;
  41709. /**
  41710. * Define the roll off factor of spatial sounds.
  41711. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41712. */
  41713. rolloffFactor?: number;
  41714. /**
  41715. * Define the reference distance the sound should be heard perfectly.
  41716. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41717. */
  41718. refDistance?: number;
  41719. /**
  41720. * Define the distance attenuation model the sound will follow.
  41721. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41722. */
  41723. distanceModel?: string;
  41724. /**
  41725. * Defines the playback speed (1 by default)
  41726. */
  41727. playbackRate?: number;
  41728. /**
  41729. * Defines if the sound is from a streaming source
  41730. */
  41731. streaming?: boolean;
  41732. /**
  41733. * Defines an optional length (in seconds) inside the sound file
  41734. */
  41735. length?: number;
  41736. /**
  41737. * Defines an optional offset (in seconds) inside the sound file
  41738. */
  41739. offset?: number;
  41740. /**
  41741. * If true, URLs will not be required to state the audio file codec to use.
  41742. */
  41743. skipCodecCheck?: boolean;
  41744. }
  41745. /**
  41746. * Defines a sound that can be played in the application.
  41747. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41748. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41749. */
  41750. export class Sound {
  41751. /**
  41752. * The name of the sound in the scene.
  41753. */
  41754. name: string;
  41755. /**
  41756. * Does the sound autoplay once loaded.
  41757. */
  41758. autoplay: boolean;
  41759. /**
  41760. * Does the sound loop after it finishes playing once.
  41761. */
  41762. loop: boolean;
  41763. /**
  41764. * Does the sound use a custom attenuation curve to simulate the falloff
  41765. * happening when the source gets further away from the camera.
  41766. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41767. */
  41768. useCustomAttenuation: boolean;
  41769. /**
  41770. * The sound track id this sound belongs to.
  41771. */
  41772. soundTrackId: number;
  41773. /**
  41774. * Is this sound currently played.
  41775. */
  41776. isPlaying: boolean;
  41777. /**
  41778. * Is this sound currently paused.
  41779. */
  41780. isPaused: boolean;
  41781. /**
  41782. * Does this sound enables spatial sound.
  41783. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41784. */
  41785. spatialSound: boolean;
  41786. /**
  41787. * Define the reference distance the sound should be heard perfectly.
  41788. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41789. */
  41790. refDistance: number;
  41791. /**
  41792. * Define the roll off factor of spatial sounds.
  41793. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41794. */
  41795. rolloffFactor: number;
  41796. /**
  41797. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  41798. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41799. */
  41800. maxDistance: number;
  41801. /**
  41802. * Define the distance attenuation model the sound will follow.
  41803. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41804. */
  41805. distanceModel: string;
  41806. /**
  41807. * @hidden
  41808. * Back Compat
  41809. **/
  41810. onended: () => any;
  41811. /**
  41812. * Gets or sets an object used to store user defined information for the sound.
  41813. */
  41814. metadata: any;
  41815. /**
  41816. * Observable event when the current playing sound finishes.
  41817. */
  41818. onEndedObservable: Observable<Sound>;
  41819. private _panningModel;
  41820. private _playbackRate;
  41821. private _streaming;
  41822. private _startTime;
  41823. private _startOffset;
  41824. private _position;
  41825. /** @hidden */
  41826. _positionInEmitterSpace: boolean;
  41827. private _localDirection;
  41828. private _volume;
  41829. private _isReadyToPlay;
  41830. private _isDirectional;
  41831. private _readyToPlayCallback;
  41832. private _audioBuffer;
  41833. private _soundSource;
  41834. private _streamingSource;
  41835. private _soundPanner;
  41836. private _soundGain;
  41837. private _inputAudioNode;
  41838. private _outputAudioNode;
  41839. private _coneInnerAngle;
  41840. private _coneOuterAngle;
  41841. private _coneOuterGain;
  41842. private _scene;
  41843. private _connectedTransformNode;
  41844. private _customAttenuationFunction;
  41845. private _registerFunc;
  41846. private _isOutputConnected;
  41847. private _htmlAudioElement;
  41848. private _urlType;
  41849. private _length?;
  41850. private _offset?;
  41851. /** @hidden */
  41852. static _SceneComponentInitialization: (scene: Scene) => void;
  41853. /**
  41854. * Create a sound and attach it to a scene
  41855. * @param name Name of your sound
  41856. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  41857. * @param scene defines the scene the sound belongs to
  41858. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  41859. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  41860. */
  41861. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  41862. /**
  41863. * Release the sound and its associated resources
  41864. */
  41865. dispose(): void;
  41866. /**
  41867. * Gets if the sounds is ready to be played or not.
  41868. * @returns true if ready, otherwise false
  41869. */
  41870. isReady(): boolean;
  41871. private _soundLoaded;
  41872. /**
  41873. * Sets the data of the sound from an audiobuffer
  41874. * @param audioBuffer The audioBuffer containing the data
  41875. */
  41876. setAudioBuffer(audioBuffer: AudioBuffer): void;
  41877. /**
  41878. * Updates the current sounds options such as maxdistance, loop...
  41879. * @param options A JSON object containing values named as the object properties
  41880. */
  41881. updateOptions(options: ISoundOptions): void;
  41882. private _createSpatialParameters;
  41883. private _updateSpatialParameters;
  41884. /**
  41885. * Switch the panning model to HRTF:
  41886. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  41887. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41888. */
  41889. switchPanningModelToHRTF(): void;
  41890. /**
  41891. * Switch the panning model to Equal Power:
  41892. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  41893. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41894. */
  41895. switchPanningModelToEqualPower(): void;
  41896. private _switchPanningModel;
  41897. /**
  41898. * Connect this sound to a sound track audio node like gain...
  41899. * @param soundTrackAudioNode the sound track audio node to connect to
  41900. */
  41901. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  41902. /**
  41903. * Transform this sound into a directional source
  41904. * @param coneInnerAngle Size of the inner cone in degree
  41905. * @param coneOuterAngle Size of the outer cone in degree
  41906. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  41907. */
  41908. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  41909. /**
  41910. * Gets or sets the inner angle for the directional cone.
  41911. */
  41912. get directionalConeInnerAngle(): number;
  41913. /**
  41914. * Gets or sets the inner angle for the directional cone.
  41915. */
  41916. set directionalConeInnerAngle(value: number);
  41917. /**
  41918. * Gets or sets the outer angle for the directional cone.
  41919. */
  41920. get directionalConeOuterAngle(): number;
  41921. /**
  41922. * Gets or sets the outer angle for the directional cone.
  41923. */
  41924. set directionalConeOuterAngle(value: number);
  41925. /**
  41926. * Sets the position of the emitter if spatial sound is enabled
  41927. * @param newPosition Defines the new posisiton
  41928. */
  41929. setPosition(newPosition: Vector3): void;
  41930. /**
  41931. * Sets the local direction of the emitter if spatial sound is enabled
  41932. * @param newLocalDirection Defines the new local direction
  41933. */
  41934. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  41935. private _updateDirection;
  41936. /** @hidden */
  41937. updateDistanceFromListener(): void;
  41938. /**
  41939. * Sets a new custom attenuation function for the sound.
  41940. * @param callback Defines the function used for the attenuation
  41941. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41942. */
  41943. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  41944. /**
  41945. * Play the sound
  41946. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  41947. * @param offset (optional) Start the sound at a specific time in seconds
  41948. * @param length (optional) Sound duration (in seconds)
  41949. */
  41950. play(time?: number, offset?: number, length?: number): void;
  41951. private _onended;
  41952. /**
  41953. * Stop the sound
  41954. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  41955. */
  41956. stop(time?: number): void;
  41957. /**
  41958. * Put the sound in pause
  41959. */
  41960. pause(): void;
  41961. /**
  41962. * Sets a dedicated volume for this sounds
  41963. * @param newVolume Define the new volume of the sound
  41964. * @param time Define time for gradual change to new volume
  41965. */
  41966. setVolume(newVolume: number, time?: number): void;
  41967. /**
  41968. * Set the sound play back rate
  41969. * @param newPlaybackRate Define the playback rate the sound should be played at
  41970. */
  41971. setPlaybackRate(newPlaybackRate: number): void;
  41972. /**
  41973. * Gets the volume of the sound.
  41974. * @returns the volume of the sound
  41975. */
  41976. getVolume(): number;
  41977. /**
  41978. * Attach the sound to a dedicated mesh
  41979. * @param transformNode The transform node to connect the sound with
  41980. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41981. */
  41982. attachToMesh(transformNode: TransformNode): void;
  41983. /**
  41984. * Detach the sound from the previously attached mesh
  41985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  41986. */
  41987. detachFromMesh(): void;
  41988. private _onRegisterAfterWorldMatrixUpdate;
  41989. /**
  41990. * Clone the current sound in the scene.
  41991. * @returns the new sound clone
  41992. */
  41993. clone(): Nullable<Sound>;
  41994. /**
  41995. * Gets the current underlying audio buffer containing the data
  41996. * @returns the audio buffer
  41997. */
  41998. getAudioBuffer(): Nullable<AudioBuffer>;
  41999. /**
  42000. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42001. * @returns the source node
  42002. */
  42003. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42004. /**
  42005. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42006. * @returns the gain node
  42007. */
  42008. getSoundGain(): Nullable<GainNode>;
  42009. /**
  42010. * Serializes the Sound in a JSON representation
  42011. * @returns the JSON representation of the sound
  42012. */
  42013. serialize(): any;
  42014. /**
  42015. * Parse a JSON representation of a sound to innstantiate in a given scene
  42016. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42017. * @param scene Define the scene the new parsed sound should be created in
  42018. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42019. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42020. * @returns the newly parsed sound
  42021. */
  42022. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * This defines an action helpful to play a defined sound on a triggered action.
  42028. */
  42029. export class PlaySoundAction extends Action {
  42030. private _sound;
  42031. /**
  42032. * Instantiate the action
  42033. * @param triggerOptions defines the trigger options
  42034. * @param sound defines the sound to play
  42035. * @param condition defines the trigger related conditions
  42036. */
  42037. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42038. /** @hidden */
  42039. _prepare(): void;
  42040. /**
  42041. * Execute the action and play the sound.
  42042. */
  42043. execute(): void;
  42044. /**
  42045. * Serializes the actions and its related information.
  42046. * @param parent defines the object to serialize in
  42047. * @returns the serialized object
  42048. */
  42049. serialize(parent: any): any;
  42050. }
  42051. /**
  42052. * This defines an action helpful to stop a defined sound on a triggered action.
  42053. */
  42054. export class StopSoundAction extends Action {
  42055. private _sound;
  42056. /**
  42057. * Instantiate the action
  42058. * @param triggerOptions defines the trigger options
  42059. * @param sound defines the sound to stop
  42060. * @param condition defines the trigger related conditions
  42061. */
  42062. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42063. /** @hidden */
  42064. _prepare(): void;
  42065. /**
  42066. * Execute the action and stop the sound.
  42067. */
  42068. execute(): void;
  42069. /**
  42070. * Serializes the actions and its related information.
  42071. * @param parent defines the object to serialize in
  42072. * @returns the serialized object
  42073. */
  42074. serialize(parent: any): any;
  42075. }
  42076. }
  42077. declare module BABYLON {
  42078. /**
  42079. * This defines an action responsible to change the value of a property
  42080. * by interpolating between its current value and the newly set one once triggered.
  42081. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42082. */
  42083. export class InterpolateValueAction extends Action {
  42084. /**
  42085. * Defines the path of the property where the value should be interpolated
  42086. */
  42087. propertyPath: string;
  42088. /**
  42089. * Defines the target value at the end of the interpolation.
  42090. */
  42091. value: any;
  42092. /**
  42093. * Defines the time it will take for the property to interpolate to the value.
  42094. */
  42095. duration: number;
  42096. /**
  42097. * Defines if the other scene animations should be stopped when the action has been triggered
  42098. */
  42099. stopOtherAnimations?: boolean;
  42100. /**
  42101. * Defines a callback raised once the interpolation animation has been done.
  42102. */
  42103. onInterpolationDone?: () => void;
  42104. /**
  42105. * Observable triggered once the interpolation animation has been done.
  42106. */
  42107. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42108. private _target;
  42109. private _effectiveTarget;
  42110. private _property;
  42111. /**
  42112. * Instantiate the action
  42113. * @param triggerOptions defines the trigger options
  42114. * @param target defines the object containing the value to interpolate
  42115. * @param propertyPath defines the path to the property in the target object
  42116. * @param value defines the target value at the end of the interpolation
  42117. * @param duration deines the time it will take for the property to interpolate to the value.
  42118. * @param condition defines the trigger related conditions
  42119. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42120. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42121. */
  42122. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42123. /** @hidden */
  42124. _prepare(): void;
  42125. /**
  42126. * Execute the action starts the value interpolation.
  42127. */
  42128. execute(): void;
  42129. /**
  42130. * Serializes the actions and its related information.
  42131. * @param parent defines the object to serialize in
  42132. * @returns the serialized object
  42133. */
  42134. serialize(parent: any): any;
  42135. }
  42136. }
  42137. declare module BABYLON {
  42138. /**
  42139. * Options allowed during the creation of a sound track.
  42140. */
  42141. export interface ISoundTrackOptions {
  42142. /**
  42143. * The volume the sound track should take during creation
  42144. */
  42145. volume?: number;
  42146. /**
  42147. * Define if the sound track is the main sound track of the scene
  42148. */
  42149. mainTrack?: boolean;
  42150. }
  42151. /**
  42152. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42153. * It will be also used in a future release to apply effects on a specific track.
  42154. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42155. */
  42156. export class SoundTrack {
  42157. /**
  42158. * The unique identifier of the sound track in the scene.
  42159. */
  42160. id: number;
  42161. /**
  42162. * The list of sounds included in the sound track.
  42163. */
  42164. soundCollection: Array<Sound>;
  42165. private _outputAudioNode;
  42166. private _scene;
  42167. private _connectedAnalyser;
  42168. private _options;
  42169. private _isInitialized;
  42170. /**
  42171. * Creates a new sound track.
  42172. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42173. * @param scene Define the scene the sound track belongs to
  42174. * @param options
  42175. */
  42176. constructor(scene: Scene, options?: ISoundTrackOptions);
  42177. private _initializeSoundTrackAudioGraph;
  42178. /**
  42179. * Release the sound track and its associated resources
  42180. */
  42181. dispose(): void;
  42182. /**
  42183. * Adds a sound to this sound track
  42184. * @param sound define the cound to add
  42185. * @ignoreNaming
  42186. */
  42187. AddSound(sound: Sound): void;
  42188. /**
  42189. * Removes a sound to this sound track
  42190. * @param sound define the cound to remove
  42191. * @ignoreNaming
  42192. */
  42193. RemoveSound(sound: Sound): void;
  42194. /**
  42195. * Set a global volume for the full sound track.
  42196. * @param newVolume Define the new volume of the sound track
  42197. */
  42198. setVolume(newVolume: number): void;
  42199. /**
  42200. * Switch the panning model to HRTF:
  42201. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42202. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42203. */
  42204. switchPanningModelToHRTF(): void;
  42205. /**
  42206. * Switch the panning model to Equal Power:
  42207. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42209. */
  42210. switchPanningModelToEqualPower(): void;
  42211. /**
  42212. * Connect the sound track to an audio analyser allowing some amazing
  42213. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42215. * @param analyser The analyser to connect to the engine
  42216. */
  42217. connectToAnalyser(analyser: Analyser): void;
  42218. }
  42219. }
  42220. declare module BABYLON {
  42221. interface AbstractScene {
  42222. /**
  42223. * The list of sounds used in the scene.
  42224. */
  42225. sounds: Nullable<Array<Sound>>;
  42226. }
  42227. interface Scene {
  42228. /**
  42229. * @hidden
  42230. * Backing field
  42231. */
  42232. _mainSoundTrack: SoundTrack;
  42233. /**
  42234. * The main sound track played by the scene.
  42235. * It cotains your primary collection of sounds.
  42236. */
  42237. mainSoundTrack: SoundTrack;
  42238. /**
  42239. * The list of sound tracks added to the scene
  42240. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42241. */
  42242. soundTracks: Nullable<Array<SoundTrack>>;
  42243. /**
  42244. * Gets a sound using a given name
  42245. * @param name defines the name to search for
  42246. * @return the found sound or null if not found at all.
  42247. */
  42248. getSoundByName(name: string): Nullable<Sound>;
  42249. /**
  42250. * Gets or sets if audio support is enabled
  42251. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42252. */
  42253. audioEnabled: boolean;
  42254. /**
  42255. * Gets or sets if audio will be output to headphones
  42256. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42257. */
  42258. headphone: boolean;
  42259. /**
  42260. * Gets or sets custom audio listener position provider
  42261. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42262. */
  42263. audioListenerPositionProvider: Nullable<() => Vector3>;
  42264. /**
  42265. * Gets or sets a refresh rate when using 3D audio positioning
  42266. */
  42267. audioPositioningRefreshRate: number;
  42268. }
  42269. /**
  42270. * Defines the sound scene component responsible to manage any sounds
  42271. * in a given scene.
  42272. */
  42273. export class AudioSceneComponent implements ISceneSerializableComponent {
  42274. private static _CameraDirectionLH;
  42275. private static _CameraDirectionRH;
  42276. /**
  42277. * The component name helpfull to identify the component in the list of scene components.
  42278. */
  42279. readonly name: string;
  42280. /**
  42281. * The scene the component belongs to.
  42282. */
  42283. scene: Scene;
  42284. private _audioEnabled;
  42285. /**
  42286. * Gets whether audio is enabled or not.
  42287. * Please use related enable/disable method to switch state.
  42288. */
  42289. get audioEnabled(): boolean;
  42290. private _headphone;
  42291. /**
  42292. * Gets whether audio is outputing to headphone or not.
  42293. * Please use the according Switch methods to change output.
  42294. */
  42295. get headphone(): boolean;
  42296. /**
  42297. * Gets or sets a refresh rate when using 3D audio positioning
  42298. */
  42299. audioPositioningRefreshRate: number;
  42300. private _audioListenerPositionProvider;
  42301. /**
  42302. * Gets the current audio listener position provider
  42303. */
  42304. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42305. /**
  42306. * Sets a custom listener position for all sounds in the scene
  42307. * By default, this is the position of the first active camera
  42308. */
  42309. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42310. /**
  42311. * Creates a new instance of the component for the given scene
  42312. * @param scene Defines the scene to register the component in
  42313. */
  42314. constructor(scene: Scene);
  42315. /**
  42316. * Registers the component in a given scene
  42317. */
  42318. register(): void;
  42319. /**
  42320. * Rebuilds the elements related to this component in case of
  42321. * context lost for instance.
  42322. */
  42323. rebuild(): void;
  42324. /**
  42325. * Serializes the component data to the specified json object
  42326. * @param serializationObject The object to serialize to
  42327. */
  42328. serialize(serializationObject: any): void;
  42329. /**
  42330. * Adds all the elements from the container to the scene
  42331. * @param container the container holding the elements
  42332. */
  42333. addFromContainer(container: AbstractScene): void;
  42334. /**
  42335. * Removes all the elements in the container from the scene
  42336. * @param container contains the elements to remove
  42337. * @param dispose if the removed element should be disposed (default: false)
  42338. */
  42339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42340. /**
  42341. * Disposes the component and the associated ressources.
  42342. */
  42343. dispose(): void;
  42344. /**
  42345. * Disables audio in the associated scene.
  42346. */
  42347. disableAudio(): void;
  42348. /**
  42349. * Enables audio in the associated scene.
  42350. */
  42351. enableAudio(): void;
  42352. /**
  42353. * Switch audio to headphone output.
  42354. */
  42355. switchAudioModeForHeadphones(): void;
  42356. /**
  42357. * Switch audio to normal speakers.
  42358. */
  42359. switchAudioModeForNormalSpeakers(): void;
  42360. private _cachedCameraDirection;
  42361. private _cachedCameraPosition;
  42362. private _lastCheck;
  42363. private _afterRender;
  42364. }
  42365. }
  42366. declare module BABYLON {
  42367. /**
  42368. * Wraps one or more Sound objects and selects one with random weight for playback.
  42369. */
  42370. export class WeightedSound {
  42371. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42372. loop: boolean;
  42373. private _coneInnerAngle;
  42374. private _coneOuterAngle;
  42375. private _volume;
  42376. /** A Sound is currently playing. */
  42377. isPlaying: boolean;
  42378. /** A Sound is currently paused. */
  42379. isPaused: boolean;
  42380. private _sounds;
  42381. private _weights;
  42382. private _currentIndex?;
  42383. /**
  42384. * Creates a new WeightedSound from the list of sounds given.
  42385. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42386. * @param sounds Array of Sounds that will be selected from.
  42387. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42388. */
  42389. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42390. /**
  42391. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42392. */
  42393. get directionalConeInnerAngle(): number;
  42394. /**
  42395. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42396. */
  42397. set directionalConeInnerAngle(value: number);
  42398. /**
  42399. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42400. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42401. */
  42402. get directionalConeOuterAngle(): number;
  42403. /**
  42404. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42405. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42406. */
  42407. set directionalConeOuterAngle(value: number);
  42408. /**
  42409. * Playback volume.
  42410. */
  42411. get volume(): number;
  42412. /**
  42413. * Playback volume.
  42414. */
  42415. set volume(value: number);
  42416. private _onended;
  42417. /**
  42418. * Suspend playback
  42419. */
  42420. pause(): void;
  42421. /**
  42422. * Stop playback
  42423. */
  42424. stop(): void;
  42425. /**
  42426. * Start playback.
  42427. * @param startOffset Position the clip head at a specific time in seconds.
  42428. */
  42429. play(startOffset?: number): void;
  42430. }
  42431. }
  42432. declare module BABYLON {
  42433. /**
  42434. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42435. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42436. */
  42437. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42438. /**
  42439. * Gets the name of the behavior.
  42440. */
  42441. get name(): string;
  42442. /**
  42443. * The easing function used by animations
  42444. */
  42445. static EasingFunction: BackEase;
  42446. /**
  42447. * The easing mode used by animations
  42448. */
  42449. static EasingMode: number;
  42450. /**
  42451. * The duration of the animation, in milliseconds
  42452. */
  42453. transitionDuration: number;
  42454. /**
  42455. * Length of the distance animated by the transition when lower radius is reached
  42456. */
  42457. lowerRadiusTransitionRange: number;
  42458. /**
  42459. * Length of the distance animated by the transition when upper radius is reached
  42460. */
  42461. upperRadiusTransitionRange: number;
  42462. private _autoTransitionRange;
  42463. /**
  42464. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42465. */
  42466. get autoTransitionRange(): boolean;
  42467. /**
  42468. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42469. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42470. */
  42471. set autoTransitionRange(value: boolean);
  42472. private _attachedCamera;
  42473. private _onAfterCheckInputsObserver;
  42474. private _onMeshTargetChangedObserver;
  42475. /**
  42476. * Initializes the behavior.
  42477. */
  42478. init(): void;
  42479. /**
  42480. * Attaches the behavior to its arc rotate camera.
  42481. * @param camera Defines the camera to attach the behavior to
  42482. */
  42483. attach(camera: ArcRotateCamera): void;
  42484. /**
  42485. * Detaches the behavior from its current arc rotate camera.
  42486. */
  42487. detach(): void;
  42488. private _radiusIsAnimating;
  42489. private _radiusBounceTransition;
  42490. private _animatables;
  42491. private _cachedWheelPrecision;
  42492. /**
  42493. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42494. * @param radiusLimit The limit to check against.
  42495. * @return Bool to indicate if at limit.
  42496. */
  42497. private _isRadiusAtLimit;
  42498. /**
  42499. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42500. * @param radiusDelta The delta by which to animate to. Can be negative.
  42501. */
  42502. private _applyBoundRadiusAnimation;
  42503. /**
  42504. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42505. */
  42506. protected _clearAnimationLocks(): void;
  42507. /**
  42508. * Stops and removes all animations that have been applied to the camera
  42509. */
  42510. stopAllAnimations(): void;
  42511. }
  42512. }
  42513. declare module BABYLON {
  42514. /**
  42515. * 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.
  42516. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42517. */
  42518. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42519. /**
  42520. * Gets the name of the behavior.
  42521. */
  42522. get name(): string;
  42523. private _mode;
  42524. private _radiusScale;
  42525. private _positionScale;
  42526. private _defaultElevation;
  42527. private _elevationReturnTime;
  42528. private _elevationReturnWaitTime;
  42529. private _zoomStopsAnimation;
  42530. private _framingTime;
  42531. /**
  42532. * The easing function used by animations
  42533. */
  42534. static EasingFunction: ExponentialEase;
  42535. /**
  42536. * The easing mode used by animations
  42537. */
  42538. static EasingMode: number;
  42539. /**
  42540. * Sets the current mode used by the behavior
  42541. */
  42542. set mode(mode: number);
  42543. /**
  42544. * Gets current mode used by the behavior.
  42545. */
  42546. get mode(): number;
  42547. /**
  42548. * Sets the scale applied to the radius (1 by default)
  42549. */
  42550. set radiusScale(radius: number);
  42551. /**
  42552. * Gets the scale applied to the radius
  42553. */
  42554. get radiusScale(): number;
  42555. /**
  42556. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42557. */
  42558. set positionScale(scale: number);
  42559. /**
  42560. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42561. */
  42562. get positionScale(): number;
  42563. /**
  42564. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42565. * behaviour is triggered, in radians.
  42566. */
  42567. set defaultElevation(elevation: number);
  42568. /**
  42569. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42570. * behaviour is triggered, in radians.
  42571. */
  42572. get defaultElevation(): number;
  42573. /**
  42574. * Sets the time (in milliseconds) taken to return to the default beta position.
  42575. * Negative value indicates camera should not return to default.
  42576. */
  42577. set elevationReturnTime(speed: number);
  42578. /**
  42579. * Gets the time (in milliseconds) taken to return to the default beta position.
  42580. * Negative value indicates camera should not return to default.
  42581. */
  42582. get elevationReturnTime(): number;
  42583. /**
  42584. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42585. */
  42586. set elevationReturnWaitTime(time: number);
  42587. /**
  42588. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42589. */
  42590. get elevationReturnWaitTime(): number;
  42591. /**
  42592. * Sets the flag that indicates if user zooming should stop animation.
  42593. */
  42594. set zoomStopsAnimation(flag: boolean);
  42595. /**
  42596. * Gets the flag that indicates if user zooming should stop animation.
  42597. */
  42598. get zoomStopsAnimation(): boolean;
  42599. /**
  42600. * Sets the transition time when framing the mesh, in milliseconds
  42601. */
  42602. set framingTime(time: number);
  42603. /**
  42604. * Gets the transition time when framing the mesh, in milliseconds
  42605. */
  42606. get framingTime(): number;
  42607. /**
  42608. * Define if the behavior should automatically change the configured
  42609. * camera limits and sensibilities.
  42610. */
  42611. autoCorrectCameraLimitsAndSensibility: boolean;
  42612. private _onPrePointerObservableObserver;
  42613. private _onAfterCheckInputsObserver;
  42614. private _onMeshTargetChangedObserver;
  42615. private _attachedCamera;
  42616. private _isPointerDown;
  42617. private _lastInteractionTime;
  42618. /**
  42619. * Initializes the behavior.
  42620. */
  42621. init(): void;
  42622. /**
  42623. * Attaches the behavior to its arc rotate camera.
  42624. * @param camera Defines the camera to attach the behavior to
  42625. */
  42626. attach(camera: ArcRotateCamera): void;
  42627. /**
  42628. * Detaches the behavior from its current arc rotate camera.
  42629. */
  42630. detach(): void;
  42631. private _animatables;
  42632. private _betaIsAnimating;
  42633. private _betaTransition;
  42634. private _radiusTransition;
  42635. private _vectorTransition;
  42636. /**
  42637. * Targets the given mesh and updates zoom level accordingly.
  42638. * @param mesh The mesh to target.
  42639. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42640. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42641. */
  42642. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42643. /**
  42644. * Targets the given mesh with its children and updates zoom level accordingly.
  42645. * @param mesh The mesh to target.
  42646. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42647. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42648. */
  42649. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42650. /**
  42651. * Targets the given meshes with their children and updates zoom level accordingly.
  42652. * @param meshes The mesh to target.
  42653. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42654. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42655. */
  42656. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42657. /**
  42658. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42659. * @param minimumWorld Determines the smaller position of the bounding box extend
  42660. * @param maximumWorld Determines the bigger position of the bounding box extend
  42661. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42662. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42663. */
  42664. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42665. /**
  42666. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42667. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42668. * frustum width.
  42669. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42670. * to fully enclose the mesh in the viewing frustum.
  42671. */
  42672. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42673. /**
  42674. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42675. * is automatically returned to its default position (expected to be above ground plane).
  42676. */
  42677. private _maintainCameraAboveGround;
  42678. /**
  42679. * Returns the frustum slope based on the canvas ratio and camera FOV
  42680. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42681. */
  42682. private _getFrustumSlope;
  42683. /**
  42684. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42685. */
  42686. private _clearAnimationLocks;
  42687. /**
  42688. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42689. */
  42690. private _applyUserInteraction;
  42691. /**
  42692. * Stops and removes all animations that have been applied to the camera
  42693. */
  42694. stopAllAnimations(): void;
  42695. /**
  42696. * Gets a value indicating if the user is moving the camera
  42697. */
  42698. get isUserIsMoving(): boolean;
  42699. /**
  42700. * The camera can move all the way towards the mesh.
  42701. */
  42702. static IgnoreBoundsSizeMode: number;
  42703. /**
  42704. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42705. */
  42706. static FitFrustumSidesMode: number;
  42707. }
  42708. }
  42709. declare module BABYLON {
  42710. /**
  42711. * Base class for Camera Pointer Inputs.
  42712. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42713. * for example usage.
  42714. */
  42715. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42716. /**
  42717. * Defines the camera the input is attached to.
  42718. */
  42719. abstract camera: Camera;
  42720. /**
  42721. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42722. */
  42723. protected _altKey: boolean;
  42724. protected _ctrlKey: boolean;
  42725. protected _metaKey: boolean;
  42726. protected _shiftKey: boolean;
  42727. /**
  42728. * Which mouse buttons were pressed at time of last mouse event.
  42729. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  42730. */
  42731. protected _buttonsPressed: number;
  42732. /**
  42733. * Defines the buttons associated with the input to handle camera move.
  42734. */
  42735. buttons: number[];
  42736. /**
  42737. * Attach the input controls to a specific dom element to get the input from.
  42738. * @param element Defines the element the controls should be listened from
  42739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42740. */
  42741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42742. /**
  42743. * Detach the current controls from the specified dom element.
  42744. * @param element Defines the element to stop listening the inputs from
  42745. */
  42746. detachControl(element: Nullable<HTMLElement>): void;
  42747. /**
  42748. * Gets the class name of the current input.
  42749. * @returns the class name
  42750. */
  42751. getClassName(): string;
  42752. /**
  42753. * Get the friendly name associated with the input class.
  42754. * @returns the input friendly name
  42755. */
  42756. getSimpleName(): string;
  42757. /**
  42758. * Called on pointer POINTERDOUBLETAP event.
  42759. * Override this method to provide functionality on POINTERDOUBLETAP event.
  42760. */
  42761. protected onDoubleTap(type: string): void;
  42762. /**
  42763. * Called on pointer POINTERMOVE event if only a single touch is active.
  42764. * Override this method to provide functionality.
  42765. */
  42766. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42767. /**
  42768. * Called on pointer POINTERMOVE event if multiple touches are active.
  42769. * Override this method to provide functionality.
  42770. */
  42771. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42772. /**
  42773. * Called on JS contextmenu event.
  42774. * Override this method to provide functionality.
  42775. */
  42776. protected onContextMenu(evt: PointerEvent): void;
  42777. /**
  42778. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42779. * press.
  42780. * Override this method to provide functionality.
  42781. */
  42782. protected onButtonDown(evt: PointerEvent): void;
  42783. /**
  42784. * Called each time a new POINTERUP event occurs. Ie, for each button
  42785. * release.
  42786. * Override this method to provide functionality.
  42787. */
  42788. protected onButtonUp(evt: PointerEvent): void;
  42789. /**
  42790. * Called when window becomes inactive.
  42791. * Override this method to provide functionality.
  42792. */
  42793. protected onLostFocus(): void;
  42794. private _pointerInput;
  42795. private _observer;
  42796. private _onLostFocus;
  42797. private pointA;
  42798. private pointB;
  42799. }
  42800. }
  42801. declare module BABYLON {
  42802. /**
  42803. * Manage the pointers inputs to control an arc rotate camera.
  42804. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42805. */
  42806. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  42807. /**
  42808. * Defines the camera the input is attached to.
  42809. */
  42810. camera: ArcRotateCamera;
  42811. /**
  42812. * Gets the class name of the current input.
  42813. * @returns the class name
  42814. */
  42815. getClassName(): string;
  42816. /**
  42817. * Defines the buttons associated with the input to handle camera move.
  42818. */
  42819. buttons: number[];
  42820. /**
  42821. * Defines the pointer angular sensibility along the X axis or how fast is
  42822. * the camera rotating.
  42823. */
  42824. angularSensibilityX: number;
  42825. /**
  42826. * Defines the pointer angular sensibility along the Y axis or how fast is
  42827. * the camera rotating.
  42828. */
  42829. angularSensibilityY: number;
  42830. /**
  42831. * Defines the pointer pinch precision or how fast is the camera zooming.
  42832. */
  42833. pinchPrecision: number;
  42834. /**
  42835. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  42836. * from 0.
  42837. * It defines the percentage of current camera.radius to use as delta when
  42838. * pinch zoom is used.
  42839. */
  42840. pinchDeltaPercentage: number;
  42841. /**
  42842. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  42843. * that any object in the plane at the camera's target point will scale
  42844. * perfectly with finger motion.
  42845. * Overrides pinchDeltaPercentage and pinchPrecision.
  42846. */
  42847. useNaturalPinchZoom: boolean;
  42848. /**
  42849. * Defines the pointer panning sensibility or how fast is the camera moving.
  42850. */
  42851. panningSensibility: number;
  42852. /**
  42853. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  42854. */
  42855. multiTouchPanning: boolean;
  42856. /**
  42857. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  42858. * zoom (pinch) through multitouch.
  42859. */
  42860. multiTouchPanAndZoom: boolean;
  42861. /**
  42862. * Revers pinch action direction.
  42863. */
  42864. pinchInwards: boolean;
  42865. private _isPanClick;
  42866. private _twoFingerActivityCount;
  42867. private _isPinching;
  42868. /**
  42869. * Called on pointer POINTERMOVE event if only a single touch is active.
  42870. */
  42871. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  42872. /**
  42873. * Called on pointer POINTERDOUBLETAP event.
  42874. */
  42875. protected onDoubleTap(type: string): void;
  42876. /**
  42877. * Called on pointer POINTERMOVE event if multiple touches are active.
  42878. */
  42879. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  42880. /**
  42881. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  42882. * press.
  42883. */
  42884. protected onButtonDown(evt: PointerEvent): void;
  42885. /**
  42886. * Called each time a new POINTERUP event occurs. Ie, for each button
  42887. * release.
  42888. */
  42889. protected onButtonUp(evt: PointerEvent): void;
  42890. /**
  42891. * Called when window becomes inactive.
  42892. */
  42893. protected onLostFocus(): void;
  42894. }
  42895. }
  42896. declare module BABYLON {
  42897. /**
  42898. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  42899. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42900. */
  42901. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  42902. /**
  42903. * Defines the camera the input is attached to.
  42904. */
  42905. camera: ArcRotateCamera;
  42906. /**
  42907. * Defines the list of key codes associated with the up action (increase alpha)
  42908. */
  42909. keysUp: number[];
  42910. /**
  42911. * Defines the list of key codes associated with the down action (decrease alpha)
  42912. */
  42913. keysDown: number[];
  42914. /**
  42915. * Defines the list of key codes associated with the left action (increase beta)
  42916. */
  42917. keysLeft: number[];
  42918. /**
  42919. * Defines the list of key codes associated with the right action (decrease beta)
  42920. */
  42921. keysRight: number[];
  42922. /**
  42923. * Defines the list of key codes associated with the reset action.
  42924. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  42925. */
  42926. keysReset: number[];
  42927. /**
  42928. * Defines the panning sensibility of the inputs.
  42929. * (How fast is the camera panning)
  42930. */
  42931. panningSensibility: number;
  42932. /**
  42933. * Defines the zooming sensibility of the inputs.
  42934. * (How fast is the camera zooming)
  42935. */
  42936. zoomingSensibility: number;
  42937. /**
  42938. * Defines whether maintaining the alt key down switch the movement mode from
  42939. * orientation to zoom.
  42940. */
  42941. useAltToZoom: boolean;
  42942. /**
  42943. * Rotation speed of the camera
  42944. */
  42945. angularSpeed: number;
  42946. private _keys;
  42947. private _ctrlPressed;
  42948. private _altPressed;
  42949. private _onCanvasBlurObserver;
  42950. private _onKeyboardObserver;
  42951. private _engine;
  42952. private _scene;
  42953. /**
  42954. * Attach the input controls to a specific dom element to get the input from.
  42955. * @param element Defines the element the controls should be listened from
  42956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42957. */
  42958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42959. /**
  42960. * Detach the current controls from the specified dom element.
  42961. * @param element Defines the element to stop listening the inputs from
  42962. */
  42963. detachControl(element: Nullable<HTMLElement>): void;
  42964. /**
  42965. * Update the current camera state depending on the inputs that have been used this frame.
  42966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42967. */
  42968. checkInputs(): void;
  42969. /**
  42970. * Gets the class name of the current intput.
  42971. * @returns the class name
  42972. */
  42973. getClassName(): string;
  42974. /**
  42975. * Get the friendly name associated with the input class.
  42976. * @returns the input friendly name
  42977. */
  42978. getSimpleName(): string;
  42979. }
  42980. }
  42981. declare module BABYLON {
  42982. /**
  42983. * Manage the mouse wheel inputs to control an arc rotate camera.
  42984. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  42985. */
  42986. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  42987. /**
  42988. * Defines the camera the input is attached to.
  42989. */
  42990. camera: ArcRotateCamera;
  42991. /**
  42992. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  42993. */
  42994. wheelPrecision: number;
  42995. /**
  42996. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  42997. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  42998. */
  42999. wheelDeltaPercentage: number;
  43000. private _wheel;
  43001. private _observer;
  43002. private computeDeltaFromMouseWheelLegacyEvent;
  43003. /**
  43004. * Attach the input controls to a specific dom element to get the input from.
  43005. * @param element Defines the element the controls should be listened from
  43006. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43007. */
  43008. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43009. /**
  43010. * Detach the current controls from the specified dom element.
  43011. * @param element Defines the element to stop listening the inputs from
  43012. */
  43013. detachControl(element: Nullable<HTMLElement>): void;
  43014. /**
  43015. * Gets the class name of the current intput.
  43016. * @returns the class name
  43017. */
  43018. getClassName(): string;
  43019. /**
  43020. * Get the friendly name associated with the input class.
  43021. * @returns the input friendly name
  43022. */
  43023. getSimpleName(): string;
  43024. }
  43025. }
  43026. declare module BABYLON {
  43027. /**
  43028. * Default Inputs manager for the ArcRotateCamera.
  43029. * It groups all the default supported inputs for ease of use.
  43030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43031. */
  43032. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43033. /**
  43034. * Instantiates a new ArcRotateCameraInputsManager.
  43035. * @param camera Defines the camera the inputs belong to
  43036. */
  43037. constructor(camera: ArcRotateCamera);
  43038. /**
  43039. * Add mouse wheel input support to the input manager.
  43040. * @returns the current input manager
  43041. */
  43042. addMouseWheel(): ArcRotateCameraInputsManager;
  43043. /**
  43044. * Add pointers input support to the input manager.
  43045. * @returns the current input manager
  43046. */
  43047. addPointers(): ArcRotateCameraInputsManager;
  43048. /**
  43049. * Add keyboard input support to the input manager.
  43050. * @returns the current input manager
  43051. */
  43052. addKeyboard(): ArcRotateCameraInputsManager;
  43053. }
  43054. }
  43055. declare module BABYLON {
  43056. /**
  43057. * This represents an orbital type of camera.
  43058. *
  43059. * 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.
  43060. * 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.
  43061. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43062. */
  43063. export class ArcRotateCamera extends TargetCamera {
  43064. /**
  43065. * Defines the rotation angle of the camera along the longitudinal axis.
  43066. */
  43067. alpha: number;
  43068. /**
  43069. * Defines the rotation angle of the camera along the latitudinal axis.
  43070. */
  43071. beta: number;
  43072. /**
  43073. * Defines the radius of the camera from it s target point.
  43074. */
  43075. radius: number;
  43076. protected _target: Vector3;
  43077. protected _targetHost: Nullable<AbstractMesh>;
  43078. /**
  43079. * Defines the target point of the camera.
  43080. * The camera looks towards it form the radius distance.
  43081. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  43082. */
  43083. get target(): Vector3;
  43084. set target(value: Vector3);
  43085. /**
  43086. * Define the current local position of the camera in the scene
  43087. */
  43088. get position(): Vector3;
  43089. set position(newPosition: Vector3);
  43090. protected _upToYMatrix: Matrix;
  43091. protected _YToUpMatrix: Matrix;
  43092. /**
  43093. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43094. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43095. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43096. */
  43097. set upVector(vec: Vector3);
  43098. get upVector(): Vector3;
  43099. /**
  43100. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43101. */
  43102. setMatUp(): void;
  43103. /**
  43104. * Current inertia value on the longitudinal axis.
  43105. * The bigger this number the longer it will take for the camera to stop.
  43106. */
  43107. inertialAlphaOffset: number;
  43108. /**
  43109. * Current inertia value on the latitudinal axis.
  43110. * The bigger this number the longer it will take for the camera to stop.
  43111. */
  43112. inertialBetaOffset: number;
  43113. /**
  43114. * Current inertia value on the radius axis.
  43115. * The bigger this number the longer it will take for the camera to stop.
  43116. */
  43117. inertialRadiusOffset: number;
  43118. /**
  43119. * Minimum allowed angle on the longitudinal axis.
  43120. * This can help limiting how the Camera is able to move in the scene.
  43121. */
  43122. lowerAlphaLimit: Nullable<number>;
  43123. /**
  43124. * Maximum allowed angle on the longitudinal axis.
  43125. * This can help limiting how the Camera is able to move in the scene.
  43126. */
  43127. upperAlphaLimit: Nullable<number>;
  43128. /**
  43129. * Minimum allowed angle on the latitudinal axis.
  43130. * This can help limiting how the Camera is able to move in the scene.
  43131. */
  43132. lowerBetaLimit: number;
  43133. /**
  43134. * Maximum allowed angle on the latitudinal axis.
  43135. * This can help limiting how the Camera is able to move in the scene.
  43136. */
  43137. upperBetaLimit: number;
  43138. /**
  43139. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43140. * This can help limiting how the Camera is able to move in the scene.
  43141. */
  43142. lowerRadiusLimit: Nullable<number>;
  43143. /**
  43144. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43145. * This can help limiting how the Camera is able to move in the scene.
  43146. */
  43147. upperRadiusLimit: Nullable<number>;
  43148. /**
  43149. * Defines the current inertia value used during panning of the camera along the X axis.
  43150. */
  43151. inertialPanningX: number;
  43152. /**
  43153. * Defines the current inertia value used during panning of the camera along the Y axis.
  43154. */
  43155. inertialPanningY: number;
  43156. /**
  43157. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43158. * Basically if your fingers moves away from more than this distance you will be considered
  43159. * in pinch mode.
  43160. */
  43161. pinchToPanMaxDistance: number;
  43162. /**
  43163. * Defines the maximum distance the camera can pan.
  43164. * This could help keeping the cammera always in your scene.
  43165. */
  43166. panningDistanceLimit: Nullable<number>;
  43167. /**
  43168. * Defines the target of the camera before paning.
  43169. */
  43170. panningOriginTarget: Vector3;
  43171. /**
  43172. * Defines the value of the inertia used during panning.
  43173. * 0 would mean stop inertia and one would mean no decelleration at all.
  43174. */
  43175. panningInertia: number;
  43176. /**
  43177. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43178. */
  43179. get angularSensibilityX(): number;
  43180. set angularSensibilityX(value: number);
  43181. /**
  43182. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43183. */
  43184. get angularSensibilityY(): number;
  43185. set angularSensibilityY(value: number);
  43186. /**
  43187. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43188. */
  43189. get pinchPrecision(): number;
  43190. set pinchPrecision(value: number);
  43191. /**
  43192. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43193. * It will be used instead of pinchDeltaPrecision if different from 0.
  43194. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43195. */
  43196. get pinchDeltaPercentage(): number;
  43197. set pinchDeltaPercentage(value: number);
  43198. /**
  43199. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43200. * and pinch delta percentage.
  43201. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43202. * that any object in the plane at the camera's target point will scale
  43203. * perfectly with finger motion.
  43204. */
  43205. get useNaturalPinchZoom(): boolean;
  43206. set useNaturalPinchZoom(value: boolean);
  43207. /**
  43208. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43209. */
  43210. get panningSensibility(): number;
  43211. set panningSensibility(value: number);
  43212. /**
  43213. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43214. */
  43215. get keysUp(): number[];
  43216. set keysUp(value: number[]);
  43217. /**
  43218. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43219. */
  43220. get keysDown(): number[];
  43221. set keysDown(value: number[]);
  43222. /**
  43223. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43224. */
  43225. get keysLeft(): number[];
  43226. set keysLeft(value: number[]);
  43227. /**
  43228. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43229. */
  43230. get keysRight(): number[];
  43231. set keysRight(value: number[]);
  43232. /**
  43233. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43234. */
  43235. get wheelPrecision(): number;
  43236. set wheelPrecision(value: number);
  43237. /**
  43238. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43239. * It will be used instead of pinchDeltaPrecision if different from 0.
  43240. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43241. */
  43242. get wheelDeltaPercentage(): number;
  43243. set wheelDeltaPercentage(value: number);
  43244. /**
  43245. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43246. */
  43247. zoomOnFactor: number;
  43248. /**
  43249. * Defines a screen offset for the camera position.
  43250. */
  43251. targetScreenOffset: Vector2;
  43252. /**
  43253. * Allows the camera to be completely reversed.
  43254. * If false the camera can not arrive upside down.
  43255. */
  43256. allowUpsideDown: boolean;
  43257. /**
  43258. * Define if double tap/click is used to restore the previously saved state of the camera.
  43259. */
  43260. useInputToRestoreState: boolean;
  43261. /** @hidden */
  43262. _viewMatrix: Matrix;
  43263. /** @hidden */
  43264. _useCtrlForPanning: boolean;
  43265. /** @hidden */
  43266. _panningMouseButton: number;
  43267. /**
  43268. * Defines the input associated to the camera.
  43269. */
  43270. inputs: ArcRotateCameraInputsManager;
  43271. /** @hidden */
  43272. _reset: () => void;
  43273. /**
  43274. * Defines the allowed panning axis.
  43275. */
  43276. panningAxis: Vector3;
  43277. protected _localDirection: Vector3;
  43278. protected _transformedDirection: Vector3;
  43279. private _bouncingBehavior;
  43280. /**
  43281. * Gets the bouncing behavior of the camera if it has been enabled.
  43282. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43283. */
  43284. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43285. /**
  43286. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43287. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43288. */
  43289. get useBouncingBehavior(): boolean;
  43290. set useBouncingBehavior(value: boolean);
  43291. private _framingBehavior;
  43292. /**
  43293. * Gets the framing behavior of the camera if it has been enabled.
  43294. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43295. */
  43296. get framingBehavior(): Nullable<FramingBehavior>;
  43297. /**
  43298. * Defines if the framing behavior of the camera is enabled on the camera.
  43299. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43300. */
  43301. get useFramingBehavior(): boolean;
  43302. set useFramingBehavior(value: boolean);
  43303. private _autoRotationBehavior;
  43304. /**
  43305. * Gets the auto rotation behavior of the camera if it has been enabled.
  43306. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43307. */
  43308. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43309. /**
  43310. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43311. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43312. */
  43313. get useAutoRotationBehavior(): boolean;
  43314. set useAutoRotationBehavior(value: boolean);
  43315. /**
  43316. * Observable triggered when the mesh target has been changed on the camera.
  43317. */
  43318. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43319. /**
  43320. * Event raised when the camera is colliding with a mesh.
  43321. */
  43322. onCollide: (collidedMesh: AbstractMesh) => void;
  43323. /**
  43324. * Defines whether the camera should check collision with the objects oh the scene.
  43325. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43326. */
  43327. checkCollisions: boolean;
  43328. /**
  43329. * Defines the collision radius of the camera.
  43330. * This simulates a sphere around the camera.
  43331. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43332. */
  43333. collisionRadius: Vector3;
  43334. protected _collider: Collider;
  43335. protected _previousPosition: Vector3;
  43336. protected _collisionVelocity: Vector3;
  43337. protected _newPosition: Vector3;
  43338. protected _previousAlpha: number;
  43339. protected _previousBeta: number;
  43340. protected _previousRadius: number;
  43341. protected _collisionTriggered: boolean;
  43342. protected _targetBoundingCenter: Nullable<Vector3>;
  43343. private _computationVector;
  43344. /**
  43345. * Instantiates a new ArcRotateCamera in a given scene
  43346. * @param name Defines the name of the camera
  43347. * @param alpha Defines the camera rotation along the logitudinal axis
  43348. * @param beta Defines the camera rotation along the latitudinal axis
  43349. * @param radius Defines the camera distance from its target
  43350. * @param target Defines the camera target
  43351. * @param scene Defines the scene the camera belongs to
  43352. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43353. */
  43354. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43355. /** @hidden */
  43356. _initCache(): void;
  43357. /** @hidden */
  43358. _updateCache(ignoreParentClass?: boolean): void;
  43359. protected _getTargetPosition(): Vector3;
  43360. private _storedAlpha;
  43361. private _storedBeta;
  43362. private _storedRadius;
  43363. private _storedTarget;
  43364. private _storedTargetScreenOffset;
  43365. /**
  43366. * Stores the current state of the camera (alpha, beta, radius and target)
  43367. * @returns the camera itself
  43368. */
  43369. storeState(): Camera;
  43370. /**
  43371. * @hidden
  43372. * Restored camera state. You must call storeState() first
  43373. */
  43374. _restoreStateValues(): boolean;
  43375. /** @hidden */
  43376. _isSynchronizedViewMatrix(): boolean;
  43377. /**
  43378. * Attached controls to the current camera.
  43379. * @param element Defines the element the controls should be listened from
  43380. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43381. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43382. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43383. */
  43384. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43385. /**
  43386. * Detach the current controls from the camera.
  43387. * The camera will stop reacting to inputs.
  43388. * @param element Defines the element to stop listening the inputs from
  43389. */
  43390. detachControl(element: HTMLElement): void;
  43391. /** @hidden */
  43392. _checkInputs(): void;
  43393. protected _checkLimits(): void;
  43394. /**
  43395. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43396. */
  43397. rebuildAnglesAndRadius(): void;
  43398. /**
  43399. * Use a position to define the current camera related information like alpha, beta and radius
  43400. * @param position Defines the position to set the camera at
  43401. */
  43402. setPosition(position: Vector3): void;
  43403. /**
  43404. * Defines the target the camera should look at.
  43405. * This will automatically adapt alpha beta and radius to fit within the new target.
  43406. * @param target Defines the new target as a Vector or a mesh
  43407. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43408. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43409. */
  43410. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43411. /** @hidden */
  43412. _getViewMatrix(): Matrix;
  43413. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43414. /**
  43415. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43416. * @param meshes Defines the mesh to zoom on
  43417. * @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)
  43418. */
  43419. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43420. /**
  43421. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43422. * The target will be changed but the radius
  43423. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43424. * @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)
  43425. */
  43426. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43427. min: Vector3;
  43428. max: Vector3;
  43429. distance: number;
  43430. }, doNotUpdateMaxZ?: boolean): void;
  43431. /**
  43432. * @override
  43433. * Override Camera.createRigCamera
  43434. */
  43435. createRigCamera(name: string, cameraIndex: number): Camera;
  43436. /**
  43437. * @hidden
  43438. * @override
  43439. * Override Camera._updateRigCameras
  43440. */
  43441. _updateRigCameras(): void;
  43442. /**
  43443. * Destroy the camera and release the current resources hold by it.
  43444. */
  43445. dispose(): void;
  43446. /**
  43447. * Gets the current object class name.
  43448. * @return the class name
  43449. */
  43450. getClassName(): string;
  43451. }
  43452. }
  43453. declare module BABYLON {
  43454. /**
  43455. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43456. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43457. */
  43458. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43459. /**
  43460. * Gets the name of the behavior.
  43461. */
  43462. get name(): string;
  43463. private _zoomStopsAnimation;
  43464. private _idleRotationSpeed;
  43465. private _idleRotationWaitTime;
  43466. private _idleRotationSpinupTime;
  43467. /**
  43468. * Sets the flag that indicates if user zooming should stop animation.
  43469. */
  43470. set zoomStopsAnimation(flag: boolean);
  43471. /**
  43472. * Gets the flag that indicates if user zooming should stop animation.
  43473. */
  43474. get zoomStopsAnimation(): boolean;
  43475. /**
  43476. * Sets the default speed at which the camera rotates around the model.
  43477. */
  43478. set idleRotationSpeed(speed: number);
  43479. /**
  43480. * Gets the default speed at which the camera rotates around the model.
  43481. */
  43482. get idleRotationSpeed(): number;
  43483. /**
  43484. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43485. */
  43486. set idleRotationWaitTime(time: number);
  43487. /**
  43488. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43489. */
  43490. get idleRotationWaitTime(): number;
  43491. /**
  43492. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43493. */
  43494. set idleRotationSpinupTime(time: number);
  43495. /**
  43496. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43497. */
  43498. get idleRotationSpinupTime(): number;
  43499. /**
  43500. * Gets a value indicating if the camera is currently rotating because of this behavior
  43501. */
  43502. get rotationInProgress(): boolean;
  43503. private _onPrePointerObservableObserver;
  43504. private _onAfterCheckInputsObserver;
  43505. private _attachedCamera;
  43506. private _isPointerDown;
  43507. private _lastFrameTime;
  43508. private _lastInteractionTime;
  43509. private _cameraRotationSpeed;
  43510. /**
  43511. * Initializes the behavior.
  43512. */
  43513. init(): void;
  43514. /**
  43515. * Attaches the behavior to its arc rotate camera.
  43516. * @param camera Defines the camera to attach the behavior to
  43517. */
  43518. attach(camera: ArcRotateCamera): void;
  43519. /**
  43520. * Detaches the behavior from its current arc rotate camera.
  43521. */
  43522. detach(): void;
  43523. /**
  43524. * Returns true if user is scrolling.
  43525. * @return true if user is scrolling.
  43526. */
  43527. private _userIsZooming;
  43528. private _lastFrameRadius;
  43529. private _shouldAnimationStopForInteraction;
  43530. /**
  43531. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43532. */
  43533. private _applyUserInteraction;
  43534. private _userIsMoving;
  43535. }
  43536. }
  43537. declare module BABYLON {
  43538. /**
  43539. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43540. */
  43541. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43542. private ui;
  43543. /**
  43544. * The name of the behavior
  43545. */
  43546. name: string;
  43547. /**
  43548. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43549. */
  43550. distanceAwayFromFace: number;
  43551. /**
  43552. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43553. */
  43554. distanceAwayFromBottomOfFace: number;
  43555. private _faceVectors;
  43556. private _target;
  43557. private _scene;
  43558. private _onRenderObserver;
  43559. private _tmpMatrix;
  43560. private _tmpVector;
  43561. /**
  43562. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43563. * @param ui The transform node that should be attched to the mesh
  43564. */
  43565. constructor(ui: TransformNode);
  43566. /**
  43567. * Initializes the behavior
  43568. */
  43569. init(): void;
  43570. private _closestFace;
  43571. private _zeroVector;
  43572. private _lookAtTmpMatrix;
  43573. private _lookAtToRef;
  43574. /**
  43575. * Attaches the AttachToBoxBehavior to the passed in mesh
  43576. * @param target The mesh that the specified node will be attached to
  43577. */
  43578. attach(target: Mesh): void;
  43579. /**
  43580. * Detaches the behavior from the mesh
  43581. */
  43582. detach(): void;
  43583. }
  43584. }
  43585. declare module BABYLON {
  43586. /**
  43587. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43588. */
  43589. export class FadeInOutBehavior implements Behavior<Mesh> {
  43590. /**
  43591. * Time in milliseconds to delay before fading in (Default: 0)
  43592. */
  43593. delay: number;
  43594. /**
  43595. * Time in milliseconds for the mesh to fade in (Default: 300)
  43596. */
  43597. fadeInTime: number;
  43598. private _millisecondsPerFrame;
  43599. private _hovered;
  43600. private _hoverValue;
  43601. private _ownerNode;
  43602. /**
  43603. * Instatiates the FadeInOutBehavior
  43604. */
  43605. constructor();
  43606. /**
  43607. * The name of the behavior
  43608. */
  43609. get name(): string;
  43610. /**
  43611. * Initializes the behavior
  43612. */
  43613. init(): void;
  43614. /**
  43615. * Attaches the fade behavior on the passed in mesh
  43616. * @param ownerNode The mesh that will be faded in/out once attached
  43617. */
  43618. attach(ownerNode: Mesh): void;
  43619. /**
  43620. * Detaches the behavior from the mesh
  43621. */
  43622. detach(): void;
  43623. /**
  43624. * Triggers the mesh to begin fading in or out
  43625. * @param value if the object should fade in or out (true to fade in)
  43626. */
  43627. fadeIn(value: boolean): void;
  43628. private _update;
  43629. private _setAllVisibility;
  43630. }
  43631. }
  43632. declare module BABYLON {
  43633. /**
  43634. * Class containing a set of static utilities functions for managing Pivots
  43635. * @hidden
  43636. */
  43637. export class PivotTools {
  43638. private static _PivotCached;
  43639. private static _OldPivotPoint;
  43640. private static _PivotTranslation;
  43641. private static _PivotTmpVector;
  43642. private static _PivotPostMultiplyPivotMatrix;
  43643. /** @hidden */
  43644. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43645. /** @hidden */
  43646. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43647. }
  43648. }
  43649. declare module BABYLON {
  43650. /**
  43651. * Class containing static functions to help procedurally build meshes
  43652. */
  43653. export class PlaneBuilder {
  43654. /**
  43655. * Creates a plane mesh
  43656. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43657. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43658. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43659. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43660. * * 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
  43661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43662. * @param name defines the name of the mesh
  43663. * @param options defines the options used to create the mesh
  43664. * @param scene defines the hosting scene
  43665. * @returns the plane mesh
  43666. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43667. */
  43668. static CreatePlane(name: string, options: {
  43669. size?: number;
  43670. width?: number;
  43671. height?: number;
  43672. sideOrientation?: number;
  43673. frontUVs?: Vector4;
  43674. backUVs?: Vector4;
  43675. updatable?: boolean;
  43676. sourcePlane?: Plane;
  43677. }, scene?: Nullable<Scene>): Mesh;
  43678. }
  43679. }
  43680. declare module BABYLON {
  43681. /**
  43682. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  43683. */
  43684. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  43685. private static _AnyMouseID;
  43686. /**
  43687. * Abstract mesh the behavior is set on
  43688. */
  43689. attachedNode: AbstractMesh;
  43690. private _dragPlane;
  43691. private _scene;
  43692. private _pointerObserver;
  43693. private _beforeRenderObserver;
  43694. private static _planeScene;
  43695. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  43696. /**
  43697. * 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)
  43698. */
  43699. maxDragAngle: number;
  43700. /**
  43701. * @hidden
  43702. */
  43703. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  43704. /**
  43705. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43706. */
  43707. currentDraggingPointerID: number;
  43708. /**
  43709. * The last position where the pointer hit the drag plane in world space
  43710. */
  43711. lastDragPosition: Vector3;
  43712. /**
  43713. * If the behavior is currently in a dragging state
  43714. */
  43715. dragging: boolean;
  43716. /**
  43717. * 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)
  43718. */
  43719. dragDeltaRatio: number;
  43720. /**
  43721. * If the drag plane orientation should be updated during the dragging (Default: true)
  43722. */
  43723. updateDragPlane: boolean;
  43724. private _debugMode;
  43725. private _moving;
  43726. /**
  43727. * Fires each time the attached mesh is dragged with the pointer
  43728. * * delta between last drag position and current drag position in world space
  43729. * * dragDistance along the drag axis
  43730. * * dragPlaneNormal normal of the current drag plane used during the drag
  43731. * * dragPlanePoint in world space where the drag intersects the drag plane
  43732. */
  43733. onDragObservable: Observable<{
  43734. delta: Vector3;
  43735. dragPlanePoint: Vector3;
  43736. dragPlaneNormal: Vector3;
  43737. dragDistance: number;
  43738. pointerId: number;
  43739. }>;
  43740. /**
  43741. * Fires each time a drag begins (eg. mouse down on mesh)
  43742. */
  43743. onDragStartObservable: Observable<{
  43744. dragPlanePoint: Vector3;
  43745. pointerId: number;
  43746. }>;
  43747. /**
  43748. * Fires each time a drag ends (eg. mouse release after drag)
  43749. */
  43750. onDragEndObservable: Observable<{
  43751. dragPlanePoint: Vector3;
  43752. pointerId: number;
  43753. }>;
  43754. /**
  43755. * If the attached mesh should be moved when dragged
  43756. */
  43757. moveAttached: boolean;
  43758. /**
  43759. * If the drag behavior will react to drag events (Default: true)
  43760. */
  43761. enabled: boolean;
  43762. /**
  43763. * If pointer events should start and release the drag (Default: true)
  43764. */
  43765. startAndReleaseDragOnPointerEvents: boolean;
  43766. /**
  43767. * If camera controls should be detached during the drag
  43768. */
  43769. detachCameraControls: boolean;
  43770. /**
  43771. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  43772. */
  43773. useObjectOrientationForDragging: boolean;
  43774. private _options;
  43775. /**
  43776. * Gets the options used by the behavior
  43777. */
  43778. get options(): {
  43779. dragAxis?: Vector3;
  43780. dragPlaneNormal?: Vector3;
  43781. };
  43782. /**
  43783. * Sets the options used by the behavior
  43784. */
  43785. set options(options: {
  43786. dragAxis?: Vector3;
  43787. dragPlaneNormal?: Vector3;
  43788. });
  43789. /**
  43790. * Creates a pointer drag behavior that can be attached to a mesh
  43791. * @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)
  43792. */
  43793. constructor(options?: {
  43794. dragAxis?: Vector3;
  43795. dragPlaneNormal?: Vector3;
  43796. });
  43797. /**
  43798. * Predicate to determine if it is valid to move the object to a new position when it is moved
  43799. */
  43800. validateDrag: (targetPosition: Vector3) => boolean;
  43801. /**
  43802. * The name of the behavior
  43803. */
  43804. get name(): string;
  43805. /**
  43806. * Initializes the behavior
  43807. */
  43808. init(): void;
  43809. private _tmpVector;
  43810. private _alternatePickedPoint;
  43811. private _worldDragAxis;
  43812. private _targetPosition;
  43813. private _attachedElement;
  43814. /**
  43815. * Attaches the drag behavior the passed in mesh
  43816. * @param ownerNode The mesh that will be dragged around once attached
  43817. * @param predicate Predicate to use for pick filtering
  43818. */
  43819. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  43820. /**
  43821. * Force relase the drag action by code.
  43822. */
  43823. releaseDrag(): void;
  43824. private _startDragRay;
  43825. private _lastPointerRay;
  43826. /**
  43827. * Simulates the start of a pointer drag event on the behavior
  43828. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  43829. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  43830. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  43831. */
  43832. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43833. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  43834. private _dragDelta;
  43835. protected _moveDrag(ray: Ray): void;
  43836. private _pickWithRayOnDragPlane;
  43837. private _pointA;
  43838. private _pointC;
  43839. private _localAxis;
  43840. private _lookAt;
  43841. private _updateDragPlanePosition;
  43842. /**
  43843. * Detaches the behavior from the mesh
  43844. */
  43845. detach(): void;
  43846. }
  43847. }
  43848. declare module BABYLON {
  43849. /**
  43850. * A behavior that when attached to a mesh will allow the mesh to be scaled
  43851. */
  43852. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  43853. private _dragBehaviorA;
  43854. private _dragBehaviorB;
  43855. private _startDistance;
  43856. private _initialScale;
  43857. private _targetScale;
  43858. private _ownerNode;
  43859. private _sceneRenderObserver;
  43860. /**
  43861. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  43862. */
  43863. constructor();
  43864. /**
  43865. * The name of the behavior
  43866. */
  43867. get name(): string;
  43868. /**
  43869. * Initializes the behavior
  43870. */
  43871. init(): void;
  43872. private _getCurrentDistance;
  43873. /**
  43874. * Attaches the scale behavior the passed in mesh
  43875. * @param ownerNode The mesh that will be scaled around once attached
  43876. */
  43877. attach(ownerNode: Mesh): void;
  43878. /**
  43879. * Detaches the behavior from the mesh
  43880. */
  43881. detach(): void;
  43882. }
  43883. }
  43884. declare module BABYLON {
  43885. /**
  43886. * 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
  43887. */
  43888. export class SixDofDragBehavior implements Behavior<Mesh> {
  43889. private static _virtualScene;
  43890. private _ownerNode;
  43891. private _sceneRenderObserver;
  43892. private _scene;
  43893. private _targetPosition;
  43894. private _virtualOriginMesh;
  43895. private _virtualDragMesh;
  43896. private _pointerObserver;
  43897. private _moving;
  43898. private _startingOrientation;
  43899. private _attachedElement;
  43900. /**
  43901. * 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)
  43902. */
  43903. private zDragFactor;
  43904. /**
  43905. * If the object should rotate to face the drag origin
  43906. */
  43907. rotateDraggedObject: boolean;
  43908. /**
  43909. * If the behavior is currently in a dragging state
  43910. */
  43911. dragging: boolean;
  43912. /**
  43913. * 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)
  43914. */
  43915. dragDeltaRatio: number;
  43916. /**
  43917. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  43918. */
  43919. currentDraggingPointerID: number;
  43920. /**
  43921. * If camera controls should be detached during the drag
  43922. */
  43923. detachCameraControls: boolean;
  43924. /**
  43925. * Fires each time a drag starts
  43926. */
  43927. onDragStartObservable: Observable<{}>;
  43928. /**
  43929. * Fires each time a drag ends (eg. mouse release after drag)
  43930. */
  43931. onDragEndObservable: Observable<{}>;
  43932. /**
  43933. * 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
  43934. */
  43935. constructor();
  43936. /**
  43937. * The name of the behavior
  43938. */
  43939. get name(): string;
  43940. /**
  43941. * Initializes the behavior
  43942. */
  43943. init(): void;
  43944. /**
  43945. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  43946. */
  43947. private get _pointerCamera();
  43948. /**
  43949. * Attaches the scale behavior the passed in mesh
  43950. * @param ownerNode The mesh that will be scaled around once attached
  43951. */
  43952. attach(ownerNode: Mesh): void;
  43953. /**
  43954. * Detaches the behavior from the mesh
  43955. */
  43956. detach(): void;
  43957. }
  43958. }
  43959. declare module BABYLON {
  43960. /**
  43961. * Class used to apply inverse kinematics to bones
  43962. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  43963. */
  43964. export class BoneIKController {
  43965. private static _tmpVecs;
  43966. private static _tmpQuat;
  43967. private static _tmpMats;
  43968. /**
  43969. * Gets or sets the target mesh
  43970. */
  43971. targetMesh: AbstractMesh;
  43972. /** Gets or sets the mesh used as pole */
  43973. poleTargetMesh: AbstractMesh;
  43974. /**
  43975. * Gets or sets the bone used as pole
  43976. */
  43977. poleTargetBone: Nullable<Bone>;
  43978. /**
  43979. * Gets or sets the target position
  43980. */
  43981. targetPosition: Vector3;
  43982. /**
  43983. * Gets or sets the pole target position
  43984. */
  43985. poleTargetPosition: Vector3;
  43986. /**
  43987. * Gets or sets the pole target local offset
  43988. */
  43989. poleTargetLocalOffset: Vector3;
  43990. /**
  43991. * Gets or sets the pole angle
  43992. */
  43993. poleAngle: number;
  43994. /**
  43995. * Gets or sets the mesh associated with the controller
  43996. */
  43997. mesh: AbstractMesh;
  43998. /**
  43999. * 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)
  44000. */
  44001. slerpAmount: number;
  44002. private _bone1Quat;
  44003. private _bone1Mat;
  44004. private _bone2Ang;
  44005. private _bone1;
  44006. private _bone2;
  44007. private _bone1Length;
  44008. private _bone2Length;
  44009. private _maxAngle;
  44010. private _maxReach;
  44011. private _rightHandedSystem;
  44012. private _bendAxis;
  44013. private _slerping;
  44014. private _adjustRoll;
  44015. /**
  44016. * Gets or sets maximum allowed angle
  44017. */
  44018. get maxAngle(): number;
  44019. set maxAngle(value: number);
  44020. /**
  44021. * Creates a new BoneIKController
  44022. * @param mesh defines the mesh to control
  44023. * @param bone defines the bone to control
  44024. * @param options defines options to set up the controller
  44025. */
  44026. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44027. targetMesh?: AbstractMesh;
  44028. poleTargetMesh?: AbstractMesh;
  44029. poleTargetBone?: Bone;
  44030. poleTargetLocalOffset?: Vector3;
  44031. poleAngle?: number;
  44032. bendAxis?: Vector3;
  44033. maxAngle?: number;
  44034. slerpAmount?: number;
  44035. });
  44036. private _setMaxAngle;
  44037. /**
  44038. * Force the controller to update the bones
  44039. */
  44040. update(): void;
  44041. }
  44042. }
  44043. declare module BABYLON {
  44044. /**
  44045. * Class used to make a bone look toward a point in space
  44046. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44047. */
  44048. export class BoneLookController {
  44049. private static _tmpVecs;
  44050. private static _tmpQuat;
  44051. private static _tmpMats;
  44052. /**
  44053. * The target Vector3 that the bone will look at
  44054. */
  44055. target: Vector3;
  44056. /**
  44057. * The mesh that the bone is attached to
  44058. */
  44059. mesh: AbstractMesh;
  44060. /**
  44061. * The bone that will be looking to the target
  44062. */
  44063. bone: Bone;
  44064. /**
  44065. * The up axis of the coordinate system that is used when the bone is rotated
  44066. */
  44067. upAxis: Vector3;
  44068. /**
  44069. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44070. */
  44071. upAxisSpace: Space;
  44072. /**
  44073. * Used to make an adjustment to the yaw of the bone
  44074. */
  44075. adjustYaw: number;
  44076. /**
  44077. * Used to make an adjustment to the pitch of the bone
  44078. */
  44079. adjustPitch: number;
  44080. /**
  44081. * Used to make an adjustment to the roll of the bone
  44082. */
  44083. adjustRoll: number;
  44084. /**
  44085. * 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)
  44086. */
  44087. slerpAmount: number;
  44088. private _minYaw;
  44089. private _maxYaw;
  44090. private _minPitch;
  44091. private _maxPitch;
  44092. private _minYawSin;
  44093. private _minYawCos;
  44094. private _maxYawSin;
  44095. private _maxYawCos;
  44096. private _midYawConstraint;
  44097. private _minPitchTan;
  44098. private _maxPitchTan;
  44099. private _boneQuat;
  44100. private _slerping;
  44101. private _transformYawPitch;
  44102. private _transformYawPitchInv;
  44103. private _firstFrameSkipped;
  44104. private _yawRange;
  44105. private _fowardAxis;
  44106. /**
  44107. * Gets or sets the minimum yaw angle that the bone can look to
  44108. */
  44109. get minYaw(): number;
  44110. set minYaw(value: number);
  44111. /**
  44112. * Gets or sets the maximum yaw angle that the bone can look to
  44113. */
  44114. get maxYaw(): number;
  44115. set maxYaw(value: number);
  44116. /**
  44117. * Gets or sets the minimum pitch angle that the bone can look to
  44118. */
  44119. get minPitch(): number;
  44120. set minPitch(value: number);
  44121. /**
  44122. * Gets or sets the maximum pitch angle that the bone can look to
  44123. */
  44124. get maxPitch(): number;
  44125. set maxPitch(value: number);
  44126. /**
  44127. * Create a BoneLookController
  44128. * @param mesh the mesh that the bone belongs to
  44129. * @param bone the bone that will be looking to the target
  44130. * @param target the target Vector3 to look at
  44131. * @param options optional settings:
  44132. * * maxYaw: the maximum angle the bone will yaw to
  44133. * * minYaw: the minimum angle the bone will yaw to
  44134. * * maxPitch: the maximum angle the bone will pitch to
  44135. * * minPitch: the minimum angle the bone will yaw to
  44136. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44137. * * upAxis: the up axis of the coordinate system
  44138. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44139. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44140. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44141. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44142. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44143. * * adjustRoll: used to make an adjustment to the roll of the bone
  44144. **/
  44145. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44146. maxYaw?: number;
  44147. minYaw?: number;
  44148. maxPitch?: number;
  44149. minPitch?: number;
  44150. slerpAmount?: number;
  44151. upAxis?: Vector3;
  44152. upAxisSpace?: Space;
  44153. yawAxis?: Vector3;
  44154. pitchAxis?: Vector3;
  44155. adjustYaw?: number;
  44156. adjustPitch?: number;
  44157. adjustRoll?: number;
  44158. });
  44159. /**
  44160. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44161. */
  44162. update(): void;
  44163. private _getAngleDiff;
  44164. private _getAngleBetween;
  44165. private _isAngleBetween;
  44166. }
  44167. }
  44168. declare module BABYLON {
  44169. /**
  44170. * Manage the gamepad inputs to control an arc rotate camera.
  44171. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44172. */
  44173. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44174. /**
  44175. * Defines the camera the input is attached to.
  44176. */
  44177. camera: ArcRotateCamera;
  44178. /**
  44179. * Defines the gamepad the input is gathering event from.
  44180. */
  44181. gamepad: Nullable<Gamepad>;
  44182. /**
  44183. * Defines the gamepad rotation sensiblity.
  44184. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44185. */
  44186. gamepadRotationSensibility: number;
  44187. /**
  44188. * Defines the gamepad move sensiblity.
  44189. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44190. */
  44191. gamepadMoveSensibility: number;
  44192. private _yAxisScale;
  44193. /**
  44194. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44195. */
  44196. get invertYAxis(): boolean;
  44197. set invertYAxis(value: boolean);
  44198. private _onGamepadConnectedObserver;
  44199. private _onGamepadDisconnectedObserver;
  44200. /**
  44201. * Attach the input controls to a specific dom element to get the input from.
  44202. * @param element Defines the element the controls should be listened from
  44203. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44204. */
  44205. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44206. /**
  44207. * Detach the current controls from the specified dom element.
  44208. * @param element Defines the element to stop listening the inputs from
  44209. */
  44210. detachControl(element: Nullable<HTMLElement>): void;
  44211. /**
  44212. * Update the current camera state depending on the inputs that have been used this frame.
  44213. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44214. */
  44215. checkInputs(): void;
  44216. /**
  44217. * Gets the class name of the current intput.
  44218. * @returns the class name
  44219. */
  44220. getClassName(): string;
  44221. /**
  44222. * Get the friendly name associated with the input class.
  44223. * @returns the input friendly name
  44224. */
  44225. getSimpleName(): string;
  44226. }
  44227. }
  44228. declare module BABYLON {
  44229. interface ArcRotateCameraInputsManager {
  44230. /**
  44231. * Add orientation input support to the input manager.
  44232. * @returns the current input manager
  44233. */
  44234. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44235. }
  44236. /**
  44237. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44238. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44239. */
  44240. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44241. /**
  44242. * Defines the camera the input is attached to.
  44243. */
  44244. camera: ArcRotateCamera;
  44245. /**
  44246. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44247. */
  44248. alphaCorrection: number;
  44249. /**
  44250. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44251. */
  44252. gammaCorrection: number;
  44253. private _alpha;
  44254. private _gamma;
  44255. private _dirty;
  44256. private _deviceOrientationHandler;
  44257. /**
  44258. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44259. */
  44260. constructor();
  44261. /**
  44262. * Attach the input controls to a specific dom element to get the input from.
  44263. * @param element Defines the element the controls should be listened from
  44264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44265. */
  44266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44267. /** @hidden */
  44268. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44269. /**
  44270. * Update the current camera state depending on the inputs that have been used this frame.
  44271. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44272. */
  44273. checkInputs(): void;
  44274. /**
  44275. * Detach the current controls from the specified dom element.
  44276. * @param element Defines the element to stop listening the inputs from
  44277. */
  44278. detachControl(element: Nullable<HTMLElement>): void;
  44279. /**
  44280. * Gets the class name of the current intput.
  44281. * @returns the class name
  44282. */
  44283. getClassName(): string;
  44284. /**
  44285. * Get the friendly name associated with the input class.
  44286. * @returns the input friendly name
  44287. */
  44288. getSimpleName(): string;
  44289. }
  44290. }
  44291. declare module BABYLON {
  44292. /**
  44293. * Listen to mouse events to control the camera.
  44294. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44295. */
  44296. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44297. /**
  44298. * Defines the camera the input is attached to.
  44299. */
  44300. camera: FlyCamera;
  44301. /**
  44302. * Defines if touch is enabled. (Default is true.)
  44303. */
  44304. touchEnabled: boolean;
  44305. /**
  44306. * Defines the buttons associated with the input to handle camera rotation.
  44307. */
  44308. buttons: number[];
  44309. /**
  44310. * Assign buttons for Yaw control.
  44311. */
  44312. buttonsYaw: number[];
  44313. /**
  44314. * Assign buttons for Pitch control.
  44315. */
  44316. buttonsPitch: number[];
  44317. /**
  44318. * Assign buttons for Roll control.
  44319. */
  44320. buttonsRoll: number[];
  44321. /**
  44322. * Detect if any button is being pressed while mouse is moved.
  44323. * -1 = Mouse locked.
  44324. * 0 = Left button.
  44325. * 1 = Middle Button.
  44326. * 2 = Right Button.
  44327. */
  44328. activeButton: number;
  44329. /**
  44330. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44331. * Higher values reduce its sensitivity.
  44332. */
  44333. angularSensibility: number;
  44334. private _observer;
  44335. private _rollObserver;
  44336. private previousPosition;
  44337. private noPreventDefault;
  44338. private element;
  44339. /**
  44340. * Listen to mouse events to control the camera.
  44341. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44343. */
  44344. constructor(touchEnabled?: boolean);
  44345. /**
  44346. * Attach the mouse control to the HTML DOM element.
  44347. * @param element Defines the element that listens to the input events.
  44348. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44349. */
  44350. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44351. /**
  44352. * Detach the current controls from the specified dom element.
  44353. * @param element Defines the element to stop listening the inputs from
  44354. */
  44355. detachControl(element: Nullable<HTMLElement>): void;
  44356. /**
  44357. * Gets the class name of the current input.
  44358. * @returns the class name.
  44359. */
  44360. getClassName(): string;
  44361. /**
  44362. * Get the friendly name associated with the input class.
  44363. * @returns the input's friendly name.
  44364. */
  44365. getSimpleName(): string;
  44366. private _pointerInput;
  44367. private _onMouseMove;
  44368. /**
  44369. * Rotate camera by mouse offset.
  44370. */
  44371. private rotateCamera;
  44372. }
  44373. }
  44374. declare module BABYLON {
  44375. /**
  44376. * Default Inputs manager for the FlyCamera.
  44377. * It groups all the default supported inputs for ease of use.
  44378. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44379. */
  44380. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44381. /**
  44382. * Instantiates a new FlyCameraInputsManager.
  44383. * @param camera Defines the camera the inputs belong to.
  44384. */
  44385. constructor(camera: FlyCamera);
  44386. /**
  44387. * Add keyboard input support to the input manager.
  44388. * @returns the new FlyCameraKeyboardMoveInput().
  44389. */
  44390. addKeyboard(): FlyCameraInputsManager;
  44391. /**
  44392. * Add mouse input support to the input manager.
  44393. * @param touchEnabled Enable touch screen support.
  44394. * @returns the new FlyCameraMouseInput().
  44395. */
  44396. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44397. }
  44398. }
  44399. declare module BABYLON {
  44400. /**
  44401. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44402. * such as in a 3D Space Shooter or a Flight Simulator.
  44403. */
  44404. export class FlyCamera extends TargetCamera {
  44405. /**
  44406. * Define the collision ellipsoid of the camera.
  44407. * This is helpful for simulating a camera body, like a player's body.
  44408. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44409. */
  44410. ellipsoid: Vector3;
  44411. /**
  44412. * Define an offset for the position of the ellipsoid around the camera.
  44413. * This can be helpful if the camera is attached away from the player's body center,
  44414. * such as at its head.
  44415. */
  44416. ellipsoidOffset: Vector3;
  44417. /**
  44418. * Enable or disable collisions of the camera with the rest of the scene objects.
  44419. */
  44420. checkCollisions: boolean;
  44421. /**
  44422. * Enable or disable gravity on the camera.
  44423. */
  44424. applyGravity: boolean;
  44425. /**
  44426. * Define the current direction the camera is moving to.
  44427. */
  44428. cameraDirection: Vector3;
  44429. /**
  44430. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44431. * This overrides and empties cameraRotation.
  44432. */
  44433. rotationQuaternion: Quaternion;
  44434. /**
  44435. * Track Roll to maintain the wanted Rolling when looking around.
  44436. */
  44437. _trackRoll: number;
  44438. /**
  44439. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44440. */
  44441. rollCorrect: number;
  44442. /**
  44443. * Mimic a banked turn, Rolling the camera when Yawing.
  44444. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44445. */
  44446. bankedTurn: boolean;
  44447. /**
  44448. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44449. */
  44450. bankedTurnLimit: number;
  44451. /**
  44452. * Value of 0 disables the banked Roll.
  44453. * Value of 1 is equal to the Yaw angle in radians.
  44454. */
  44455. bankedTurnMultiplier: number;
  44456. /**
  44457. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44458. */
  44459. inputs: FlyCameraInputsManager;
  44460. /**
  44461. * Gets the input sensibility for mouse input.
  44462. * Higher values reduce sensitivity.
  44463. */
  44464. get angularSensibility(): number;
  44465. /**
  44466. * Sets the input sensibility for a mouse input.
  44467. * Higher values reduce sensitivity.
  44468. */
  44469. set angularSensibility(value: number);
  44470. /**
  44471. * Get the keys for camera movement forward.
  44472. */
  44473. get keysForward(): number[];
  44474. /**
  44475. * Set the keys for camera movement forward.
  44476. */
  44477. set keysForward(value: number[]);
  44478. /**
  44479. * Get the keys for camera movement backward.
  44480. */
  44481. get keysBackward(): number[];
  44482. set keysBackward(value: number[]);
  44483. /**
  44484. * Get the keys for camera movement up.
  44485. */
  44486. get keysUp(): number[];
  44487. /**
  44488. * Set the keys for camera movement up.
  44489. */
  44490. set keysUp(value: number[]);
  44491. /**
  44492. * Get the keys for camera movement down.
  44493. */
  44494. get keysDown(): number[];
  44495. /**
  44496. * Set the keys for camera movement down.
  44497. */
  44498. set keysDown(value: number[]);
  44499. /**
  44500. * Get the keys for camera movement left.
  44501. */
  44502. get keysLeft(): number[];
  44503. /**
  44504. * Set the keys for camera movement left.
  44505. */
  44506. set keysLeft(value: number[]);
  44507. /**
  44508. * Set the keys for camera movement right.
  44509. */
  44510. get keysRight(): number[];
  44511. /**
  44512. * Set the keys for camera movement right.
  44513. */
  44514. set keysRight(value: number[]);
  44515. /**
  44516. * Event raised when the camera collides with a mesh in the scene.
  44517. */
  44518. onCollide: (collidedMesh: AbstractMesh) => void;
  44519. private _collider;
  44520. private _needMoveForGravity;
  44521. private _oldPosition;
  44522. private _diffPosition;
  44523. private _newPosition;
  44524. /** @hidden */
  44525. _localDirection: Vector3;
  44526. /** @hidden */
  44527. _transformedDirection: Vector3;
  44528. /**
  44529. * Instantiates a FlyCamera.
  44530. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44531. * such as in a 3D Space Shooter or a Flight Simulator.
  44532. * @param name Define the name of the camera in the scene.
  44533. * @param position Define the starting position of the camera in the scene.
  44534. * @param scene Define the scene the camera belongs to.
  44535. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44536. */
  44537. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44538. /**
  44539. * Attach a control to the HTML DOM element.
  44540. * @param element Defines the element that listens to the input events.
  44541. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44542. */
  44543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44544. /**
  44545. * Detach a control from the HTML DOM element.
  44546. * The camera will stop reacting to that input.
  44547. * @param element Defines the element that listens to the input events.
  44548. */
  44549. detachControl(element: HTMLElement): void;
  44550. private _collisionMask;
  44551. /**
  44552. * Get the mask that the camera ignores in collision events.
  44553. */
  44554. get collisionMask(): number;
  44555. /**
  44556. * Set the mask that the camera ignores in collision events.
  44557. */
  44558. set collisionMask(mask: number);
  44559. /** @hidden */
  44560. _collideWithWorld(displacement: Vector3): void;
  44561. /** @hidden */
  44562. private _onCollisionPositionChange;
  44563. /** @hidden */
  44564. _checkInputs(): void;
  44565. /** @hidden */
  44566. _decideIfNeedsToMove(): boolean;
  44567. /** @hidden */
  44568. _updatePosition(): void;
  44569. /**
  44570. * Restore the Roll to its target value at the rate specified.
  44571. * @param rate - Higher means slower restoring.
  44572. * @hidden
  44573. */
  44574. restoreRoll(rate: number): void;
  44575. /**
  44576. * Destroy the camera and release the current resources held by it.
  44577. */
  44578. dispose(): void;
  44579. /**
  44580. * Get the current object class name.
  44581. * @returns the class name.
  44582. */
  44583. getClassName(): string;
  44584. }
  44585. }
  44586. declare module BABYLON {
  44587. /**
  44588. * Listen to keyboard events to control the camera.
  44589. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44590. */
  44591. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44592. /**
  44593. * Defines the camera the input is attached to.
  44594. */
  44595. camera: FlyCamera;
  44596. /**
  44597. * The list of keyboard keys used to control the forward move of the camera.
  44598. */
  44599. keysForward: number[];
  44600. /**
  44601. * The list of keyboard keys used to control the backward move of the camera.
  44602. */
  44603. keysBackward: number[];
  44604. /**
  44605. * The list of keyboard keys used to control the forward move of the camera.
  44606. */
  44607. keysUp: number[];
  44608. /**
  44609. * The list of keyboard keys used to control the backward move of the camera.
  44610. */
  44611. keysDown: number[];
  44612. /**
  44613. * The list of keyboard keys used to control the right strafe move of the camera.
  44614. */
  44615. keysRight: number[];
  44616. /**
  44617. * The list of keyboard keys used to control the left strafe move of the camera.
  44618. */
  44619. keysLeft: number[];
  44620. private _keys;
  44621. private _onCanvasBlurObserver;
  44622. private _onKeyboardObserver;
  44623. private _engine;
  44624. private _scene;
  44625. /**
  44626. * Attach the input controls to a specific dom element to get the input from.
  44627. * @param element Defines the element the controls should be listened from
  44628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44629. */
  44630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44631. /**
  44632. * Detach the current controls from the specified dom element.
  44633. * @param element Defines the element to stop listening the inputs from
  44634. */
  44635. detachControl(element: Nullable<HTMLElement>): void;
  44636. /**
  44637. * Gets the class name of the current intput.
  44638. * @returns the class name
  44639. */
  44640. getClassName(): string;
  44641. /** @hidden */
  44642. _onLostFocus(e: FocusEvent): void;
  44643. /**
  44644. * Get the friendly name associated with the input class.
  44645. * @returns the input friendly name
  44646. */
  44647. getSimpleName(): string;
  44648. /**
  44649. * Update the current camera state depending on the inputs that have been used this frame.
  44650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44651. */
  44652. checkInputs(): void;
  44653. }
  44654. }
  44655. declare module BABYLON {
  44656. /**
  44657. * Manage the mouse wheel inputs to control a follow camera.
  44658. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44659. */
  44660. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  44661. /**
  44662. * Defines the camera the input is attached to.
  44663. */
  44664. camera: FollowCamera;
  44665. /**
  44666. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  44667. */
  44668. axisControlRadius: boolean;
  44669. /**
  44670. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  44671. */
  44672. axisControlHeight: boolean;
  44673. /**
  44674. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  44675. */
  44676. axisControlRotation: boolean;
  44677. /**
  44678. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  44679. * relation to mouseWheel events.
  44680. */
  44681. wheelPrecision: number;
  44682. /**
  44683. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44684. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44685. */
  44686. wheelDeltaPercentage: number;
  44687. private _wheel;
  44688. private _observer;
  44689. /**
  44690. * Attach the input controls to a specific dom element to get the input from.
  44691. * @param element Defines the element the controls should be listened from
  44692. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44693. */
  44694. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44695. /**
  44696. * Detach the current controls from the specified dom element.
  44697. * @param element Defines the element to stop listening the inputs from
  44698. */
  44699. detachControl(element: Nullable<HTMLElement>): void;
  44700. /**
  44701. * Gets the class name of the current intput.
  44702. * @returns the class name
  44703. */
  44704. getClassName(): string;
  44705. /**
  44706. * Get the friendly name associated with the input class.
  44707. * @returns the input friendly name
  44708. */
  44709. getSimpleName(): string;
  44710. }
  44711. }
  44712. declare module BABYLON {
  44713. /**
  44714. * Manage the pointers inputs to control an follow camera.
  44715. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44716. */
  44717. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  44718. /**
  44719. * Defines the camera the input is attached to.
  44720. */
  44721. camera: FollowCamera;
  44722. /**
  44723. * Gets the class name of the current input.
  44724. * @returns the class name
  44725. */
  44726. getClassName(): string;
  44727. /**
  44728. * Defines the pointer angular sensibility along the X axis or how fast is
  44729. * the camera rotating.
  44730. * A negative number will reverse the axis direction.
  44731. */
  44732. angularSensibilityX: number;
  44733. /**
  44734. * Defines the pointer angular sensibility along the Y axis or how fast is
  44735. * the camera rotating.
  44736. * A negative number will reverse the axis direction.
  44737. */
  44738. angularSensibilityY: number;
  44739. /**
  44740. * Defines the pointer pinch precision or how fast is the camera zooming.
  44741. * A negative number will reverse the axis direction.
  44742. */
  44743. pinchPrecision: number;
  44744. /**
  44745. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44746. * from 0.
  44747. * It defines the percentage of current camera.radius to use as delta when
  44748. * pinch zoom is used.
  44749. */
  44750. pinchDeltaPercentage: number;
  44751. /**
  44752. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  44753. */
  44754. axisXControlRadius: boolean;
  44755. /**
  44756. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  44757. */
  44758. axisXControlHeight: boolean;
  44759. /**
  44760. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  44761. */
  44762. axisXControlRotation: boolean;
  44763. /**
  44764. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  44765. */
  44766. axisYControlRadius: boolean;
  44767. /**
  44768. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  44769. */
  44770. axisYControlHeight: boolean;
  44771. /**
  44772. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  44773. */
  44774. axisYControlRotation: boolean;
  44775. /**
  44776. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  44777. */
  44778. axisPinchControlRadius: boolean;
  44779. /**
  44780. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  44781. */
  44782. axisPinchControlHeight: boolean;
  44783. /**
  44784. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  44785. */
  44786. axisPinchControlRotation: boolean;
  44787. /**
  44788. * Log error messages if basic misconfiguration has occurred.
  44789. */
  44790. warningEnable: boolean;
  44791. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44792. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44793. private _warningCounter;
  44794. private _warning;
  44795. }
  44796. }
  44797. declare module BABYLON {
  44798. /**
  44799. * Default Inputs manager for the FollowCamera.
  44800. * It groups all the default supported inputs for ease of use.
  44801. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44802. */
  44803. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  44804. /**
  44805. * Instantiates a new FollowCameraInputsManager.
  44806. * @param camera Defines the camera the inputs belong to
  44807. */
  44808. constructor(camera: FollowCamera);
  44809. /**
  44810. * Add keyboard input support to the input manager.
  44811. * @returns the current input manager
  44812. */
  44813. addKeyboard(): FollowCameraInputsManager;
  44814. /**
  44815. * Add mouse wheel input support to the input manager.
  44816. * @returns the current input manager
  44817. */
  44818. addMouseWheel(): FollowCameraInputsManager;
  44819. /**
  44820. * Add pointers input support to the input manager.
  44821. * @returns the current input manager
  44822. */
  44823. addPointers(): FollowCameraInputsManager;
  44824. /**
  44825. * Add orientation input support to the input manager.
  44826. * @returns the current input manager
  44827. */
  44828. addVRDeviceOrientation(): FollowCameraInputsManager;
  44829. }
  44830. }
  44831. declare module BABYLON {
  44832. /**
  44833. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  44834. * an arc rotate version arcFollowCamera are available.
  44835. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44836. */
  44837. export class FollowCamera extends TargetCamera {
  44838. /**
  44839. * Distance the follow camera should follow an object at
  44840. */
  44841. radius: number;
  44842. /**
  44843. * Minimum allowed distance of the camera to the axis of rotation
  44844. * (The camera can not get closer).
  44845. * This can help limiting how the Camera is able to move in the scene.
  44846. */
  44847. lowerRadiusLimit: Nullable<number>;
  44848. /**
  44849. * Maximum allowed distance of the camera to the axis of rotation
  44850. * (The camera can not get further).
  44851. * This can help limiting how the Camera is able to move in the scene.
  44852. */
  44853. upperRadiusLimit: Nullable<number>;
  44854. /**
  44855. * Define a rotation offset between the camera and the object it follows
  44856. */
  44857. rotationOffset: number;
  44858. /**
  44859. * Minimum allowed angle to camera position relative to target object.
  44860. * This can help limiting how the Camera is able to move in the scene.
  44861. */
  44862. lowerRotationOffsetLimit: Nullable<number>;
  44863. /**
  44864. * Maximum allowed angle to camera position relative to target object.
  44865. * This can help limiting how the Camera is able to move in the scene.
  44866. */
  44867. upperRotationOffsetLimit: Nullable<number>;
  44868. /**
  44869. * Define a height offset between the camera and the object it follows.
  44870. * It can help following an object from the top (like a car chaing a plane)
  44871. */
  44872. heightOffset: number;
  44873. /**
  44874. * Minimum allowed height of camera position relative to target object.
  44875. * This can help limiting how the Camera is able to move in the scene.
  44876. */
  44877. lowerHeightOffsetLimit: Nullable<number>;
  44878. /**
  44879. * Maximum allowed height of camera position relative to target object.
  44880. * This can help limiting how the Camera is able to move in the scene.
  44881. */
  44882. upperHeightOffsetLimit: Nullable<number>;
  44883. /**
  44884. * Define how fast the camera can accelerate to follow it s target.
  44885. */
  44886. cameraAcceleration: number;
  44887. /**
  44888. * Define the speed limit of the camera following an object.
  44889. */
  44890. maxCameraSpeed: number;
  44891. /**
  44892. * Define the target of the camera.
  44893. */
  44894. lockedTarget: Nullable<AbstractMesh>;
  44895. /**
  44896. * Defines the input associated with the camera.
  44897. */
  44898. inputs: FollowCameraInputsManager;
  44899. /**
  44900. * Instantiates the follow camera.
  44901. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44902. * @param name Define the name of the camera in the scene
  44903. * @param position Define the position of the camera
  44904. * @param scene Define the scene the camera belong to
  44905. * @param lockedTarget Define the target of the camera
  44906. */
  44907. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  44908. private _follow;
  44909. /**
  44910. * Attached controls to the current camera.
  44911. * @param element Defines the element the controls should be listened from
  44912. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44913. */
  44914. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44915. /**
  44916. * Detach the current controls from the camera.
  44917. * The camera will stop reacting to inputs.
  44918. * @param element Defines the element to stop listening the inputs from
  44919. */
  44920. detachControl(element: HTMLElement): void;
  44921. /** @hidden */
  44922. _checkInputs(): void;
  44923. private _checkLimits;
  44924. /**
  44925. * Gets the camera class name.
  44926. * @returns the class name
  44927. */
  44928. getClassName(): string;
  44929. }
  44930. /**
  44931. * Arc Rotate version of the follow camera.
  44932. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  44933. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44934. */
  44935. export class ArcFollowCamera extends TargetCamera {
  44936. /** The longitudinal angle of the camera */
  44937. alpha: number;
  44938. /** The latitudinal angle of the camera */
  44939. beta: number;
  44940. /** The radius of the camera from its target */
  44941. radius: number;
  44942. private _cartesianCoordinates;
  44943. /** Define the camera target (the mesh it should follow) */
  44944. private _meshTarget;
  44945. /**
  44946. * Instantiates a new ArcFollowCamera
  44947. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  44948. * @param name Define the name of the camera
  44949. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  44950. * @param beta Define the rotation angle of the camera around the elevation axis
  44951. * @param radius Define the radius of the camera from its target point
  44952. * @param target Define the target of the camera
  44953. * @param scene Define the scene the camera belongs to
  44954. */
  44955. constructor(name: string,
  44956. /** The longitudinal angle of the camera */
  44957. alpha: number,
  44958. /** The latitudinal angle of the camera */
  44959. beta: number,
  44960. /** The radius of the camera from its target */
  44961. radius: number,
  44962. /** Define the camera target (the mesh it should follow) */
  44963. target: Nullable<AbstractMesh>, scene: Scene);
  44964. private _follow;
  44965. /** @hidden */
  44966. _checkInputs(): void;
  44967. /**
  44968. * Returns the class name of the object.
  44969. * It is mostly used internally for serialization purposes.
  44970. */
  44971. getClassName(): string;
  44972. }
  44973. }
  44974. declare module BABYLON {
  44975. /**
  44976. * Manage the keyboard inputs to control the movement of a follow camera.
  44977. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44978. */
  44979. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  44980. /**
  44981. * Defines the camera the input is attached to.
  44982. */
  44983. camera: FollowCamera;
  44984. /**
  44985. * Defines the list of key codes associated with the up action (increase heightOffset)
  44986. */
  44987. keysHeightOffsetIncr: number[];
  44988. /**
  44989. * Defines the list of key codes associated with the down action (decrease heightOffset)
  44990. */
  44991. keysHeightOffsetDecr: number[];
  44992. /**
  44993. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  44994. */
  44995. keysHeightOffsetModifierAlt: boolean;
  44996. /**
  44997. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  44998. */
  44999. keysHeightOffsetModifierCtrl: boolean;
  45000. /**
  45001. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45002. */
  45003. keysHeightOffsetModifierShift: boolean;
  45004. /**
  45005. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45006. */
  45007. keysRotationOffsetIncr: number[];
  45008. /**
  45009. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45010. */
  45011. keysRotationOffsetDecr: number[];
  45012. /**
  45013. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45014. */
  45015. keysRotationOffsetModifierAlt: boolean;
  45016. /**
  45017. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45018. */
  45019. keysRotationOffsetModifierCtrl: boolean;
  45020. /**
  45021. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45022. */
  45023. keysRotationOffsetModifierShift: boolean;
  45024. /**
  45025. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45026. */
  45027. keysRadiusIncr: number[];
  45028. /**
  45029. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45030. */
  45031. keysRadiusDecr: number[];
  45032. /**
  45033. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45034. */
  45035. keysRadiusModifierAlt: boolean;
  45036. /**
  45037. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45038. */
  45039. keysRadiusModifierCtrl: boolean;
  45040. /**
  45041. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45042. */
  45043. keysRadiusModifierShift: boolean;
  45044. /**
  45045. * Defines the rate of change of heightOffset.
  45046. */
  45047. heightSensibility: number;
  45048. /**
  45049. * Defines the rate of change of rotationOffset.
  45050. */
  45051. rotationSensibility: number;
  45052. /**
  45053. * Defines the rate of change of radius.
  45054. */
  45055. radiusSensibility: number;
  45056. private _keys;
  45057. private _ctrlPressed;
  45058. private _altPressed;
  45059. private _shiftPressed;
  45060. private _onCanvasBlurObserver;
  45061. private _onKeyboardObserver;
  45062. private _engine;
  45063. private _scene;
  45064. /**
  45065. * Attach the input controls to a specific dom element to get the input from.
  45066. * @param element Defines the element the controls should be listened from
  45067. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45068. */
  45069. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45070. /**
  45071. * Detach the current controls from the specified dom element.
  45072. * @param element Defines the element to stop listening the inputs from
  45073. */
  45074. detachControl(element: Nullable<HTMLElement>): void;
  45075. /**
  45076. * Update the current camera state depending on the inputs that have been used this frame.
  45077. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45078. */
  45079. checkInputs(): void;
  45080. /**
  45081. * Gets the class name of the current input.
  45082. * @returns the class name
  45083. */
  45084. getClassName(): string;
  45085. /**
  45086. * Get the friendly name associated with the input class.
  45087. * @returns the input friendly name
  45088. */
  45089. getSimpleName(): string;
  45090. /**
  45091. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45092. * allow modification of the heightOffset value.
  45093. */
  45094. private _modifierHeightOffset;
  45095. /**
  45096. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45097. * allow modification of the rotationOffset value.
  45098. */
  45099. private _modifierRotationOffset;
  45100. /**
  45101. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45102. * allow modification of the radius value.
  45103. */
  45104. private _modifierRadius;
  45105. }
  45106. }
  45107. declare module BABYLON {
  45108. interface FreeCameraInputsManager {
  45109. /**
  45110. * @hidden
  45111. */
  45112. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45113. /**
  45114. * Add orientation input support to the input manager.
  45115. * @returns the current input manager
  45116. */
  45117. addDeviceOrientation(): FreeCameraInputsManager;
  45118. }
  45119. /**
  45120. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45121. * Screen rotation is taken into account.
  45122. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45123. */
  45124. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45125. private _camera;
  45126. private _screenOrientationAngle;
  45127. private _constantTranform;
  45128. private _screenQuaternion;
  45129. private _alpha;
  45130. private _beta;
  45131. private _gamma;
  45132. /**
  45133. * Can be used to detect if a device orientation sensor is available on a device
  45134. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45135. * @returns a promise that will resolve on orientation change
  45136. */
  45137. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45138. /**
  45139. * @hidden
  45140. */
  45141. _onDeviceOrientationChangedObservable: Observable<void>;
  45142. /**
  45143. * Instantiates a new input
  45144. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45145. */
  45146. constructor();
  45147. /**
  45148. * Define the camera controlled by the input.
  45149. */
  45150. get camera(): FreeCamera;
  45151. set camera(camera: FreeCamera);
  45152. /**
  45153. * Attach the input controls to a specific dom element to get the input from.
  45154. * @param element Defines the element the controls should be listened from
  45155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45156. */
  45157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45158. private _orientationChanged;
  45159. private _deviceOrientation;
  45160. /**
  45161. * Detach the current controls from the specified dom element.
  45162. * @param element Defines the element to stop listening the inputs from
  45163. */
  45164. detachControl(element: Nullable<HTMLElement>): void;
  45165. /**
  45166. * Update the current camera state depending on the inputs that have been used this frame.
  45167. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45168. */
  45169. checkInputs(): void;
  45170. /**
  45171. * Gets the class name of the current intput.
  45172. * @returns the class name
  45173. */
  45174. getClassName(): string;
  45175. /**
  45176. * Get the friendly name associated with the input class.
  45177. * @returns the input friendly name
  45178. */
  45179. getSimpleName(): string;
  45180. }
  45181. }
  45182. declare module BABYLON {
  45183. /**
  45184. * Manage the gamepad inputs to control a free camera.
  45185. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45186. */
  45187. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45188. /**
  45189. * Define the camera the input is attached to.
  45190. */
  45191. camera: FreeCamera;
  45192. /**
  45193. * Define the Gamepad controlling the input
  45194. */
  45195. gamepad: Nullable<Gamepad>;
  45196. /**
  45197. * Defines the gamepad rotation sensiblity.
  45198. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45199. */
  45200. gamepadAngularSensibility: number;
  45201. /**
  45202. * Defines the gamepad move sensiblity.
  45203. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45204. */
  45205. gamepadMoveSensibility: number;
  45206. private _yAxisScale;
  45207. /**
  45208. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45209. */
  45210. get invertYAxis(): boolean;
  45211. set invertYAxis(value: boolean);
  45212. private _onGamepadConnectedObserver;
  45213. private _onGamepadDisconnectedObserver;
  45214. private _cameraTransform;
  45215. private _deltaTransform;
  45216. private _vector3;
  45217. private _vector2;
  45218. /**
  45219. * Attach the input controls to a specific dom element to get the input from.
  45220. * @param element Defines the element the controls should be listened from
  45221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45222. */
  45223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45224. /**
  45225. * Detach the current controls from the specified dom element.
  45226. * @param element Defines the element to stop listening the inputs from
  45227. */
  45228. detachControl(element: Nullable<HTMLElement>): void;
  45229. /**
  45230. * Update the current camera state depending on the inputs that have been used this frame.
  45231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45232. */
  45233. checkInputs(): void;
  45234. /**
  45235. * Gets the class name of the current intput.
  45236. * @returns the class name
  45237. */
  45238. getClassName(): string;
  45239. /**
  45240. * Get the friendly name associated with the input class.
  45241. * @returns the input friendly name
  45242. */
  45243. getSimpleName(): string;
  45244. }
  45245. }
  45246. declare module BABYLON {
  45247. /**
  45248. * Defines the potential axis of a Joystick
  45249. */
  45250. export enum JoystickAxis {
  45251. /** X axis */
  45252. X = 0,
  45253. /** Y axis */
  45254. Y = 1,
  45255. /** Z axis */
  45256. Z = 2
  45257. }
  45258. /**
  45259. * Represents the different customization options available
  45260. * for VirtualJoystick
  45261. */
  45262. interface VirtualJoystickCustomizations {
  45263. /**
  45264. * Size of the joystick's puck
  45265. */
  45266. puckSize: number;
  45267. /**
  45268. * Size of the joystick's container
  45269. */
  45270. containerSize: number;
  45271. /**
  45272. * Color of the joystick && puck
  45273. */
  45274. color: string;
  45275. /**
  45276. * Image URL for the joystick's puck
  45277. */
  45278. puckImage?: string;
  45279. /**
  45280. * Image URL for the joystick's container
  45281. */
  45282. containerImage?: string;
  45283. /**
  45284. * Defines the unmoving position of the joystick container
  45285. */
  45286. position?: {
  45287. x: number;
  45288. y: number;
  45289. };
  45290. /**
  45291. * Defines whether or not the joystick container is always visible
  45292. */
  45293. alwaysVisible: boolean;
  45294. /**
  45295. * Defines whether or not to limit the movement of the puck to the joystick's container
  45296. */
  45297. limitToContainer: boolean;
  45298. }
  45299. /**
  45300. * Class used to define virtual joystick (used in touch mode)
  45301. */
  45302. export class VirtualJoystick {
  45303. /**
  45304. * Gets or sets a boolean indicating that left and right values must be inverted
  45305. */
  45306. reverseLeftRight: boolean;
  45307. /**
  45308. * Gets or sets a boolean indicating that up and down values must be inverted
  45309. */
  45310. reverseUpDown: boolean;
  45311. /**
  45312. * Gets the offset value for the position (ie. the change of the position value)
  45313. */
  45314. deltaPosition: Vector3;
  45315. /**
  45316. * Gets a boolean indicating if the virtual joystick was pressed
  45317. */
  45318. pressed: boolean;
  45319. /**
  45320. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45321. */
  45322. static Canvas: Nullable<HTMLCanvasElement>;
  45323. /**
  45324. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45325. */
  45326. limitToContainer: boolean;
  45327. private static _globalJoystickIndex;
  45328. private static _alwaysVisibleSticks;
  45329. private static vjCanvasContext;
  45330. private static vjCanvasWidth;
  45331. private static vjCanvasHeight;
  45332. private static halfWidth;
  45333. private static _GetDefaultOptions;
  45334. private _action;
  45335. private _axisTargetedByLeftAndRight;
  45336. private _axisTargetedByUpAndDown;
  45337. private _joystickSensibility;
  45338. private _inversedSensibility;
  45339. private _joystickPointerID;
  45340. private _joystickColor;
  45341. private _joystickPointerPos;
  45342. private _joystickPreviousPointerPos;
  45343. private _joystickPointerStartPos;
  45344. private _deltaJoystickVector;
  45345. private _leftJoystick;
  45346. private _touches;
  45347. private _joystickPosition;
  45348. private _alwaysVisible;
  45349. private _puckImage;
  45350. private _containerImage;
  45351. private _joystickPuckSize;
  45352. private _joystickContainerSize;
  45353. private _clearPuckSize;
  45354. private _clearContainerSize;
  45355. private _clearPuckSizeOffset;
  45356. private _clearContainerSizeOffset;
  45357. private _onPointerDownHandlerRef;
  45358. private _onPointerMoveHandlerRef;
  45359. private _onPointerUpHandlerRef;
  45360. private _onResize;
  45361. /**
  45362. * Creates a new virtual joystick
  45363. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45364. * @param customizations Defines the options we want to customize the VirtualJoystick
  45365. */
  45366. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45367. /**
  45368. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45369. * @param newJoystickSensibility defines the new sensibility
  45370. */
  45371. setJoystickSensibility(newJoystickSensibility: number): void;
  45372. private _onPointerDown;
  45373. private _onPointerMove;
  45374. private _onPointerUp;
  45375. /**
  45376. * Change the color of the virtual joystick
  45377. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45378. */
  45379. setJoystickColor(newColor: string): void;
  45380. /**
  45381. * Size of the joystick's container
  45382. */
  45383. set containerSize(newSize: number);
  45384. get containerSize(): number;
  45385. /**
  45386. * Size of the joystick's puck
  45387. */
  45388. set puckSize(newSize: number);
  45389. get puckSize(): number;
  45390. /**
  45391. * Clears the set position of the joystick
  45392. */
  45393. clearPosition(): void;
  45394. /**
  45395. * Defines whether or not the joystick container is always visible
  45396. */
  45397. set alwaysVisible(value: boolean);
  45398. get alwaysVisible(): boolean;
  45399. /**
  45400. * Sets the constant position of the Joystick container
  45401. * @param x X axis coordinate
  45402. * @param y Y axis coordinate
  45403. */
  45404. setPosition(x: number, y: number): void;
  45405. /**
  45406. * Defines a callback to call when the joystick is touched
  45407. * @param action defines the callback
  45408. */
  45409. setActionOnTouch(action: () => any): void;
  45410. /**
  45411. * Defines which axis you'd like to control for left & right
  45412. * @param axis defines the axis to use
  45413. */
  45414. setAxisForLeftRight(axis: JoystickAxis): void;
  45415. /**
  45416. * Defines which axis you'd like to control for up & down
  45417. * @param axis defines the axis to use
  45418. */
  45419. setAxisForUpDown(axis: JoystickAxis): void;
  45420. /**
  45421. * Clears the canvas from the previous puck / container draw
  45422. */
  45423. private _clearPreviousDraw;
  45424. /**
  45425. * Loads `urlPath` to be used for the container's image
  45426. * @param urlPath defines the urlPath of an image to use
  45427. */
  45428. setContainerImage(urlPath: string): void;
  45429. /**
  45430. * Loads `urlPath` to be used for the puck's image
  45431. * @param urlPath defines the urlPath of an image to use
  45432. */
  45433. setPuckImage(urlPath: string): void;
  45434. /**
  45435. * Draws the Virtual Joystick's container
  45436. */
  45437. private _drawContainer;
  45438. /**
  45439. * Draws the Virtual Joystick's puck
  45440. */
  45441. private _drawPuck;
  45442. private _drawVirtualJoystick;
  45443. /**
  45444. * Release internal HTML canvas
  45445. */
  45446. releaseCanvas(): void;
  45447. }
  45448. }
  45449. declare module BABYLON {
  45450. interface FreeCameraInputsManager {
  45451. /**
  45452. * Add virtual joystick input support to the input manager.
  45453. * @returns the current input manager
  45454. */
  45455. addVirtualJoystick(): FreeCameraInputsManager;
  45456. }
  45457. /**
  45458. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45459. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45460. */
  45461. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45462. /**
  45463. * Defines the camera the input is attached to.
  45464. */
  45465. camera: FreeCamera;
  45466. private _leftjoystick;
  45467. private _rightjoystick;
  45468. /**
  45469. * Gets the left stick of the virtual joystick.
  45470. * @returns The virtual Joystick
  45471. */
  45472. getLeftJoystick(): VirtualJoystick;
  45473. /**
  45474. * Gets the right stick of the virtual joystick.
  45475. * @returns The virtual Joystick
  45476. */
  45477. getRightJoystick(): VirtualJoystick;
  45478. /**
  45479. * Update the current camera state depending on the inputs that have been used this frame.
  45480. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45481. */
  45482. checkInputs(): void;
  45483. /**
  45484. * Attach the input controls to a specific dom element to get the input from.
  45485. * @param element Defines the element the controls should be listened from
  45486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45487. */
  45488. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45489. /**
  45490. * Detach the current controls from the specified dom element.
  45491. * @param element Defines the element to stop listening the inputs from
  45492. */
  45493. detachControl(element: Nullable<HTMLElement>): void;
  45494. /**
  45495. * Gets the class name of the current intput.
  45496. * @returns the class name
  45497. */
  45498. getClassName(): string;
  45499. /**
  45500. * Get the friendly name associated with the input class.
  45501. * @returns the input friendly name
  45502. */
  45503. getSimpleName(): string;
  45504. }
  45505. }
  45506. declare module BABYLON {
  45507. /**
  45508. * This represents a FPS type of camera controlled by touch.
  45509. * This is like a universal camera minus the Gamepad controls.
  45510. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45511. */
  45512. export class TouchCamera extends FreeCamera {
  45513. /**
  45514. * Defines the touch sensibility for rotation.
  45515. * The higher the faster.
  45516. */
  45517. get touchAngularSensibility(): number;
  45518. set touchAngularSensibility(value: number);
  45519. /**
  45520. * Defines the touch sensibility for move.
  45521. * The higher the faster.
  45522. */
  45523. get touchMoveSensibility(): number;
  45524. set touchMoveSensibility(value: number);
  45525. /**
  45526. * Instantiates a new touch camera.
  45527. * This represents a FPS type of camera controlled by touch.
  45528. * This is like a universal camera minus the Gamepad controls.
  45529. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45530. * @param name Define the name of the camera in the scene
  45531. * @param position Define the start position of the camera in the scene
  45532. * @param scene Define the scene the camera belongs to
  45533. */
  45534. constructor(name: string, position: Vector3, scene: Scene);
  45535. /**
  45536. * Gets the current object class name.
  45537. * @return the class name
  45538. */
  45539. getClassName(): string;
  45540. /** @hidden */
  45541. _setupInputs(): void;
  45542. }
  45543. }
  45544. declare module BABYLON {
  45545. /**
  45546. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45547. * being tilted forward or back and left or right.
  45548. */
  45549. export class DeviceOrientationCamera extends FreeCamera {
  45550. private _initialQuaternion;
  45551. private _quaternionCache;
  45552. private _tmpDragQuaternion;
  45553. private _disablePointerInputWhenUsingDeviceOrientation;
  45554. /**
  45555. * Creates a new device orientation camera
  45556. * @param name The name of the camera
  45557. * @param position The start position camera
  45558. * @param scene The scene the camera belongs to
  45559. */
  45560. constructor(name: string, position: Vector3, scene: Scene);
  45561. /**
  45562. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  45563. */
  45564. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  45565. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  45566. private _dragFactor;
  45567. /**
  45568. * Enabled turning on the y axis when the orientation sensor is active
  45569. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  45570. */
  45571. enableHorizontalDragging(dragFactor?: number): void;
  45572. /**
  45573. * Gets the current instance class name ("DeviceOrientationCamera").
  45574. * This helps avoiding instanceof at run time.
  45575. * @returns the class name
  45576. */
  45577. getClassName(): string;
  45578. /**
  45579. * @hidden
  45580. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  45581. */
  45582. _checkInputs(): void;
  45583. /**
  45584. * Reset the camera to its default orientation on the specified axis only.
  45585. * @param axis The axis to reset
  45586. */
  45587. resetToCurrentRotation(axis?: Axis): void;
  45588. }
  45589. }
  45590. declare module BABYLON {
  45591. /**
  45592. * Defines supported buttons for XBox360 compatible gamepads
  45593. */
  45594. export enum Xbox360Button {
  45595. /** A */
  45596. A = 0,
  45597. /** B */
  45598. B = 1,
  45599. /** X */
  45600. X = 2,
  45601. /** Y */
  45602. Y = 3,
  45603. /** Left button */
  45604. LB = 4,
  45605. /** Right button */
  45606. RB = 5,
  45607. /** Back */
  45608. Back = 8,
  45609. /** Start */
  45610. Start = 9,
  45611. /** Left stick */
  45612. LeftStick = 10,
  45613. /** Right stick */
  45614. RightStick = 11
  45615. }
  45616. /** Defines values for XBox360 DPad */
  45617. export enum Xbox360Dpad {
  45618. /** Up */
  45619. Up = 12,
  45620. /** Down */
  45621. Down = 13,
  45622. /** Left */
  45623. Left = 14,
  45624. /** Right */
  45625. Right = 15
  45626. }
  45627. /**
  45628. * Defines a XBox360 gamepad
  45629. */
  45630. export class Xbox360Pad extends Gamepad {
  45631. private _leftTrigger;
  45632. private _rightTrigger;
  45633. private _onlefttriggerchanged;
  45634. private _onrighttriggerchanged;
  45635. private _onbuttondown;
  45636. private _onbuttonup;
  45637. private _ondpaddown;
  45638. private _ondpadup;
  45639. /** Observable raised when a button is pressed */
  45640. onButtonDownObservable: Observable<Xbox360Button>;
  45641. /** Observable raised when a button is released */
  45642. onButtonUpObservable: Observable<Xbox360Button>;
  45643. /** Observable raised when a pad is pressed */
  45644. onPadDownObservable: Observable<Xbox360Dpad>;
  45645. /** Observable raised when a pad is released */
  45646. onPadUpObservable: Observable<Xbox360Dpad>;
  45647. private _buttonA;
  45648. private _buttonB;
  45649. private _buttonX;
  45650. private _buttonY;
  45651. private _buttonBack;
  45652. private _buttonStart;
  45653. private _buttonLB;
  45654. private _buttonRB;
  45655. private _buttonLeftStick;
  45656. private _buttonRightStick;
  45657. private _dPadUp;
  45658. private _dPadDown;
  45659. private _dPadLeft;
  45660. private _dPadRight;
  45661. private _isXboxOnePad;
  45662. /**
  45663. * Creates a new XBox360 gamepad object
  45664. * @param id defines the id of this gamepad
  45665. * @param index defines its index
  45666. * @param gamepad defines the internal HTML gamepad object
  45667. * @param xboxOne defines if it is a XBox One gamepad
  45668. */
  45669. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  45670. /**
  45671. * Defines the callback to call when left trigger is pressed
  45672. * @param callback defines the callback to use
  45673. */
  45674. onlefttriggerchanged(callback: (value: number) => void): void;
  45675. /**
  45676. * Defines the callback to call when right trigger is pressed
  45677. * @param callback defines the callback to use
  45678. */
  45679. onrighttriggerchanged(callback: (value: number) => void): void;
  45680. /**
  45681. * Gets the left trigger value
  45682. */
  45683. get leftTrigger(): number;
  45684. /**
  45685. * Sets the left trigger value
  45686. */
  45687. set leftTrigger(newValue: number);
  45688. /**
  45689. * Gets the right trigger value
  45690. */
  45691. get rightTrigger(): number;
  45692. /**
  45693. * Sets the right trigger value
  45694. */
  45695. set rightTrigger(newValue: number);
  45696. /**
  45697. * Defines the callback to call when a button is pressed
  45698. * @param callback defines the callback to use
  45699. */
  45700. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  45701. /**
  45702. * Defines the callback to call when a button is released
  45703. * @param callback defines the callback to use
  45704. */
  45705. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  45706. /**
  45707. * Defines the callback to call when a pad is pressed
  45708. * @param callback defines the callback to use
  45709. */
  45710. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  45711. /**
  45712. * Defines the callback to call when a pad is released
  45713. * @param callback defines the callback to use
  45714. */
  45715. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  45716. private _setButtonValue;
  45717. private _setDPadValue;
  45718. /**
  45719. * Gets the value of the `A` button
  45720. */
  45721. get buttonA(): number;
  45722. /**
  45723. * Sets the value of the `A` button
  45724. */
  45725. set buttonA(value: number);
  45726. /**
  45727. * Gets the value of the `B` button
  45728. */
  45729. get buttonB(): number;
  45730. /**
  45731. * Sets the value of the `B` button
  45732. */
  45733. set buttonB(value: number);
  45734. /**
  45735. * Gets the value of the `X` button
  45736. */
  45737. get buttonX(): number;
  45738. /**
  45739. * Sets the value of the `X` button
  45740. */
  45741. set buttonX(value: number);
  45742. /**
  45743. * Gets the value of the `Y` button
  45744. */
  45745. get buttonY(): number;
  45746. /**
  45747. * Sets the value of the `Y` button
  45748. */
  45749. set buttonY(value: number);
  45750. /**
  45751. * Gets the value of the `Start` button
  45752. */
  45753. get buttonStart(): number;
  45754. /**
  45755. * Sets the value of the `Start` button
  45756. */
  45757. set buttonStart(value: number);
  45758. /**
  45759. * Gets the value of the `Back` button
  45760. */
  45761. get buttonBack(): number;
  45762. /**
  45763. * Sets the value of the `Back` button
  45764. */
  45765. set buttonBack(value: number);
  45766. /**
  45767. * Gets the value of the `Left` button
  45768. */
  45769. get buttonLB(): number;
  45770. /**
  45771. * Sets the value of the `Left` button
  45772. */
  45773. set buttonLB(value: number);
  45774. /**
  45775. * Gets the value of the `Right` button
  45776. */
  45777. get buttonRB(): number;
  45778. /**
  45779. * Sets the value of the `Right` button
  45780. */
  45781. set buttonRB(value: number);
  45782. /**
  45783. * Gets the value of the Left joystick
  45784. */
  45785. get buttonLeftStick(): number;
  45786. /**
  45787. * Sets the value of the Left joystick
  45788. */
  45789. set buttonLeftStick(value: number);
  45790. /**
  45791. * Gets the value of the Right joystick
  45792. */
  45793. get buttonRightStick(): number;
  45794. /**
  45795. * Sets the value of the Right joystick
  45796. */
  45797. set buttonRightStick(value: number);
  45798. /**
  45799. * Gets the value of D-pad up
  45800. */
  45801. get dPadUp(): number;
  45802. /**
  45803. * Sets the value of D-pad up
  45804. */
  45805. set dPadUp(value: number);
  45806. /**
  45807. * Gets the value of D-pad down
  45808. */
  45809. get dPadDown(): number;
  45810. /**
  45811. * Sets the value of D-pad down
  45812. */
  45813. set dPadDown(value: number);
  45814. /**
  45815. * Gets the value of D-pad left
  45816. */
  45817. get dPadLeft(): number;
  45818. /**
  45819. * Sets the value of D-pad left
  45820. */
  45821. set dPadLeft(value: number);
  45822. /**
  45823. * Gets the value of D-pad right
  45824. */
  45825. get dPadRight(): number;
  45826. /**
  45827. * Sets the value of D-pad right
  45828. */
  45829. set dPadRight(value: number);
  45830. /**
  45831. * Force the gamepad to synchronize with device values
  45832. */
  45833. update(): void;
  45834. /**
  45835. * Disposes the gamepad
  45836. */
  45837. dispose(): void;
  45838. }
  45839. }
  45840. declare module BABYLON {
  45841. /**
  45842. * Defines supported buttons for DualShock compatible gamepads
  45843. */
  45844. export enum DualShockButton {
  45845. /** Cross */
  45846. Cross = 0,
  45847. /** Circle */
  45848. Circle = 1,
  45849. /** Square */
  45850. Square = 2,
  45851. /** Triangle */
  45852. Triangle = 3,
  45853. /** L1 */
  45854. L1 = 4,
  45855. /** R1 */
  45856. R1 = 5,
  45857. /** Share */
  45858. Share = 8,
  45859. /** Options */
  45860. Options = 9,
  45861. /** Left stick */
  45862. LeftStick = 10,
  45863. /** Right stick */
  45864. RightStick = 11
  45865. }
  45866. /** Defines values for DualShock DPad */
  45867. export enum DualShockDpad {
  45868. /** Up */
  45869. Up = 12,
  45870. /** Down */
  45871. Down = 13,
  45872. /** Left */
  45873. Left = 14,
  45874. /** Right */
  45875. Right = 15
  45876. }
  45877. /**
  45878. * Defines a DualShock gamepad
  45879. */
  45880. export class DualShockPad extends Gamepad {
  45881. private _leftTrigger;
  45882. private _rightTrigger;
  45883. private _onlefttriggerchanged;
  45884. private _onrighttriggerchanged;
  45885. private _onbuttondown;
  45886. private _onbuttonup;
  45887. private _ondpaddown;
  45888. private _ondpadup;
  45889. /** Observable raised when a button is pressed */
  45890. onButtonDownObservable: Observable<DualShockButton>;
  45891. /** Observable raised when a button is released */
  45892. onButtonUpObservable: Observable<DualShockButton>;
  45893. /** Observable raised when a pad is pressed */
  45894. onPadDownObservable: Observable<DualShockDpad>;
  45895. /** Observable raised when a pad is released */
  45896. onPadUpObservable: Observable<DualShockDpad>;
  45897. private _buttonCross;
  45898. private _buttonCircle;
  45899. private _buttonSquare;
  45900. private _buttonTriangle;
  45901. private _buttonShare;
  45902. private _buttonOptions;
  45903. private _buttonL1;
  45904. private _buttonR1;
  45905. private _buttonLeftStick;
  45906. private _buttonRightStick;
  45907. private _dPadUp;
  45908. private _dPadDown;
  45909. private _dPadLeft;
  45910. private _dPadRight;
  45911. /**
  45912. * Creates a new DualShock gamepad object
  45913. * @param id defines the id of this gamepad
  45914. * @param index defines its index
  45915. * @param gamepad defines the internal HTML gamepad object
  45916. */
  45917. constructor(id: string, index: number, gamepad: any);
  45918. /**
  45919. * Defines the callback to call when left trigger is pressed
  45920. * @param callback defines the callback to use
  45921. */
  45922. onlefttriggerchanged(callback: (value: number) => void): void;
  45923. /**
  45924. * Defines the callback to call when right trigger is pressed
  45925. * @param callback defines the callback to use
  45926. */
  45927. onrighttriggerchanged(callback: (value: number) => void): void;
  45928. /**
  45929. * Gets the left trigger value
  45930. */
  45931. get leftTrigger(): number;
  45932. /**
  45933. * Sets the left trigger value
  45934. */
  45935. set leftTrigger(newValue: number);
  45936. /**
  45937. * Gets the right trigger value
  45938. */
  45939. get rightTrigger(): number;
  45940. /**
  45941. * Sets the right trigger value
  45942. */
  45943. set rightTrigger(newValue: number);
  45944. /**
  45945. * Defines the callback to call when a button is pressed
  45946. * @param callback defines the callback to use
  45947. */
  45948. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  45949. /**
  45950. * Defines the callback to call when a button is released
  45951. * @param callback defines the callback to use
  45952. */
  45953. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  45954. /**
  45955. * Defines the callback to call when a pad is pressed
  45956. * @param callback defines the callback to use
  45957. */
  45958. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  45959. /**
  45960. * Defines the callback to call when a pad is released
  45961. * @param callback defines the callback to use
  45962. */
  45963. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  45964. private _setButtonValue;
  45965. private _setDPadValue;
  45966. /**
  45967. * Gets the value of the `Cross` button
  45968. */
  45969. get buttonCross(): number;
  45970. /**
  45971. * Sets the value of the `Cross` button
  45972. */
  45973. set buttonCross(value: number);
  45974. /**
  45975. * Gets the value of the `Circle` button
  45976. */
  45977. get buttonCircle(): number;
  45978. /**
  45979. * Sets the value of the `Circle` button
  45980. */
  45981. set buttonCircle(value: number);
  45982. /**
  45983. * Gets the value of the `Square` button
  45984. */
  45985. get buttonSquare(): number;
  45986. /**
  45987. * Sets the value of the `Square` button
  45988. */
  45989. set buttonSquare(value: number);
  45990. /**
  45991. * Gets the value of the `Triangle` button
  45992. */
  45993. get buttonTriangle(): number;
  45994. /**
  45995. * Sets the value of the `Triangle` button
  45996. */
  45997. set buttonTriangle(value: number);
  45998. /**
  45999. * Gets the value of the `Options` button
  46000. */
  46001. get buttonOptions(): number;
  46002. /**
  46003. * Sets the value of the `Options` button
  46004. */
  46005. set buttonOptions(value: number);
  46006. /**
  46007. * Gets the value of the `Share` button
  46008. */
  46009. get buttonShare(): number;
  46010. /**
  46011. * Sets the value of the `Share` button
  46012. */
  46013. set buttonShare(value: number);
  46014. /**
  46015. * Gets the value of the `L1` button
  46016. */
  46017. get buttonL1(): number;
  46018. /**
  46019. * Sets the value of the `L1` button
  46020. */
  46021. set buttonL1(value: number);
  46022. /**
  46023. * Gets the value of the `R1` button
  46024. */
  46025. get buttonR1(): number;
  46026. /**
  46027. * Sets the value of the `R1` button
  46028. */
  46029. set buttonR1(value: number);
  46030. /**
  46031. * Gets the value of the Left joystick
  46032. */
  46033. get buttonLeftStick(): number;
  46034. /**
  46035. * Sets the value of the Left joystick
  46036. */
  46037. set buttonLeftStick(value: number);
  46038. /**
  46039. * Gets the value of the Right joystick
  46040. */
  46041. get buttonRightStick(): number;
  46042. /**
  46043. * Sets the value of the Right joystick
  46044. */
  46045. set buttonRightStick(value: number);
  46046. /**
  46047. * Gets the value of D-pad up
  46048. */
  46049. get dPadUp(): number;
  46050. /**
  46051. * Sets the value of D-pad up
  46052. */
  46053. set dPadUp(value: number);
  46054. /**
  46055. * Gets the value of D-pad down
  46056. */
  46057. get dPadDown(): number;
  46058. /**
  46059. * Sets the value of D-pad down
  46060. */
  46061. set dPadDown(value: number);
  46062. /**
  46063. * Gets the value of D-pad left
  46064. */
  46065. get dPadLeft(): number;
  46066. /**
  46067. * Sets the value of D-pad left
  46068. */
  46069. set dPadLeft(value: number);
  46070. /**
  46071. * Gets the value of D-pad right
  46072. */
  46073. get dPadRight(): number;
  46074. /**
  46075. * Sets the value of D-pad right
  46076. */
  46077. set dPadRight(value: number);
  46078. /**
  46079. * Force the gamepad to synchronize with device values
  46080. */
  46081. update(): void;
  46082. /**
  46083. * Disposes the gamepad
  46084. */
  46085. dispose(): void;
  46086. }
  46087. }
  46088. declare module BABYLON {
  46089. /**
  46090. * Manager for handling gamepads
  46091. */
  46092. export class GamepadManager {
  46093. private _scene?;
  46094. private _babylonGamepads;
  46095. private _oneGamepadConnected;
  46096. /** @hidden */
  46097. _isMonitoring: boolean;
  46098. private _gamepadEventSupported;
  46099. private _gamepadSupport?;
  46100. /**
  46101. * observable to be triggered when the gamepad controller has been connected
  46102. */
  46103. onGamepadConnectedObservable: Observable<Gamepad>;
  46104. /**
  46105. * observable to be triggered when the gamepad controller has been disconnected
  46106. */
  46107. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46108. private _onGamepadConnectedEvent;
  46109. private _onGamepadDisconnectedEvent;
  46110. /**
  46111. * Initializes the gamepad manager
  46112. * @param _scene BabylonJS scene
  46113. */
  46114. constructor(_scene?: Scene | undefined);
  46115. /**
  46116. * The gamepads in the game pad manager
  46117. */
  46118. get gamepads(): Gamepad[];
  46119. /**
  46120. * Get the gamepad controllers based on type
  46121. * @param type The type of gamepad controller
  46122. * @returns Nullable gamepad
  46123. */
  46124. getGamepadByType(type?: number): Nullable<Gamepad>;
  46125. /**
  46126. * Disposes the gamepad manager
  46127. */
  46128. dispose(): void;
  46129. private _addNewGamepad;
  46130. private _startMonitoringGamepads;
  46131. private _stopMonitoringGamepads;
  46132. /** @hidden */
  46133. _checkGamepadsStatus(): void;
  46134. private _updateGamepadObjects;
  46135. }
  46136. }
  46137. declare module BABYLON {
  46138. interface Scene {
  46139. /** @hidden */
  46140. _gamepadManager: Nullable<GamepadManager>;
  46141. /**
  46142. * Gets the gamepad manager associated with the scene
  46143. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46144. */
  46145. gamepadManager: GamepadManager;
  46146. }
  46147. /**
  46148. * Interface representing a free camera inputs manager
  46149. */
  46150. interface FreeCameraInputsManager {
  46151. /**
  46152. * Adds gamepad input support to the FreeCameraInputsManager.
  46153. * @returns the FreeCameraInputsManager
  46154. */
  46155. addGamepad(): FreeCameraInputsManager;
  46156. }
  46157. /**
  46158. * Interface representing an arc rotate camera inputs manager
  46159. */
  46160. interface ArcRotateCameraInputsManager {
  46161. /**
  46162. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46163. * @returns the camera inputs manager
  46164. */
  46165. addGamepad(): ArcRotateCameraInputsManager;
  46166. }
  46167. /**
  46168. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46169. */
  46170. export class GamepadSystemSceneComponent implements ISceneComponent {
  46171. /**
  46172. * The component name helpfull to identify the component in the list of scene components.
  46173. */
  46174. readonly name: string;
  46175. /**
  46176. * The scene the component belongs to.
  46177. */
  46178. scene: Scene;
  46179. /**
  46180. * Creates a new instance of the component for the given scene
  46181. * @param scene Defines the scene to register the component in
  46182. */
  46183. constructor(scene: Scene);
  46184. /**
  46185. * Registers the component in a given scene
  46186. */
  46187. register(): void;
  46188. /**
  46189. * Rebuilds the elements related to this component in case of
  46190. * context lost for instance.
  46191. */
  46192. rebuild(): void;
  46193. /**
  46194. * Disposes the component and the associated ressources
  46195. */
  46196. dispose(): void;
  46197. private _beforeCameraUpdate;
  46198. }
  46199. }
  46200. declare module BABYLON {
  46201. /**
  46202. * 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,
  46203. * which still works and will still be found in many Playgrounds.
  46204. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46205. */
  46206. export class UniversalCamera extends TouchCamera {
  46207. /**
  46208. * Defines the gamepad rotation sensiblity.
  46209. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46210. */
  46211. get gamepadAngularSensibility(): number;
  46212. set gamepadAngularSensibility(value: number);
  46213. /**
  46214. * Defines the gamepad move sensiblity.
  46215. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46216. */
  46217. get gamepadMoveSensibility(): number;
  46218. set gamepadMoveSensibility(value: number);
  46219. /**
  46220. * 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,
  46221. * which still works and will still be found in many Playgrounds.
  46222. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46223. * @param name Define the name of the camera in the scene
  46224. * @param position Define the start position of the camera in the scene
  46225. * @param scene Define the scene the camera belongs to
  46226. */
  46227. constructor(name: string, position: Vector3, scene: Scene);
  46228. /**
  46229. * Gets the current object class name.
  46230. * @return the class name
  46231. */
  46232. getClassName(): string;
  46233. }
  46234. }
  46235. declare module BABYLON {
  46236. /**
  46237. * This represents a FPS type of camera. This is only here for back compat purpose.
  46238. * Please use the UniversalCamera instead as both are identical.
  46239. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46240. */
  46241. export class GamepadCamera extends UniversalCamera {
  46242. /**
  46243. * Instantiates a new Gamepad Camera
  46244. * This represents a FPS type of camera. This is only here for back compat purpose.
  46245. * Please use the UniversalCamera instead as both are identical.
  46246. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46247. * @param name Define the name of the camera in the scene
  46248. * @param position Define the start position of the camera in the scene
  46249. * @param scene Define the scene the camera belongs to
  46250. */
  46251. constructor(name: string, position: Vector3, scene: Scene);
  46252. /**
  46253. * Gets the current object class name.
  46254. * @return the class name
  46255. */
  46256. getClassName(): string;
  46257. }
  46258. }
  46259. declare module BABYLON {
  46260. /** @hidden */
  46261. export var passPixelShader: {
  46262. name: string;
  46263. shader: string;
  46264. };
  46265. }
  46266. declare module BABYLON {
  46267. /** @hidden */
  46268. export var passCubePixelShader: {
  46269. name: string;
  46270. shader: string;
  46271. };
  46272. }
  46273. declare module BABYLON {
  46274. /**
  46275. * PassPostProcess which produces an output the same as it's input
  46276. */
  46277. export class PassPostProcess extends PostProcess {
  46278. /**
  46279. * Gets a string identifying the name of the class
  46280. * @returns "PassPostProcess" string
  46281. */
  46282. getClassName(): string;
  46283. /**
  46284. * Creates the PassPostProcess
  46285. * @param name The name of the effect.
  46286. * @param options The required width/height ratio to downsize to before computing the render pass.
  46287. * @param camera The camera to apply the render pass to.
  46288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46289. * @param engine The engine which the post process will be applied. (default: current engine)
  46290. * @param reusable If the post process can be reused on the same frame. (default: false)
  46291. * @param textureType The type of texture to be used when performing the post processing.
  46292. * @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)
  46293. */
  46294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46295. /** @hidden */
  46296. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  46297. }
  46298. /**
  46299. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46300. */
  46301. export class PassCubePostProcess extends PostProcess {
  46302. private _face;
  46303. /**
  46304. * Gets or sets the cube face to display.
  46305. * * 0 is +X
  46306. * * 1 is -X
  46307. * * 2 is +Y
  46308. * * 3 is -Y
  46309. * * 4 is +Z
  46310. * * 5 is -Z
  46311. */
  46312. get face(): number;
  46313. set face(value: number);
  46314. /**
  46315. * Gets a string identifying the name of the class
  46316. * @returns "PassCubePostProcess" string
  46317. */
  46318. getClassName(): string;
  46319. /**
  46320. * Creates the PassCubePostProcess
  46321. * @param name The name of the effect.
  46322. * @param options The required width/height ratio to downsize to before computing the render pass.
  46323. * @param camera The camera to apply the render pass to.
  46324. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46325. * @param engine The engine which the post process will be applied. (default: current engine)
  46326. * @param reusable If the post process can be reused on the same frame. (default: false)
  46327. * @param textureType The type of texture to be used when performing the post processing.
  46328. * @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)
  46329. */
  46330. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46331. /** @hidden */
  46332. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  46333. }
  46334. }
  46335. declare module BABYLON {
  46336. /** @hidden */
  46337. export var anaglyphPixelShader: {
  46338. name: string;
  46339. shader: string;
  46340. };
  46341. }
  46342. declare module BABYLON {
  46343. /**
  46344. * Postprocess used to generate anaglyphic rendering
  46345. */
  46346. export class AnaglyphPostProcess extends PostProcess {
  46347. private _passedProcess;
  46348. /**
  46349. * Gets a string identifying the name of the class
  46350. * @returns "AnaglyphPostProcess" string
  46351. */
  46352. getClassName(): string;
  46353. /**
  46354. * Creates a new AnaglyphPostProcess
  46355. * @param name defines postprocess name
  46356. * @param options defines creation options or target ratio scale
  46357. * @param rigCameras defines cameras using this postprocess
  46358. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46359. * @param engine defines hosting engine
  46360. * @param reusable defines if the postprocess will be reused multiple times per frame
  46361. */
  46362. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46363. }
  46364. }
  46365. declare module BABYLON {
  46366. /**
  46367. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46368. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46369. */
  46370. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46371. /**
  46372. * Creates a new AnaglyphArcRotateCamera
  46373. * @param name defines camera name
  46374. * @param alpha defines alpha angle (in radians)
  46375. * @param beta defines beta angle (in radians)
  46376. * @param radius defines radius
  46377. * @param target defines camera target
  46378. * @param interaxialDistance defines distance between each color axis
  46379. * @param scene defines the hosting scene
  46380. */
  46381. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46382. /**
  46383. * Gets camera class name
  46384. * @returns AnaglyphArcRotateCamera
  46385. */
  46386. getClassName(): string;
  46387. }
  46388. }
  46389. declare module BABYLON {
  46390. /**
  46391. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46392. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46393. */
  46394. export class AnaglyphFreeCamera extends FreeCamera {
  46395. /**
  46396. * Creates a new AnaglyphFreeCamera
  46397. * @param name defines camera name
  46398. * @param position defines initial position
  46399. * @param interaxialDistance defines distance between each color axis
  46400. * @param scene defines the hosting scene
  46401. */
  46402. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46403. /**
  46404. * Gets camera class name
  46405. * @returns AnaglyphFreeCamera
  46406. */
  46407. getClassName(): string;
  46408. }
  46409. }
  46410. declare module BABYLON {
  46411. /**
  46412. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46413. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46414. */
  46415. export class AnaglyphGamepadCamera extends GamepadCamera {
  46416. /**
  46417. * Creates a new AnaglyphGamepadCamera
  46418. * @param name defines camera name
  46419. * @param position defines initial position
  46420. * @param interaxialDistance defines distance between each color axis
  46421. * @param scene defines the hosting scene
  46422. */
  46423. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46424. /**
  46425. * Gets camera class name
  46426. * @returns AnaglyphGamepadCamera
  46427. */
  46428. getClassName(): string;
  46429. }
  46430. }
  46431. declare module BABYLON {
  46432. /**
  46433. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46434. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46435. */
  46436. export class AnaglyphUniversalCamera extends UniversalCamera {
  46437. /**
  46438. * Creates a new AnaglyphUniversalCamera
  46439. * @param name defines camera name
  46440. * @param position defines initial position
  46441. * @param interaxialDistance defines distance between each color axis
  46442. * @param scene defines the hosting scene
  46443. */
  46444. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46445. /**
  46446. * Gets camera class name
  46447. * @returns AnaglyphUniversalCamera
  46448. */
  46449. getClassName(): string;
  46450. }
  46451. }
  46452. declare module BABYLON {
  46453. /**
  46454. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46455. * @see https://doc.babylonjs.com/features/cameras
  46456. */
  46457. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46458. /**
  46459. * Creates a new StereoscopicArcRotateCamera
  46460. * @param name defines camera name
  46461. * @param alpha defines alpha angle (in radians)
  46462. * @param beta defines beta angle (in radians)
  46463. * @param radius defines radius
  46464. * @param target defines camera target
  46465. * @param interaxialDistance defines distance between each color axis
  46466. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46467. * @param scene defines the hosting scene
  46468. */
  46469. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46470. /**
  46471. * Gets camera class name
  46472. * @returns StereoscopicArcRotateCamera
  46473. */
  46474. getClassName(): string;
  46475. }
  46476. }
  46477. declare module BABYLON {
  46478. /**
  46479. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46480. * @see https://doc.babylonjs.com/features/cameras
  46481. */
  46482. export class StereoscopicFreeCamera extends FreeCamera {
  46483. /**
  46484. * Creates a new StereoscopicFreeCamera
  46485. * @param name defines camera name
  46486. * @param position defines initial position
  46487. * @param interaxialDistance defines distance between each color axis
  46488. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46489. * @param scene defines the hosting scene
  46490. */
  46491. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46492. /**
  46493. * Gets camera class name
  46494. * @returns StereoscopicFreeCamera
  46495. */
  46496. getClassName(): string;
  46497. }
  46498. }
  46499. declare module BABYLON {
  46500. /**
  46501. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46502. * @see https://doc.babylonjs.com/features/cameras
  46503. */
  46504. export class StereoscopicGamepadCamera extends GamepadCamera {
  46505. /**
  46506. * Creates a new StereoscopicGamepadCamera
  46507. * @param name defines camera name
  46508. * @param position defines initial position
  46509. * @param interaxialDistance defines distance between each color axis
  46510. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46511. * @param scene defines the hosting scene
  46512. */
  46513. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46514. /**
  46515. * Gets camera class name
  46516. * @returns StereoscopicGamepadCamera
  46517. */
  46518. getClassName(): string;
  46519. }
  46520. }
  46521. declare module BABYLON {
  46522. /**
  46523. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  46524. * @see https://doc.babylonjs.com/features/cameras
  46525. */
  46526. export class StereoscopicUniversalCamera extends UniversalCamera {
  46527. /**
  46528. * Creates a new StereoscopicUniversalCamera
  46529. * @param name defines camera name
  46530. * @param position defines initial position
  46531. * @param interaxialDistance defines distance between each color axis
  46532. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46533. * @param scene defines the hosting scene
  46534. */
  46535. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46536. /**
  46537. * Gets camera class name
  46538. * @returns StereoscopicUniversalCamera
  46539. */
  46540. getClassName(): string;
  46541. }
  46542. }
  46543. declare module BABYLON {
  46544. /**
  46545. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  46546. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46547. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46548. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46549. */
  46550. export class VirtualJoysticksCamera extends FreeCamera {
  46551. /**
  46552. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  46553. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  46554. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  46555. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  46556. * @param name Define the name of the camera in the scene
  46557. * @param position Define the start position of the camera in the scene
  46558. * @param scene Define the scene the camera belongs to
  46559. */
  46560. constructor(name: string, position: Vector3, scene: Scene);
  46561. /**
  46562. * Gets the current object class name.
  46563. * @return the class name
  46564. */
  46565. getClassName(): string;
  46566. }
  46567. }
  46568. declare module BABYLON {
  46569. /**
  46570. * This represents all the required metrics to create a VR camera.
  46571. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  46572. */
  46573. export class VRCameraMetrics {
  46574. /**
  46575. * Define the horizontal resolution off the screen.
  46576. */
  46577. hResolution: number;
  46578. /**
  46579. * Define the vertical resolution off the screen.
  46580. */
  46581. vResolution: number;
  46582. /**
  46583. * Define the horizontal screen size.
  46584. */
  46585. hScreenSize: number;
  46586. /**
  46587. * Define the vertical screen size.
  46588. */
  46589. vScreenSize: number;
  46590. /**
  46591. * Define the vertical screen center position.
  46592. */
  46593. vScreenCenter: number;
  46594. /**
  46595. * Define the distance of the eyes to the screen.
  46596. */
  46597. eyeToScreenDistance: number;
  46598. /**
  46599. * Define the distance between both lenses
  46600. */
  46601. lensSeparationDistance: number;
  46602. /**
  46603. * Define the distance between both viewer's eyes.
  46604. */
  46605. interpupillaryDistance: number;
  46606. /**
  46607. * Define the distortion factor of the VR postprocess.
  46608. * Please, touch with care.
  46609. */
  46610. distortionK: number[];
  46611. /**
  46612. * Define the chromatic aberration correction factors for the VR post process.
  46613. */
  46614. chromaAbCorrection: number[];
  46615. /**
  46616. * Define the scale factor of the post process.
  46617. * The smaller the better but the slower.
  46618. */
  46619. postProcessScaleFactor: number;
  46620. /**
  46621. * Define an offset for the lens center.
  46622. */
  46623. lensCenterOffset: number;
  46624. /**
  46625. * Define if the current vr camera should compensate the distortion of the lense or not.
  46626. */
  46627. compensateDistortion: boolean;
  46628. /**
  46629. * Defines if multiview should be enabled when rendering (Default: false)
  46630. */
  46631. multiviewEnabled: boolean;
  46632. /**
  46633. * Gets the rendering aspect ratio based on the provided resolutions.
  46634. */
  46635. get aspectRatio(): number;
  46636. /**
  46637. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  46638. */
  46639. get aspectRatioFov(): number;
  46640. /**
  46641. * @hidden
  46642. */
  46643. get leftHMatrix(): Matrix;
  46644. /**
  46645. * @hidden
  46646. */
  46647. get rightHMatrix(): Matrix;
  46648. /**
  46649. * @hidden
  46650. */
  46651. get leftPreViewMatrix(): Matrix;
  46652. /**
  46653. * @hidden
  46654. */
  46655. get rightPreViewMatrix(): Matrix;
  46656. /**
  46657. * Get the default VRMetrics based on the most generic setup.
  46658. * @returns the default vr metrics
  46659. */
  46660. static GetDefault(): VRCameraMetrics;
  46661. }
  46662. }
  46663. declare module BABYLON {
  46664. /** @hidden */
  46665. export var vrDistortionCorrectionPixelShader: {
  46666. name: string;
  46667. shader: string;
  46668. };
  46669. }
  46670. declare module BABYLON {
  46671. /**
  46672. * VRDistortionCorrectionPostProcess used for mobile VR
  46673. */
  46674. export class VRDistortionCorrectionPostProcess extends PostProcess {
  46675. private _isRightEye;
  46676. private _distortionFactors;
  46677. private _postProcessScaleFactor;
  46678. private _lensCenterOffset;
  46679. private _scaleIn;
  46680. private _scaleFactor;
  46681. private _lensCenter;
  46682. /**
  46683. * Gets a string identifying the name of the class
  46684. * @returns "VRDistortionCorrectionPostProcess" string
  46685. */
  46686. getClassName(): string;
  46687. /**
  46688. * Initializes the VRDistortionCorrectionPostProcess
  46689. * @param name The name of the effect.
  46690. * @param camera The camera to apply the render pass to.
  46691. * @param isRightEye If this is for the right eye distortion
  46692. * @param vrMetrics All the required metrics for the VR camera
  46693. */
  46694. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  46695. }
  46696. }
  46697. declare module BABYLON {
  46698. /**
  46699. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  46700. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46701. */
  46702. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  46703. /**
  46704. * Creates a new VRDeviceOrientationArcRotateCamera
  46705. * @param name defines camera name
  46706. * @param alpha defines the camera rotation along the logitudinal axis
  46707. * @param beta defines the camera rotation along the latitudinal axis
  46708. * @param radius defines the camera distance from its target
  46709. * @param target defines the camera target
  46710. * @param scene defines the scene the camera belongs to
  46711. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46712. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46713. */
  46714. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46715. /**
  46716. * Gets camera class name
  46717. * @returns VRDeviceOrientationArcRotateCamera
  46718. */
  46719. getClassName(): string;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * Camera used to simulate VR rendering (based on FreeCamera)
  46725. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46726. */
  46727. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  46728. /**
  46729. * Creates a new VRDeviceOrientationFreeCamera
  46730. * @param name defines camera name
  46731. * @param position defines the start position of the camera
  46732. * @param scene defines the scene the camera belongs to
  46733. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46734. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46735. */
  46736. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46737. /**
  46738. * Gets camera class name
  46739. * @returns VRDeviceOrientationFreeCamera
  46740. */
  46741. getClassName(): string;
  46742. }
  46743. }
  46744. declare module BABYLON {
  46745. /**
  46746. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  46747. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  46748. */
  46749. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  46750. /**
  46751. * Creates a new VRDeviceOrientationGamepadCamera
  46752. * @param name defines camera name
  46753. * @param position defines the start position of the camera
  46754. * @param scene defines the scene the camera belongs to
  46755. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  46756. * @param vrCameraMetrics defines the vr metrics associated to the camera
  46757. */
  46758. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  46759. /**
  46760. * Gets camera class name
  46761. * @returns VRDeviceOrientationGamepadCamera
  46762. */
  46763. getClassName(): string;
  46764. }
  46765. }
  46766. declare module BABYLON {
  46767. /**
  46768. * A class extending Texture allowing drawing on a texture
  46769. * @see https://doc.babylonjs.com/how_to/dynamictexture
  46770. */
  46771. export class DynamicTexture extends Texture {
  46772. private _generateMipMaps;
  46773. private _canvas;
  46774. private _context;
  46775. /**
  46776. * Creates a DynamicTexture
  46777. * @param name defines the name of the texture
  46778. * @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
  46779. * @param scene defines the scene where you want the texture
  46780. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  46781. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  46782. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  46783. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  46784. */
  46785. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  46786. /**
  46787. * Get the current class name of the texture useful for serialization or dynamic coding.
  46788. * @returns "DynamicTexture"
  46789. */
  46790. getClassName(): string;
  46791. /**
  46792. * Gets the current state of canRescale
  46793. */
  46794. get canRescale(): boolean;
  46795. private _recreate;
  46796. /**
  46797. * Scales the texture
  46798. * @param ratio the scale factor to apply to both width and height
  46799. */
  46800. scale(ratio: number): void;
  46801. /**
  46802. * Resizes the texture
  46803. * @param width the new width
  46804. * @param height the new height
  46805. */
  46806. scaleTo(width: number, height: number): void;
  46807. /**
  46808. * Gets the context of the canvas used by the texture
  46809. * @returns the canvas context of the dynamic texture
  46810. */
  46811. getContext(): CanvasRenderingContext2D;
  46812. /**
  46813. * Clears the texture
  46814. */
  46815. clear(): void;
  46816. /**
  46817. * Updates the texture
  46818. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46819. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  46820. */
  46821. update(invertY?: boolean, premulAlpha?: boolean): void;
  46822. /**
  46823. * Draws text onto the texture
  46824. * @param text defines the text to be drawn
  46825. * @param x defines the placement of the text from the left
  46826. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  46827. * @param font defines the font to be used with font-style, font-size, font-name
  46828. * @param color defines the color used for the text
  46829. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  46830. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  46831. * @param update defines whether texture is immediately update (default is true)
  46832. */
  46833. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  46834. /**
  46835. * Clones the texture
  46836. * @returns the clone of the texture.
  46837. */
  46838. clone(): DynamicTexture;
  46839. /**
  46840. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  46841. * @returns a serialized dynamic texture object
  46842. */
  46843. serialize(): any;
  46844. private _IsCanvasElement;
  46845. /** @hidden */
  46846. _rebuild(): void;
  46847. }
  46848. }
  46849. declare module BABYLON {
  46850. /**
  46851. * Class containing static functions to help procedurally build meshes
  46852. */
  46853. export class GroundBuilder {
  46854. /**
  46855. * Creates a ground mesh
  46856. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  46857. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  46858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46859. * @param name defines the name of the mesh
  46860. * @param options defines the options used to create the mesh
  46861. * @param scene defines the hosting scene
  46862. * @returns the ground mesh
  46863. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  46864. */
  46865. static CreateGround(name: string, options: {
  46866. width?: number;
  46867. height?: number;
  46868. subdivisions?: number;
  46869. subdivisionsX?: number;
  46870. subdivisionsY?: number;
  46871. updatable?: boolean;
  46872. }, scene: any): Mesh;
  46873. /**
  46874. * Creates a tiled ground mesh
  46875. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  46876. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  46877. * * 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
  46878. * * 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
  46879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46880. * @param name defines the name of the mesh
  46881. * @param options defines the options used to create the mesh
  46882. * @param scene defines the hosting scene
  46883. * @returns the tiled ground mesh
  46884. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  46885. */
  46886. static CreateTiledGround(name: string, options: {
  46887. xmin: number;
  46888. zmin: number;
  46889. xmax: number;
  46890. zmax: number;
  46891. subdivisions?: {
  46892. w: number;
  46893. h: number;
  46894. };
  46895. precision?: {
  46896. w: number;
  46897. h: number;
  46898. };
  46899. updatable?: boolean;
  46900. }, scene?: Nullable<Scene>): Mesh;
  46901. /**
  46902. * Creates a ground mesh from a height map
  46903. * * The parameter `url` sets the URL of the height map image resource.
  46904. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  46905. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  46906. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  46907. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  46908. * * 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.
  46909. * * 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).
  46910. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  46911. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46912. * @param name defines the name of the mesh
  46913. * @param url defines the url to the height map
  46914. * @param options defines the options used to create the mesh
  46915. * @param scene defines the hosting scene
  46916. * @returns the ground mesh
  46917. * @see https://doc.babylonjs.com/babylon101/height_map
  46918. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  46919. */
  46920. static CreateGroundFromHeightMap(name: string, url: string, options: {
  46921. width?: number;
  46922. height?: number;
  46923. subdivisions?: number;
  46924. minHeight?: number;
  46925. maxHeight?: number;
  46926. colorFilter?: Color3;
  46927. alphaFilter?: number;
  46928. updatable?: boolean;
  46929. onReady?: (mesh: GroundMesh) => void;
  46930. }, scene?: Nullable<Scene>): GroundMesh;
  46931. }
  46932. }
  46933. declare module BABYLON {
  46934. /**
  46935. * Class containing static functions to help procedurally build meshes
  46936. */
  46937. export class TorusBuilder {
  46938. /**
  46939. * Creates a torus mesh
  46940. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  46941. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  46942. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  46943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46944. * * 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
  46945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46946. * @param name defines the name of the mesh
  46947. * @param options defines the options used to create the mesh
  46948. * @param scene defines the hosting scene
  46949. * @returns the torus mesh
  46950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  46951. */
  46952. static CreateTorus(name: string, options: {
  46953. diameter?: number;
  46954. thickness?: number;
  46955. tessellation?: number;
  46956. updatable?: boolean;
  46957. sideOrientation?: number;
  46958. frontUVs?: Vector4;
  46959. backUVs?: Vector4;
  46960. }, scene: any): Mesh;
  46961. }
  46962. }
  46963. declare module BABYLON {
  46964. /**
  46965. * Class containing static functions to help procedurally build meshes
  46966. */
  46967. export class CylinderBuilder {
  46968. /**
  46969. * Creates a cylinder or a cone mesh
  46970. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  46971. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  46972. * * 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.
  46973. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  46974. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  46975. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  46976. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  46977. * * 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).
  46978. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  46979. * * 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).
  46980. * * 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
  46981. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  46982. * * 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
  46983. * * 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.
  46984. * * If `enclose` is false, a ring surface is one element.
  46985. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  46986. * * 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
  46987. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46988. * * 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
  46989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  46990. * @param name defines the name of the mesh
  46991. * @param options defines the options used to create the mesh
  46992. * @param scene defines the hosting scene
  46993. * @returns the cylinder mesh
  46994. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  46995. */
  46996. static CreateCylinder(name: string, options: {
  46997. height?: number;
  46998. diameterTop?: number;
  46999. diameterBottom?: number;
  47000. diameter?: number;
  47001. tessellation?: number;
  47002. subdivisions?: number;
  47003. arc?: number;
  47004. faceColors?: Color4[];
  47005. faceUV?: Vector4[];
  47006. updatable?: boolean;
  47007. hasRings?: boolean;
  47008. enclose?: boolean;
  47009. cap?: number;
  47010. sideOrientation?: number;
  47011. frontUVs?: Vector4;
  47012. backUVs?: Vector4;
  47013. }, scene: any): Mesh;
  47014. }
  47015. }
  47016. declare module BABYLON {
  47017. /**
  47018. * States of the webXR experience
  47019. */
  47020. export enum WebXRState {
  47021. /**
  47022. * Transitioning to being in XR mode
  47023. */
  47024. ENTERING_XR = 0,
  47025. /**
  47026. * Transitioning to non XR mode
  47027. */
  47028. EXITING_XR = 1,
  47029. /**
  47030. * In XR mode and presenting
  47031. */
  47032. IN_XR = 2,
  47033. /**
  47034. * Not entered XR mode
  47035. */
  47036. NOT_IN_XR = 3
  47037. }
  47038. /**
  47039. * Abstraction of the XR render target
  47040. */
  47041. export interface WebXRRenderTarget extends IDisposable {
  47042. /**
  47043. * xrpresent context of the canvas which can be used to display/mirror xr content
  47044. */
  47045. canvasContext: WebGLRenderingContext;
  47046. /**
  47047. * xr layer for the canvas
  47048. */
  47049. xrLayer: Nullable<XRWebGLLayer>;
  47050. /**
  47051. * Initializes the xr layer for the session
  47052. * @param xrSession xr session
  47053. * @returns a promise that will resolve once the XR Layer has been created
  47054. */
  47055. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47056. }
  47057. }
  47058. declare module BABYLON {
  47059. /**
  47060. * COnfiguration object for WebXR output canvas
  47061. */
  47062. export class WebXRManagedOutputCanvasOptions {
  47063. /**
  47064. * An optional canvas in case you wish to create it yourself and provide it here.
  47065. * If not provided, a new canvas will be created
  47066. */
  47067. canvasElement?: HTMLCanvasElement;
  47068. /**
  47069. * Options for this XR Layer output
  47070. */
  47071. canvasOptions?: XRWebGLLayerOptions;
  47072. /**
  47073. * CSS styling for a newly created canvas (if not provided)
  47074. */
  47075. newCanvasCssStyle?: string;
  47076. /**
  47077. * Get the default values of the configuration object
  47078. * @param engine defines the engine to use (can be null)
  47079. * @returns default values of this configuration object
  47080. */
  47081. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  47082. }
  47083. /**
  47084. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47085. */
  47086. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47087. private _options;
  47088. private _canvas;
  47089. private _engine;
  47090. private _originalCanvasSize;
  47091. /**
  47092. * Rendering context of the canvas which can be used to display/mirror xr content
  47093. */
  47094. canvasContext: WebGLRenderingContext;
  47095. /**
  47096. * xr layer for the canvas
  47097. */
  47098. xrLayer: Nullable<XRWebGLLayer>;
  47099. /**
  47100. * Obseervers registered here will be triggered when the xr layer was initialized
  47101. */
  47102. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47103. /**
  47104. * Initializes the canvas to be added/removed upon entering/exiting xr
  47105. * @param _xrSessionManager The XR Session manager
  47106. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47107. */
  47108. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47109. /**
  47110. * Disposes of the object
  47111. */
  47112. dispose(): void;
  47113. /**
  47114. * Initializes the xr layer for the session
  47115. * @param xrSession xr session
  47116. * @returns a promise that will resolve once the XR Layer has been created
  47117. */
  47118. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47119. private _addCanvas;
  47120. private _removeCanvas;
  47121. private _setCanvasSize;
  47122. private _setManagedOutputCanvas;
  47123. }
  47124. }
  47125. declare module BABYLON {
  47126. /**
  47127. * Manages an XRSession to work with Babylon's engine
  47128. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47129. */
  47130. export class WebXRSessionManager implements IDisposable {
  47131. /** The scene which the session should be created for */
  47132. scene: Scene;
  47133. private _referenceSpace;
  47134. private _rttProvider;
  47135. private _sessionEnded;
  47136. private _xrNavigator;
  47137. private baseLayer;
  47138. /**
  47139. * The base reference space from which the session started. good if you want to reset your
  47140. * reference space
  47141. */
  47142. baseReferenceSpace: XRReferenceSpace;
  47143. /**
  47144. * Current XR frame
  47145. */
  47146. currentFrame: Nullable<XRFrame>;
  47147. /** WebXR timestamp updated every frame */
  47148. currentTimestamp: number;
  47149. /**
  47150. * Used just in case of a failure to initialize an immersive session.
  47151. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47152. */
  47153. defaultHeightCompensation: number;
  47154. /**
  47155. * Fires every time a new xrFrame arrives which can be used to update the camera
  47156. */
  47157. onXRFrameObservable: Observable<XRFrame>;
  47158. /**
  47159. * Fires when the reference space changed
  47160. */
  47161. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47162. /**
  47163. * Fires when the xr session is ended either by the device or manually done
  47164. */
  47165. onXRSessionEnded: Observable<any>;
  47166. /**
  47167. * Fires when the xr session is ended either by the device or manually done
  47168. */
  47169. onXRSessionInit: Observable<XRSession>;
  47170. /**
  47171. * Underlying xr session
  47172. */
  47173. session: XRSession;
  47174. /**
  47175. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47176. * or get the offset the player is currently at.
  47177. */
  47178. viewerReferenceSpace: XRReferenceSpace;
  47179. /**
  47180. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47181. * @param scene The scene which the session should be created for
  47182. */
  47183. constructor(
  47184. /** The scene which the session should be created for */
  47185. scene: Scene);
  47186. /**
  47187. * The current reference space used in this session. This reference space can constantly change!
  47188. * It is mainly used to offset the camera's position.
  47189. */
  47190. get referenceSpace(): XRReferenceSpace;
  47191. /**
  47192. * Set a new reference space and triggers the observable
  47193. */
  47194. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47195. /**
  47196. * Disposes of the session manager
  47197. */
  47198. dispose(): void;
  47199. /**
  47200. * Stops the xrSession and restores the render loop
  47201. * @returns Promise which resolves after it exits XR
  47202. */
  47203. exitXRAsync(): Promise<void>;
  47204. /**
  47205. * Gets the correct render target texture to be rendered this frame for this eye
  47206. * @param eye the eye for which to get the render target
  47207. * @returns the render target for the specified eye
  47208. */
  47209. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47210. /**
  47211. * Creates a WebXRRenderTarget object for the XR session
  47212. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47213. * @param options optional options to provide when creating a new render target
  47214. * @returns a WebXR render target to which the session can render
  47215. */
  47216. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47217. /**
  47218. * Initializes the manager
  47219. * After initialization enterXR can be called to start an XR session
  47220. * @returns Promise which resolves after it is initialized
  47221. */
  47222. initializeAsync(): Promise<void>;
  47223. /**
  47224. * Initializes an xr session
  47225. * @param xrSessionMode mode to initialize
  47226. * @param xrSessionInit defines optional and required values to pass to the session builder
  47227. * @returns a promise which will resolve once the session has been initialized
  47228. */
  47229. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47230. /**
  47231. * Checks if a session would be supported for the creation options specified
  47232. * @param sessionMode session mode to check if supported eg. immersive-vr
  47233. * @returns A Promise that resolves to true if supported and false if not
  47234. */
  47235. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47236. /**
  47237. * Resets the reference space to the one started the session
  47238. */
  47239. resetReferenceSpace(): void;
  47240. /**
  47241. * Starts rendering to the xr layer
  47242. */
  47243. runXRRenderLoop(): void;
  47244. /**
  47245. * Sets the reference space on the xr session
  47246. * @param referenceSpaceType space to set
  47247. * @returns a promise that will resolve once the reference space has been set
  47248. */
  47249. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  47250. /**
  47251. * Updates the render state of the session
  47252. * @param state state to set
  47253. * @returns a promise that resolves once the render state has been updated
  47254. */
  47255. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  47256. /**
  47257. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  47258. * @param sessionMode defines the session to test
  47259. * @returns a promise with boolean as final value
  47260. */
  47261. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47262. private _createRenderTargetTexture;
  47263. }
  47264. }
  47265. declare module BABYLON {
  47266. /**
  47267. * WebXR Camera which holds the views for the xrSession
  47268. * @see https://doc.babylonjs.com/how_to/webxr_camera
  47269. */
  47270. export class WebXRCamera extends FreeCamera {
  47271. private _xrSessionManager;
  47272. private _firstFrame;
  47273. private _referenceQuaternion;
  47274. private _referencedPosition;
  47275. private _xrInvPositionCache;
  47276. private _xrInvQuaternionCache;
  47277. /**
  47278. * Observable raised before camera teleportation
  47279. */
  47280. onBeforeCameraTeleport: Observable<Vector3>;
  47281. /**
  47282. * Observable raised after camera teleportation
  47283. */
  47284. onAfterCameraTeleport: Observable<Vector3>;
  47285. /**
  47286. * Should position compensation execute on first frame.
  47287. * This is used when copying the position from a native (non XR) camera
  47288. */
  47289. compensateOnFirstFrame: boolean;
  47290. /**
  47291. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  47292. * @param name the name of the camera
  47293. * @param scene the scene to add the camera to
  47294. * @param _xrSessionManager a constructed xr session manager
  47295. */
  47296. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  47297. /**
  47298. * Return the user's height, unrelated to the current ground.
  47299. * This will be the y position of this camera, when ground level is 0.
  47300. */
  47301. get realWorldHeight(): number;
  47302. /** @hidden */
  47303. _updateForDualEyeDebugging(): void;
  47304. /**
  47305. * Sets this camera's transformation based on a non-vr camera
  47306. * @param otherCamera the non-vr camera to copy the transformation from
  47307. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  47308. */
  47309. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  47310. /**
  47311. * Gets the current instance class name ("WebXRCamera").
  47312. * @returns the class name
  47313. */
  47314. getClassName(): string;
  47315. private _rotate180;
  47316. private _updateFromXRSession;
  47317. private _updateNumberOfRigCameras;
  47318. private _updateReferenceSpace;
  47319. private _updateReferenceSpaceOffset;
  47320. }
  47321. }
  47322. declare module BABYLON {
  47323. /**
  47324. * Defining the interface required for a (webxr) feature
  47325. */
  47326. export interface IWebXRFeature extends IDisposable {
  47327. /**
  47328. * Is this feature attached
  47329. */
  47330. attached: boolean;
  47331. /**
  47332. * Should auto-attach be disabled?
  47333. */
  47334. disableAutoAttach: boolean;
  47335. /**
  47336. * Attach the feature to the session
  47337. * Will usually be called by the features manager
  47338. *
  47339. * @param force should attachment be forced (even when already attached)
  47340. * @returns true if successful.
  47341. */
  47342. attach(force?: boolean): boolean;
  47343. /**
  47344. * Detach the feature from the session
  47345. * Will usually be called by the features manager
  47346. *
  47347. * @returns true if successful.
  47348. */
  47349. detach(): boolean;
  47350. /**
  47351. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  47352. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  47353. *
  47354. * @returns whether or not the feature is compatible in this environment
  47355. */
  47356. isCompatible(): boolean;
  47357. /**
  47358. * Was this feature disposed;
  47359. */
  47360. isDisposed: boolean;
  47361. /**
  47362. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  47363. */
  47364. xrNativeFeatureName?: string;
  47365. /**
  47366. * A list of (Babylon WebXR) features this feature depends on
  47367. */
  47368. dependsOn?: string[];
  47369. }
  47370. /**
  47371. * A list of the currently available features without referencing them
  47372. */
  47373. export class WebXRFeatureName {
  47374. /**
  47375. * The name of the anchor system feature
  47376. */
  47377. static readonly ANCHOR_SYSTEM: string;
  47378. /**
  47379. * The name of the background remover feature
  47380. */
  47381. static readonly BACKGROUND_REMOVER: string;
  47382. /**
  47383. * The name of the hit test feature
  47384. */
  47385. static readonly HIT_TEST: string;
  47386. /**
  47387. * physics impostors for xr controllers feature
  47388. */
  47389. static readonly PHYSICS_CONTROLLERS: string;
  47390. /**
  47391. * The name of the plane detection feature
  47392. */
  47393. static readonly PLANE_DETECTION: string;
  47394. /**
  47395. * The name of the pointer selection feature
  47396. */
  47397. static readonly POINTER_SELECTION: string;
  47398. /**
  47399. * The name of the teleportation feature
  47400. */
  47401. static readonly TELEPORTATION: string;
  47402. /**
  47403. * The name of the feature points feature.
  47404. */
  47405. static readonly FEATURE_POINTS: string;
  47406. /**
  47407. * The name of the hand tracking feature.
  47408. */
  47409. static readonly HAND_TRACKING: string;
  47410. }
  47411. /**
  47412. * Defining the constructor of a feature. Used to register the modules.
  47413. */
  47414. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  47415. /**
  47416. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  47417. * It is mainly used in AR sessions.
  47418. *
  47419. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  47420. */
  47421. export class WebXRFeaturesManager implements IDisposable {
  47422. private _xrSessionManager;
  47423. private static readonly _AvailableFeatures;
  47424. private _features;
  47425. /**
  47426. * constructs a new features manages.
  47427. *
  47428. * @param _xrSessionManager an instance of WebXRSessionManager
  47429. */
  47430. constructor(_xrSessionManager: WebXRSessionManager);
  47431. /**
  47432. * Used to register a module. After calling this function a developer can use this feature in the scene.
  47433. * Mainly used internally.
  47434. *
  47435. * @param featureName the name of the feature to register
  47436. * @param constructorFunction the function used to construct the module
  47437. * @param version the (babylon) version of the module
  47438. * @param stable is that a stable version of this module
  47439. */
  47440. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  47441. /**
  47442. * Returns a constructor of a specific feature.
  47443. *
  47444. * @param featureName the name of the feature to construct
  47445. * @param version the version of the feature to load
  47446. * @param xrSessionManager the xrSessionManager. Used to construct the module
  47447. * @param options optional options provided to the module.
  47448. * @returns a function that, when called, will return a new instance of this feature
  47449. */
  47450. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  47451. /**
  47452. * Can be used to return the list of features currently registered
  47453. *
  47454. * @returns an Array of available features
  47455. */
  47456. static GetAvailableFeatures(): string[];
  47457. /**
  47458. * Gets the versions available for a specific feature
  47459. * @param featureName the name of the feature
  47460. * @returns an array with the available versions
  47461. */
  47462. static GetAvailableVersions(featureName: string): string[];
  47463. /**
  47464. * Return the latest unstable version of this feature
  47465. * @param featureName the name of the feature to search
  47466. * @returns the version number. if not found will return -1
  47467. */
  47468. static GetLatestVersionOfFeature(featureName: string): number;
  47469. /**
  47470. * Return the latest stable version of this feature
  47471. * @param featureName the name of the feature to search
  47472. * @returns the version number. if not found will return -1
  47473. */
  47474. static GetStableVersionOfFeature(featureName: string): number;
  47475. /**
  47476. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  47477. * Can be used during a session to start a feature
  47478. * @param featureName the name of feature to attach
  47479. */
  47480. attachFeature(featureName: string): void;
  47481. /**
  47482. * Can be used inside a session or when the session ends to detach a specific feature
  47483. * @param featureName the name of the feature to detach
  47484. */
  47485. detachFeature(featureName: string): void;
  47486. /**
  47487. * Used to disable an already-enabled feature
  47488. * The feature will be disposed and will be recreated once enabled.
  47489. * @param featureName the feature to disable
  47490. * @returns true if disable was successful
  47491. */
  47492. disableFeature(featureName: string | {
  47493. Name: string;
  47494. }): boolean;
  47495. /**
  47496. * dispose this features manager
  47497. */
  47498. dispose(): void;
  47499. /**
  47500. * 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.
  47501. * 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.
  47502. *
  47503. * @param featureName the name of the feature to load or the class of the feature
  47504. * @param version optional version to load. if not provided the latest version will be enabled
  47505. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  47506. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  47507. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  47508. * @returns a new constructed feature or throws an error if feature not found.
  47509. */
  47510. enableFeature(featureName: string | {
  47511. Name: string;
  47512. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  47513. /**
  47514. * get the implementation of an enabled feature.
  47515. * @param featureName the name of the feature to load
  47516. * @returns the feature class, if found
  47517. */
  47518. getEnabledFeature(featureName: string): IWebXRFeature;
  47519. /**
  47520. * Get the list of enabled features
  47521. * @returns an array of enabled features
  47522. */
  47523. getEnabledFeatures(): string[];
  47524. /**
  47525. * This function will exten the session creation configuration object with enabled features.
  47526. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  47527. * according to the defined "required" variable, provided during enableFeature call
  47528. * @param xrSessionInit the xr Session init object to extend
  47529. *
  47530. * @returns an extended XRSessionInit object
  47531. */
  47532. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  47533. }
  47534. }
  47535. declare module BABYLON {
  47536. /**
  47537. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  47538. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  47539. */
  47540. export class WebXRExperienceHelper implements IDisposable {
  47541. private scene;
  47542. private _nonVRCamera;
  47543. private _originalSceneAutoClear;
  47544. private _supported;
  47545. /**
  47546. * Camera used to render xr content
  47547. */
  47548. camera: WebXRCamera;
  47549. /** A features manager for this xr session */
  47550. featuresManager: WebXRFeaturesManager;
  47551. /**
  47552. * Observers registered here will be triggered after the camera's initial transformation is set
  47553. * This can be used to set a different ground level or an extra rotation.
  47554. *
  47555. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  47556. * to the position set after this observable is done executing.
  47557. */
  47558. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  47559. /**
  47560. * Fires when the state of the experience helper has changed
  47561. */
  47562. onStateChangedObservable: Observable<WebXRState>;
  47563. /** Session manager used to keep track of xr session */
  47564. sessionManager: WebXRSessionManager;
  47565. /**
  47566. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  47567. */
  47568. state: WebXRState;
  47569. /**
  47570. * Creates a WebXRExperienceHelper
  47571. * @param scene The scene the helper should be created in
  47572. */
  47573. private constructor();
  47574. /**
  47575. * Creates the experience helper
  47576. * @param scene the scene to attach the experience helper to
  47577. * @returns a promise for the experience helper
  47578. */
  47579. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  47580. /**
  47581. * Disposes of the experience helper
  47582. */
  47583. dispose(): void;
  47584. /**
  47585. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  47586. * @param sessionMode options for the XR session
  47587. * @param referenceSpaceType frame of reference of the XR session
  47588. * @param renderTarget the output canvas that will be used to enter XR mode
  47589. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  47590. * @returns promise that resolves after xr mode has entered
  47591. */
  47592. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  47593. /**
  47594. * Exits XR mode and returns the scene to its original state
  47595. * @returns promise that resolves after xr mode has exited
  47596. */
  47597. exitXRAsync(): Promise<void>;
  47598. private _nonXRToXRCamera;
  47599. private _setState;
  47600. }
  47601. }
  47602. declare module BABYLON {
  47603. /**
  47604. * X-Y values for axes in WebXR
  47605. */
  47606. export interface IWebXRMotionControllerAxesValue {
  47607. /**
  47608. * The value of the x axis
  47609. */
  47610. x: number;
  47611. /**
  47612. * The value of the y-axis
  47613. */
  47614. y: number;
  47615. }
  47616. /**
  47617. * changed / previous values for the values of this component
  47618. */
  47619. export interface IWebXRMotionControllerComponentChangesValues<T> {
  47620. /**
  47621. * current (this frame) value
  47622. */
  47623. current: T;
  47624. /**
  47625. * previous (last change) value
  47626. */
  47627. previous: T;
  47628. }
  47629. /**
  47630. * Represents changes in the component between current frame and last values recorded
  47631. */
  47632. export interface IWebXRMotionControllerComponentChanges {
  47633. /**
  47634. * will be populated with previous and current values if axes changed
  47635. */
  47636. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  47637. /**
  47638. * will be populated with previous and current values if pressed changed
  47639. */
  47640. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47641. /**
  47642. * will be populated with previous and current values if touched changed
  47643. */
  47644. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  47645. /**
  47646. * will be populated with previous and current values if value changed
  47647. */
  47648. value?: IWebXRMotionControllerComponentChangesValues<number>;
  47649. }
  47650. /**
  47651. * This class represents a single component (for example button or thumbstick) of a motion controller
  47652. */
  47653. export class WebXRControllerComponent implements IDisposable {
  47654. /**
  47655. * the id of this component
  47656. */
  47657. id: string;
  47658. /**
  47659. * the type of the component
  47660. */
  47661. type: MotionControllerComponentType;
  47662. private _buttonIndex;
  47663. private _axesIndices;
  47664. private _axes;
  47665. private _changes;
  47666. private _currentValue;
  47667. private _hasChanges;
  47668. private _pressed;
  47669. private _touched;
  47670. /**
  47671. * button component type
  47672. */
  47673. static BUTTON_TYPE: MotionControllerComponentType;
  47674. /**
  47675. * squeeze component type
  47676. */
  47677. static SQUEEZE_TYPE: MotionControllerComponentType;
  47678. /**
  47679. * Thumbstick component type
  47680. */
  47681. static THUMBSTICK_TYPE: MotionControllerComponentType;
  47682. /**
  47683. * Touchpad component type
  47684. */
  47685. static TOUCHPAD_TYPE: MotionControllerComponentType;
  47686. /**
  47687. * trigger component type
  47688. */
  47689. static TRIGGER_TYPE: MotionControllerComponentType;
  47690. /**
  47691. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  47692. * the axes data changes
  47693. */
  47694. onAxisValueChangedObservable: Observable<{
  47695. x: number;
  47696. y: number;
  47697. }>;
  47698. /**
  47699. * Observers registered here will be triggered when the state of a button changes
  47700. * State change is either pressed / touched / value
  47701. */
  47702. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  47703. /**
  47704. * Creates a new component for a motion controller.
  47705. * It is created by the motion controller itself
  47706. *
  47707. * @param id the id of this component
  47708. * @param type the type of the component
  47709. * @param _buttonIndex index in the buttons array of the gamepad
  47710. * @param _axesIndices indices of the values in the axes array of the gamepad
  47711. */
  47712. constructor(
  47713. /**
  47714. * the id of this component
  47715. */
  47716. id: string,
  47717. /**
  47718. * the type of the component
  47719. */
  47720. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  47721. /**
  47722. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  47723. */
  47724. get axes(): IWebXRMotionControllerAxesValue;
  47725. /**
  47726. * Get the changes. Elements will be populated only if they changed with their previous and current value
  47727. */
  47728. get changes(): IWebXRMotionControllerComponentChanges;
  47729. /**
  47730. * Return whether or not the component changed the last frame
  47731. */
  47732. get hasChanges(): boolean;
  47733. /**
  47734. * is the button currently pressed
  47735. */
  47736. get pressed(): boolean;
  47737. /**
  47738. * is the button currently touched
  47739. */
  47740. get touched(): boolean;
  47741. /**
  47742. * Get the current value of this component
  47743. */
  47744. get value(): number;
  47745. /**
  47746. * Dispose this component
  47747. */
  47748. dispose(): void;
  47749. /**
  47750. * Are there axes correlating to this component
  47751. * @return true is axes data is available
  47752. */
  47753. isAxes(): boolean;
  47754. /**
  47755. * Is this component a button (hence - pressable)
  47756. * @returns true if can be pressed
  47757. */
  47758. isButton(): boolean;
  47759. /**
  47760. * update this component using the gamepad object it is in. Called on every frame
  47761. * @param nativeController the native gamepad controller object
  47762. */
  47763. update(nativeController: IMinimalMotionControllerObject): void;
  47764. }
  47765. }
  47766. declare module BABYLON {
  47767. /**
  47768. * Interface used to represent data loading progression
  47769. */
  47770. export interface ISceneLoaderProgressEvent {
  47771. /**
  47772. * Defines if data length to load can be evaluated
  47773. */
  47774. readonly lengthComputable: boolean;
  47775. /**
  47776. * Defines the loaded data length
  47777. */
  47778. readonly loaded: number;
  47779. /**
  47780. * Defines the data length to load
  47781. */
  47782. readonly total: number;
  47783. }
  47784. /**
  47785. * Interface used by SceneLoader plugins to define supported file extensions
  47786. */
  47787. export interface ISceneLoaderPluginExtensions {
  47788. /**
  47789. * Defines the list of supported extensions
  47790. */
  47791. [extension: string]: {
  47792. isBinary: boolean;
  47793. };
  47794. }
  47795. /**
  47796. * Interface used by SceneLoader plugin factory
  47797. */
  47798. export interface ISceneLoaderPluginFactory {
  47799. /**
  47800. * Defines the name of the factory
  47801. */
  47802. name: string;
  47803. /**
  47804. * Function called to create a new plugin
  47805. * @return the new plugin
  47806. */
  47807. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  47808. /**
  47809. * The callback that returns true if the data can be directly loaded.
  47810. * @param data string containing the file data
  47811. * @returns if the data can be loaded directly
  47812. */
  47813. canDirectLoad?(data: string): boolean;
  47814. }
  47815. /**
  47816. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  47817. */
  47818. export interface ISceneLoaderPluginBase {
  47819. /**
  47820. * The friendly name of this plugin.
  47821. */
  47822. name: string;
  47823. /**
  47824. * The file extensions supported by this plugin.
  47825. */
  47826. extensions: string | ISceneLoaderPluginExtensions;
  47827. /**
  47828. * The callback called when loading from a url.
  47829. * @param scene scene loading this url
  47830. * @param url url to load
  47831. * @param onSuccess callback called when the file successfully loads
  47832. * @param onProgress callback called while file is loading (if the server supports this mode)
  47833. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  47834. * @param onError callback called when the file fails to load
  47835. * @returns a file request object
  47836. */
  47837. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47838. /**
  47839. * The callback called when loading from a file object.
  47840. * @param scene scene loading this file
  47841. * @param file defines the file to load
  47842. * @param onSuccess defines the callback to call when data is loaded
  47843. * @param onProgress defines the callback to call during loading process
  47844. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  47845. * @param onError defines the callback to call when an error occurs
  47846. * @returns a file request object
  47847. */
  47848. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  47849. /**
  47850. * The callback that returns true if the data can be directly loaded.
  47851. * @param data string containing the file data
  47852. * @returns if the data can be loaded directly
  47853. */
  47854. canDirectLoad?(data: string): boolean;
  47855. /**
  47856. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  47857. * @param scene scene loading this data
  47858. * @param data string containing the data
  47859. * @returns data to pass to the plugin
  47860. */
  47861. directLoad?(scene: Scene, data: string): any;
  47862. /**
  47863. * The callback that allows custom handling of the root url based on the response url.
  47864. * @param rootUrl the original root url
  47865. * @param responseURL the response url if available
  47866. * @returns the new root url
  47867. */
  47868. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  47869. }
  47870. /**
  47871. * Interface used to define a SceneLoader plugin
  47872. */
  47873. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  47874. /**
  47875. * Import meshes into a scene.
  47876. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47877. * @param scene The scene to import into
  47878. * @param data The data to import
  47879. * @param rootUrl The root url for scene and resources
  47880. * @param meshes The meshes array to import into
  47881. * @param particleSystems The particle systems array to import into
  47882. * @param skeletons The skeletons array to import into
  47883. * @param onError The callback when import fails
  47884. * @returns True if successful or false otherwise
  47885. */
  47886. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  47887. /**
  47888. * Load into a scene.
  47889. * @param scene The scene to load into
  47890. * @param data The data to import
  47891. * @param rootUrl The root url for scene and resources
  47892. * @param onError The callback when import fails
  47893. * @returns True if successful or false otherwise
  47894. */
  47895. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  47896. /**
  47897. * Load into an asset container.
  47898. * @param scene The scene to load into
  47899. * @param data The data to import
  47900. * @param rootUrl The root url for scene and resources
  47901. * @param onError The callback when import fails
  47902. * @returns The loaded asset container
  47903. */
  47904. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  47905. }
  47906. /**
  47907. * Interface used to define an async SceneLoader plugin
  47908. */
  47909. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  47910. /**
  47911. * Import meshes into a scene.
  47912. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  47913. * @param scene The scene to import into
  47914. * @param data The data to import
  47915. * @param rootUrl The root url for scene and resources
  47916. * @param onProgress The callback when the load progresses
  47917. * @param fileName Defines the name of the file to load
  47918. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  47919. */
  47920. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  47921. meshes: AbstractMesh[];
  47922. particleSystems: IParticleSystem[];
  47923. skeletons: Skeleton[];
  47924. animationGroups: AnimationGroup[];
  47925. }>;
  47926. /**
  47927. * Load into a scene.
  47928. * @param scene The scene to load into
  47929. * @param data The data to import
  47930. * @param rootUrl The root url for scene and resources
  47931. * @param onProgress The callback when the load progresses
  47932. * @param fileName Defines the name of the file to load
  47933. * @returns Nothing
  47934. */
  47935. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  47936. /**
  47937. * Load into an asset container.
  47938. * @param scene The scene to load into
  47939. * @param data The data to import
  47940. * @param rootUrl The root url for scene and resources
  47941. * @param onProgress The callback when the load progresses
  47942. * @param fileName Defines the name of the file to load
  47943. * @returns The loaded asset container
  47944. */
  47945. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  47946. }
  47947. /**
  47948. * Mode that determines how to handle old animation groups before loading new ones.
  47949. */
  47950. export enum SceneLoaderAnimationGroupLoadingMode {
  47951. /**
  47952. * Reset all old animations to initial state then dispose them.
  47953. */
  47954. Clean = 0,
  47955. /**
  47956. * Stop all old animations.
  47957. */
  47958. Stop = 1,
  47959. /**
  47960. * Restart old animations from first frame.
  47961. */
  47962. Sync = 2,
  47963. /**
  47964. * Old animations remains untouched.
  47965. */
  47966. NoSync = 3
  47967. }
  47968. /**
  47969. * Defines a plugin registered by the SceneLoader
  47970. */
  47971. interface IRegisteredPlugin {
  47972. /**
  47973. * Defines the plugin to use
  47974. */
  47975. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  47976. /**
  47977. * Defines if the plugin supports binary data
  47978. */
  47979. isBinary: boolean;
  47980. }
  47981. /**
  47982. * Class used to load scene from various file formats using registered plugins
  47983. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  47984. */
  47985. export class SceneLoader {
  47986. /**
  47987. * No logging while loading
  47988. */
  47989. static readonly NO_LOGGING: number;
  47990. /**
  47991. * Minimal logging while loading
  47992. */
  47993. static readonly MINIMAL_LOGGING: number;
  47994. /**
  47995. * Summary logging while loading
  47996. */
  47997. static readonly SUMMARY_LOGGING: number;
  47998. /**
  47999. * Detailled logging while loading
  48000. */
  48001. static readonly DETAILED_LOGGING: number;
  48002. /**
  48003. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48004. */
  48005. static get ForceFullSceneLoadingForIncremental(): boolean;
  48006. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48007. /**
  48008. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48009. */
  48010. static get ShowLoadingScreen(): boolean;
  48011. static set ShowLoadingScreen(value: boolean);
  48012. /**
  48013. * Defines the current logging level (while loading the scene)
  48014. * @ignorenaming
  48015. */
  48016. static get loggingLevel(): number;
  48017. static set loggingLevel(value: number);
  48018. /**
  48019. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48020. */
  48021. static get CleanBoneMatrixWeights(): boolean;
  48022. static set CleanBoneMatrixWeights(value: boolean);
  48023. /**
  48024. * Event raised when a plugin is used to load a scene
  48025. */
  48026. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48027. private static _registeredPlugins;
  48028. private static _showingLoadingScreen;
  48029. /**
  48030. * Gets the default plugin (used to load Babylon files)
  48031. * @returns the .babylon plugin
  48032. */
  48033. static GetDefaultPlugin(): IRegisteredPlugin;
  48034. private static _GetPluginForExtension;
  48035. private static _GetPluginForDirectLoad;
  48036. private static _GetPluginForFilename;
  48037. private static _GetDirectLoad;
  48038. private static _LoadData;
  48039. private static _GetFileInfo;
  48040. /**
  48041. * Gets a plugin that can load the given extension
  48042. * @param extension defines the extension to load
  48043. * @returns a plugin or null if none works
  48044. */
  48045. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48046. /**
  48047. * Gets a boolean indicating that the given extension can be loaded
  48048. * @param extension defines the extension to load
  48049. * @returns true if the extension is supported
  48050. */
  48051. static IsPluginForExtensionAvailable(extension: string): boolean;
  48052. /**
  48053. * Adds a new plugin to the list of registered plugins
  48054. * @param plugin defines the plugin to add
  48055. */
  48056. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48057. /**
  48058. * Import meshes into a scene
  48059. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48060. * @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)
  48061. * @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)
  48062. * @param scene the instance of BABYLON.Scene to append to
  48063. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  48064. * @param onProgress a callback with a progress event for each file being loaded
  48065. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48066. * @param pluginExtension the extension used to determine the plugin
  48067. * @returns The loaded plugin
  48068. */
  48069. 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>;
  48070. /**
  48071. * Import meshes into a scene
  48072. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48073. * @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)
  48074. * @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)
  48075. * @param scene the instance of BABYLON.Scene to append to
  48076. * @param onProgress a callback with a progress event for each file being loaded
  48077. * @param pluginExtension the extension used to determine the plugin
  48078. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48079. */
  48080. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48081. meshes: AbstractMesh[];
  48082. particleSystems: IParticleSystem[];
  48083. skeletons: Skeleton[];
  48084. animationGroups: AnimationGroup[];
  48085. }>;
  48086. /**
  48087. * Load a scene
  48088. * @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)
  48089. * @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)
  48090. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48091. * @param onSuccess a callback with the scene when import succeeds
  48092. * @param onProgress a callback with a progress event for each file being loaded
  48093. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48094. * @param pluginExtension the extension used to determine the plugin
  48095. * @returns The loaded plugin
  48096. */
  48097. 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>;
  48098. /**
  48099. * Load a scene
  48100. * @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)
  48101. * @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)
  48102. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48103. * @param onProgress a callback with a progress event for each file being loaded
  48104. * @param pluginExtension the extension used to determine the plugin
  48105. * @returns The loaded scene
  48106. */
  48107. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48108. /**
  48109. * Append a scene
  48110. * @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)
  48111. * @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)
  48112. * @param scene is the instance of BABYLON.Scene to append to
  48113. * @param onSuccess a callback with the scene when import succeeds
  48114. * @param onProgress a callback with a progress event for each file being loaded
  48115. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48116. * @param pluginExtension the extension used to determine the plugin
  48117. * @returns The loaded plugin
  48118. */
  48119. 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>;
  48120. /**
  48121. * Append a scene
  48122. * @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)
  48123. * @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)
  48124. * @param scene is the instance of BABYLON.Scene to append to
  48125. * @param onProgress a callback with a progress event for each file being loaded
  48126. * @param pluginExtension the extension used to determine the plugin
  48127. * @returns The given scene
  48128. */
  48129. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48130. /**
  48131. * Load a scene into an asset container
  48132. * @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)
  48133. * @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)
  48134. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48135. * @param onSuccess a callback with the scene when import succeeds
  48136. * @param onProgress a callback with a progress event for each file being loaded
  48137. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48138. * @param pluginExtension the extension used to determine the plugin
  48139. * @returns The loaded plugin
  48140. */
  48141. 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>;
  48142. /**
  48143. * Load a scene into an asset container
  48144. * @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)
  48145. * @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)
  48146. * @param scene is the instance of Scene to append to
  48147. * @param onProgress a callback with a progress event for each file being loaded
  48148. * @param pluginExtension the extension used to determine the plugin
  48149. * @returns The loaded asset container
  48150. */
  48151. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48152. /**
  48153. * Import animations from a file into a scene
  48154. * @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)
  48155. * @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)
  48156. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48157. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48158. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48159. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48160. * @param onSuccess a callback with the scene when import succeeds
  48161. * @param onProgress a callback with a progress event for each file being loaded
  48162. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48163. * @param pluginExtension the extension used to determine the plugin
  48164. */
  48165. 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;
  48166. /**
  48167. * Import animations from a file into a scene
  48168. * @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)
  48169. * @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)
  48170. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48171. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48172. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48173. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48174. * @param onSuccess a callback with the scene when import succeeds
  48175. * @param onProgress a callback with a progress event for each file being loaded
  48176. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48177. * @param pluginExtension the extension used to determine the plugin
  48178. * @returns the updated scene with imported animations
  48179. */
  48180. 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>;
  48181. }
  48182. }
  48183. declare module BABYLON {
  48184. /**
  48185. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48186. */
  48187. export type MotionControllerHandedness = "none" | "left" | "right";
  48188. /**
  48189. * The type of components available in motion controllers.
  48190. * This is not the name of the component.
  48191. */
  48192. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48193. /**
  48194. * The state of a controller component
  48195. */
  48196. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48197. /**
  48198. * The schema of motion controller layout.
  48199. * No object will be initialized using this interface
  48200. * This is used just to define the profile.
  48201. */
  48202. export interface IMotionControllerLayout {
  48203. /**
  48204. * Path to load the assets. Usually relative to the base path
  48205. */
  48206. assetPath: string;
  48207. /**
  48208. * Available components (unsorted)
  48209. */
  48210. components: {
  48211. /**
  48212. * A map of component Ids
  48213. */
  48214. [componentId: string]: {
  48215. /**
  48216. * The type of input the component outputs
  48217. */
  48218. type: MotionControllerComponentType;
  48219. /**
  48220. * The indices of this component in the gamepad object
  48221. */
  48222. gamepadIndices: {
  48223. /**
  48224. * Index of button
  48225. */
  48226. button?: number;
  48227. /**
  48228. * If available, index of x-axis
  48229. */
  48230. xAxis?: number;
  48231. /**
  48232. * If available, index of y-axis
  48233. */
  48234. yAxis?: number;
  48235. };
  48236. /**
  48237. * The mesh's root node name
  48238. */
  48239. rootNodeName: string;
  48240. /**
  48241. * Animation definitions for this model
  48242. */
  48243. visualResponses: {
  48244. [stateKey: string]: {
  48245. /**
  48246. * What property will be animated
  48247. */
  48248. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48249. /**
  48250. * What states influence this visual response
  48251. */
  48252. states: MotionControllerComponentStateType[];
  48253. /**
  48254. * Type of animation - movement or visibility
  48255. */
  48256. valueNodeProperty: "transform" | "visibility";
  48257. /**
  48258. * Base node name to move. Its position will be calculated according to the min and max nodes
  48259. */
  48260. valueNodeName?: string;
  48261. /**
  48262. * Minimum movement node
  48263. */
  48264. minNodeName?: string;
  48265. /**
  48266. * Max movement node
  48267. */
  48268. maxNodeName?: string;
  48269. };
  48270. };
  48271. /**
  48272. * If touch enabled, what is the name of node to display user feedback
  48273. */
  48274. touchPointNodeName?: string;
  48275. };
  48276. };
  48277. /**
  48278. * Is it xr standard mapping or not
  48279. */
  48280. gamepadMapping: "" | "xr-standard";
  48281. /**
  48282. * Base root node of this entire model
  48283. */
  48284. rootNodeName: string;
  48285. /**
  48286. * Defines the main button component id
  48287. */
  48288. selectComponentId: string;
  48289. }
  48290. /**
  48291. * A definition for the layout map in the input profile
  48292. */
  48293. export interface IMotionControllerLayoutMap {
  48294. /**
  48295. * Layouts with handedness type as a key
  48296. */
  48297. [handedness: string]: IMotionControllerLayout;
  48298. }
  48299. /**
  48300. * The XR Input profile schema
  48301. * Profiles can be found here:
  48302. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  48303. */
  48304. export interface IMotionControllerProfile {
  48305. /**
  48306. * fallback profiles for this profileId
  48307. */
  48308. fallbackProfileIds: string[];
  48309. /**
  48310. * The layout map, with handedness as key
  48311. */
  48312. layouts: IMotionControllerLayoutMap;
  48313. /**
  48314. * The id of this profile
  48315. * correlates to the profile(s) in the xrInput.profiles array
  48316. */
  48317. profileId: string;
  48318. }
  48319. /**
  48320. * A helper-interface for the 3 meshes needed for controller button animation
  48321. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  48322. */
  48323. export interface IMotionControllerButtonMeshMap {
  48324. /**
  48325. * the mesh that defines the pressed value mesh position.
  48326. * This is used to find the max-position of this button
  48327. */
  48328. pressedMesh: AbstractMesh;
  48329. /**
  48330. * the mesh that defines the unpressed value mesh position.
  48331. * This is used to find the min (or initial) position of this button
  48332. */
  48333. unpressedMesh: AbstractMesh;
  48334. /**
  48335. * The mesh that will be changed when value changes
  48336. */
  48337. valueMesh: AbstractMesh;
  48338. }
  48339. /**
  48340. * A helper-interface for the 3 meshes needed for controller axis animation.
  48341. * This will be expanded when touchpad animations are fully supported
  48342. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  48343. */
  48344. export interface IMotionControllerMeshMap {
  48345. /**
  48346. * the mesh that defines the maximum value mesh position.
  48347. */
  48348. maxMesh?: AbstractMesh;
  48349. /**
  48350. * the mesh that defines the minimum value mesh position.
  48351. */
  48352. minMesh?: AbstractMesh;
  48353. /**
  48354. * The mesh that will be changed when axis value changes
  48355. */
  48356. valueMesh?: AbstractMesh;
  48357. }
  48358. /**
  48359. * The elements needed for change-detection of the gamepad objects in motion controllers
  48360. */
  48361. export interface IMinimalMotionControllerObject {
  48362. /**
  48363. * Available axes of this controller
  48364. */
  48365. axes: number[];
  48366. /**
  48367. * An array of available buttons
  48368. */
  48369. buttons: Array<{
  48370. /**
  48371. * Value of the button/trigger
  48372. */
  48373. value: number;
  48374. /**
  48375. * If the button/trigger is currently touched
  48376. */
  48377. touched: boolean;
  48378. /**
  48379. * If the button/trigger is currently pressed
  48380. */
  48381. pressed: boolean;
  48382. }>;
  48383. /**
  48384. * EXPERIMENTAL haptic support.
  48385. */
  48386. hapticActuators?: Array<{
  48387. pulse: (value: number, duration: number) => Promise<boolean>;
  48388. }>;
  48389. }
  48390. /**
  48391. * An Abstract Motion controller
  48392. * This class receives an xrInput and a profile layout and uses those to initialize the components
  48393. * Each component has an observable to check for changes in value and state
  48394. */
  48395. export abstract class WebXRAbstractMotionController implements IDisposable {
  48396. protected scene: Scene;
  48397. protected layout: IMotionControllerLayout;
  48398. /**
  48399. * The gamepad object correlating to this controller
  48400. */
  48401. gamepadObject: IMinimalMotionControllerObject;
  48402. /**
  48403. * handedness (left/right/none) of this controller
  48404. */
  48405. handedness: MotionControllerHandedness;
  48406. private _initComponent;
  48407. private _modelReady;
  48408. /**
  48409. * A map of components (WebXRControllerComponent) in this motion controller
  48410. * Components have a ComponentType and can also have both button and axis definitions
  48411. */
  48412. readonly components: {
  48413. [id: string]: WebXRControllerComponent;
  48414. };
  48415. /**
  48416. * Disable the model's animation. Can be set at any time.
  48417. */
  48418. disableAnimation: boolean;
  48419. /**
  48420. * Observers registered here will be triggered when the model of this controller is done loading
  48421. */
  48422. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  48423. /**
  48424. * The profile id of this motion controller
  48425. */
  48426. abstract profileId: string;
  48427. /**
  48428. * The root mesh of the model. It is null if the model was not yet initialized
  48429. */
  48430. rootMesh: Nullable<AbstractMesh>;
  48431. /**
  48432. * constructs a new abstract motion controller
  48433. * @param scene the scene to which the model of the controller will be added
  48434. * @param layout The profile layout to load
  48435. * @param gamepadObject The gamepad object correlating to this controller
  48436. * @param handedness handedness (left/right/none) of this controller
  48437. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  48438. */
  48439. constructor(scene: Scene, layout: IMotionControllerLayout,
  48440. /**
  48441. * The gamepad object correlating to this controller
  48442. */
  48443. gamepadObject: IMinimalMotionControllerObject,
  48444. /**
  48445. * handedness (left/right/none) of this controller
  48446. */
  48447. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  48448. /**
  48449. * Dispose this controller, the model mesh and all its components
  48450. */
  48451. dispose(): void;
  48452. /**
  48453. * Returns all components of specific type
  48454. * @param type the type to search for
  48455. * @return an array of components with this type
  48456. */
  48457. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  48458. /**
  48459. * get a component based an its component id as defined in layout.components
  48460. * @param id the id of the component
  48461. * @returns the component correlates to the id or undefined if not found
  48462. */
  48463. getComponent(id: string): WebXRControllerComponent;
  48464. /**
  48465. * Get the list of components available in this motion controller
  48466. * @returns an array of strings correlating to available components
  48467. */
  48468. getComponentIds(): string[];
  48469. /**
  48470. * Get the first component of specific type
  48471. * @param type type of component to find
  48472. * @return a controller component or null if not found
  48473. */
  48474. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  48475. /**
  48476. * Get the main (Select) component of this controller as defined in the layout
  48477. * @returns the main component of this controller
  48478. */
  48479. getMainComponent(): WebXRControllerComponent;
  48480. /**
  48481. * Loads the model correlating to this controller
  48482. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  48483. * @returns A promise fulfilled with the result of the model loading
  48484. */
  48485. loadModel(): Promise<boolean>;
  48486. /**
  48487. * Update this model using the current XRFrame
  48488. * @param xrFrame the current xr frame to use and update the model
  48489. */
  48490. updateFromXRFrame(xrFrame: XRFrame): void;
  48491. /**
  48492. * Backwards compatibility due to a deeply-integrated typo
  48493. */
  48494. get handness(): XREye;
  48495. /**
  48496. * Pulse (vibrate) this controller
  48497. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  48498. * Consecutive calls to this function will cancel the last pulse call
  48499. *
  48500. * @param value the strength of the pulse in 0.0...1.0 range
  48501. * @param duration Duration of the pulse in milliseconds
  48502. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  48503. * @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
  48504. */
  48505. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  48506. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48507. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  48508. /**
  48509. * Moves the axis on the controller mesh based on its current state
  48510. * @param axis the index of the axis
  48511. * @param axisValue the value of the axis which determines the meshes new position
  48512. * @hidden
  48513. */
  48514. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  48515. /**
  48516. * Update the model itself with the current frame data
  48517. * @param xrFrame the frame to use for updating the model mesh
  48518. */
  48519. protected updateModel(xrFrame: XRFrame): void;
  48520. /**
  48521. * Get the filename and path for this controller's model
  48522. * @returns a map of filename and path
  48523. */
  48524. protected abstract _getFilenameAndPath(): {
  48525. filename: string;
  48526. path: string;
  48527. };
  48528. /**
  48529. * This function is called before the mesh is loaded. It checks for loading constraints.
  48530. * For example, this function can check if the GLB loader is available
  48531. * If this function returns false, the generic controller will be loaded instead
  48532. * @returns Is the client ready to load the mesh
  48533. */
  48534. protected abstract _getModelLoadingConstraints(): boolean;
  48535. /**
  48536. * This function will be called after the model was successfully loaded and can be used
  48537. * for mesh transformations before it is available for the user
  48538. * @param meshes the loaded meshes
  48539. */
  48540. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  48541. /**
  48542. * Set the root mesh for this controller. Important for the WebXR controller class
  48543. * @param meshes the loaded meshes
  48544. */
  48545. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  48546. /**
  48547. * A function executed each frame that updates the mesh (if needed)
  48548. * @param xrFrame the current xrFrame
  48549. */
  48550. protected abstract _updateModel(xrFrame: XRFrame): void;
  48551. private _getGenericFilenameAndPath;
  48552. private _getGenericParentMesh;
  48553. }
  48554. }
  48555. declare module BABYLON {
  48556. /**
  48557. * A generic trigger-only motion controller for WebXR
  48558. */
  48559. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  48560. /**
  48561. * Static version of the profile id of this controller
  48562. */
  48563. static ProfileId: string;
  48564. profileId: string;
  48565. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  48566. protected _getFilenameAndPath(): {
  48567. filename: string;
  48568. path: string;
  48569. };
  48570. protected _getModelLoadingConstraints(): boolean;
  48571. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  48572. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48573. protected _updateModel(): void;
  48574. }
  48575. }
  48576. declare module BABYLON {
  48577. /**
  48578. * Class containing static functions to help procedurally build meshes
  48579. */
  48580. export class SphereBuilder {
  48581. /**
  48582. * Creates a sphere mesh
  48583. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  48584. * * 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`)
  48585. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  48586. * * 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
  48587. * * 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)
  48588. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48589. * * 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
  48590. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48591. * @param name defines the name of the mesh
  48592. * @param options defines the options used to create the mesh
  48593. * @param scene defines the hosting scene
  48594. * @returns the sphere mesh
  48595. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  48596. */
  48597. static CreateSphere(name: string, options: {
  48598. segments?: number;
  48599. diameter?: number;
  48600. diameterX?: number;
  48601. diameterY?: number;
  48602. diameterZ?: number;
  48603. arc?: number;
  48604. slice?: number;
  48605. sideOrientation?: number;
  48606. frontUVs?: Vector4;
  48607. backUVs?: Vector4;
  48608. updatable?: boolean;
  48609. }, scene?: Nullable<Scene>): Mesh;
  48610. }
  48611. }
  48612. declare module BABYLON {
  48613. /**
  48614. * A profiled motion controller has its profile loaded from an online repository.
  48615. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  48616. */
  48617. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  48618. private _repositoryUrl;
  48619. private _buttonMeshMapping;
  48620. private _touchDots;
  48621. /**
  48622. * The profile ID of this controller. Will be populated when the controller initializes.
  48623. */
  48624. profileId: string;
  48625. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  48626. dispose(): void;
  48627. protected _getFilenameAndPath(): {
  48628. filename: string;
  48629. path: string;
  48630. };
  48631. protected _getModelLoadingConstraints(): boolean;
  48632. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  48633. protected _setRootMesh(meshes: AbstractMesh[]): void;
  48634. protected _updateModel(_xrFrame: XRFrame): void;
  48635. }
  48636. }
  48637. declare module BABYLON {
  48638. /**
  48639. * A construction function type to create a new controller based on an xrInput object
  48640. */
  48641. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  48642. /**
  48643. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  48644. *
  48645. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  48646. * it should be replaced with auto-loaded controllers.
  48647. *
  48648. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  48649. */
  48650. export class WebXRMotionControllerManager {
  48651. private static _AvailableControllers;
  48652. private static _Fallbacks;
  48653. private static _ProfileLoadingPromises;
  48654. private static _ProfilesList;
  48655. /**
  48656. * The base URL of the online controller repository. Can be changed at any time.
  48657. */
  48658. static BaseRepositoryUrl: string;
  48659. /**
  48660. * Which repository gets priority - local or online
  48661. */
  48662. static PrioritizeOnlineRepository: boolean;
  48663. /**
  48664. * Use the online repository, or use only locally-defined controllers
  48665. */
  48666. static UseOnlineRepository: boolean;
  48667. /**
  48668. * Clear the cache used for profile loading and reload when requested again
  48669. */
  48670. static ClearProfilesCache(): void;
  48671. /**
  48672. * Register the default fallbacks.
  48673. * This function is called automatically when this file is imported.
  48674. */
  48675. static DefaultFallbacks(): void;
  48676. /**
  48677. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  48678. * @param profileId the profile to which a fallback needs to be found
  48679. * @return an array with corresponding fallback profiles
  48680. */
  48681. static FindFallbackWithProfileId(profileId: string): string[];
  48682. /**
  48683. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  48684. * The order of search:
  48685. *
  48686. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  48687. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  48688. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  48689. * 4) return the generic trigger controller if none were found
  48690. *
  48691. * @param xrInput the xrInput to which a new controller is initialized
  48692. * @param scene the scene to which the model will be added
  48693. * @param forceProfile force a certain profile for this controller
  48694. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  48695. */
  48696. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  48697. /**
  48698. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  48699. *
  48700. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  48701. *
  48702. * @param type the profile type to register
  48703. * @param constructFunction the function to be called when loading this profile
  48704. */
  48705. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  48706. /**
  48707. * Register a fallback to a specific profile.
  48708. * @param profileId the profileId that will receive the fallbacks
  48709. * @param fallbacks A list of fallback profiles
  48710. */
  48711. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  48712. /**
  48713. * Will update the list of profiles available in the repository
  48714. * @return a promise that resolves to a map of profiles available online
  48715. */
  48716. static UpdateProfilesList(): Promise<{
  48717. [profile: string]: string;
  48718. }>;
  48719. private static _LoadProfileFromRepository;
  48720. private static _LoadProfilesFromAvailableControllers;
  48721. }
  48722. }
  48723. declare module BABYLON {
  48724. /**
  48725. * Configuration options for the WebXR controller creation
  48726. */
  48727. export interface IWebXRControllerOptions {
  48728. /**
  48729. * Should the controller mesh be animated when a user interacts with it
  48730. * The pressed buttons / thumbstick and touchpad animations will be disabled
  48731. */
  48732. disableMotionControllerAnimation?: boolean;
  48733. /**
  48734. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  48735. */
  48736. doNotLoadControllerMesh?: boolean;
  48737. /**
  48738. * Force a specific controller type for this controller.
  48739. * This can be used when creating your own profile or when testing different controllers
  48740. */
  48741. forceControllerProfile?: string;
  48742. /**
  48743. * Defines a rendering group ID for meshes that will be loaded.
  48744. * This is for the default controllers only.
  48745. */
  48746. renderingGroupId?: number;
  48747. }
  48748. /**
  48749. * Represents an XR controller
  48750. */
  48751. export class WebXRInputSource {
  48752. private _scene;
  48753. /** The underlying input source for the controller */
  48754. inputSource: XRInputSource;
  48755. private _options;
  48756. private _tmpVector;
  48757. private _uniqueId;
  48758. private _disposed;
  48759. /**
  48760. * 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
  48761. */
  48762. grip?: AbstractMesh;
  48763. /**
  48764. * If available, this is the gamepad object related to this controller.
  48765. * Using this object it is possible to get click events and trackpad changes of the
  48766. * webxr controller that is currently being used.
  48767. */
  48768. motionController?: WebXRAbstractMotionController;
  48769. /**
  48770. * Event that fires when the controller is removed/disposed.
  48771. * The object provided as event data is this controller, after associated assets were disposed.
  48772. * uniqueId is still available.
  48773. */
  48774. onDisposeObservable: Observable<WebXRInputSource>;
  48775. /**
  48776. * Will be triggered when the mesh associated with the motion controller is done loading.
  48777. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  48778. * A shortened version of controller -> motion controller -> on mesh loaded.
  48779. */
  48780. onMeshLoadedObservable: Observable<AbstractMesh>;
  48781. /**
  48782. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  48783. */
  48784. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  48785. /**
  48786. * Pointer which can be used to select objects or attach a visible laser to
  48787. */
  48788. pointer: AbstractMesh;
  48789. /**
  48790. * Creates the input source object
  48791. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  48792. * @param _scene the scene which the controller should be associated to
  48793. * @param inputSource the underlying input source for the controller
  48794. * @param _options options for this controller creation
  48795. */
  48796. constructor(_scene: Scene,
  48797. /** The underlying input source for the controller */
  48798. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  48799. /**
  48800. * Get this controllers unique id
  48801. */
  48802. get uniqueId(): string;
  48803. /**
  48804. * Disposes of the object
  48805. */
  48806. dispose(): void;
  48807. /**
  48808. * Gets a world space ray coming from the pointer or grip
  48809. * @param result the resulting ray
  48810. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  48811. */
  48812. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  48813. /**
  48814. * Updates the controller pose based on the given XRFrame
  48815. * @param xrFrame xr frame to update the pose with
  48816. * @param referenceSpace reference space to use
  48817. */
  48818. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  48819. }
  48820. }
  48821. declare module BABYLON {
  48822. /**
  48823. * The schema for initialization options of the XR Input class
  48824. */
  48825. export interface IWebXRInputOptions {
  48826. /**
  48827. * If set to true no model will be automatically loaded
  48828. */
  48829. doNotLoadControllerMeshes?: boolean;
  48830. /**
  48831. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  48832. * If not found, the xr input profile data will be used.
  48833. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  48834. */
  48835. forceInputProfile?: string;
  48836. /**
  48837. * Do not send a request to the controller repository to load the profile.
  48838. *
  48839. * Instead, use the controllers available in babylon itself.
  48840. */
  48841. disableOnlineControllerRepository?: boolean;
  48842. /**
  48843. * A custom URL for the controllers repository
  48844. */
  48845. customControllersRepositoryURL?: string;
  48846. /**
  48847. * Should the controller model's components not move according to the user input
  48848. */
  48849. disableControllerAnimation?: boolean;
  48850. /**
  48851. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  48852. */
  48853. controllerOptions?: IWebXRControllerOptions;
  48854. }
  48855. /**
  48856. * XR input used to track XR inputs such as controllers/rays
  48857. */
  48858. export class WebXRInput implements IDisposable {
  48859. /**
  48860. * the xr session manager for this session
  48861. */
  48862. xrSessionManager: WebXRSessionManager;
  48863. /**
  48864. * the WebXR camera for this session. Mainly used for teleportation
  48865. */
  48866. xrCamera: WebXRCamera;
  48867. private readonly options;
  48868. /**
  48869. * XR controllers being tracked
  48870. */
  48871. controllers: Array<WebXRInputSource>;
  48872. private _frameObserver;
  48873. private _sessionEndedObserver;
  48874. private _sessionInitObserver;
  48875. /**
  48876. * Event when a controller has been connected/added
  48877. */
  48878. onControllerAddedObservable: Observable<WebXRInputSource>;
  48879. /**
  48880. * Event when a controller has been removed/disconnected
  48881. */
  48882. onControllerRemovedObservable: Observable<WebXRInputSource>;
  48883. /**
  48884. * Initializes the WebXRInput
  48885. * @param xrSessionManager the xr session manager for this session
  48886. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  48887. * @param options = initialization options for this xr input
  48888. */
  48889. constructor(
  48890. /**
  48891. * the xr session manager for this session
  48892. */
  48893. xrSessionManager: WebXRSessionManager,
  48894. /**
  48895. * the WebXR camera for this session. Mainly used for teleportation
  48896. */
  48897. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  48898. private _onInputSourcesChange;
  48899. private _addAndRemoveControllers;
  48900. /**
  48901. * Disposes of the object
  48902. */
  48903. dispose(): void;
  48904. }
  48905. }
  48906. declare module BABYLON {
  48907. /**
  48908. * This is the base class for all WebXR features.
  48909. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  48910. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  48911. */
  48912. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  48913. protected _xrSessionManager: WebXRSessionManager;
  48914. private _attached;
  48915. private _removeOnDetach;
  48916. /**
  48917. * Is this feature disposed?
  48918. */
  48919. isDisposed: boolean;
  48920. /**
  48921. * Should auto-attach be disabled?
  48922. */
  48923. disableAutoAttach: boolean;
  48924. /**
  48925. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  48926. */
  48927. xrNativeFeatureName: string;
  48928. /**
  48929. * Construct a new (abstract) WebXR feature
  48930. * @param _xrSessionManager the xr session manager for this feature
  48931. */
  48932. constructor(_xrSessionManager: WebXRSessionManager);
  48933. /**
  48934. * Is this feature attached
  48935. */
  48936. get attached(): boolean;
  48937. /**
  48938. * attach this feature
  48939. *
  48940. * @param force should attachment be forced (even when already attached)
  48941. * @returns true if successful, false is failed or already attached
  48942. */
  48943. attach(force?: boolean): boolean;
  48944. /**
  48945. * detach this feature.
  48946. *
  48947. * @returns true if successful, false if failed or already detached
  48948. */
  48949. detach(): boolean;
  48950. /**
  48951. * Dispose this feature and all of the resources attached
  48952. */
  48953. dispose(): void;
  48954. /**
  48955. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  48956. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  48957. *
  48958. * @returns whether or not the feature is compatible in this environment
  48959. */
  48960. isCompatible(): boolean;
  48961. /**
  48962. * This is used to register callbacks that will automatically be removed when detach is called.
  48963. * @param observable the observable to which the observer will be attached
  48964. * @param callback the callback to register
  48965. */
  48966. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  48967. /**
  48968. * Code in this function will be executed on each xrFrame received from the browser.
  48969. * This function will not execute after the feature is detached.
  48970. * @param _xrFrame the current frame
  48971. */
  48972. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  48973. }
  48974. }
  48975. declare module BABYLON {
  48976. /**
  48977. * Renders a layer on top of an existing scene
  48978. */
  48979. export class UtilityLayerRenderer implements IDisposable {
  48980. /** the original scene that will be rendered on top of */
  48981. originalScene: Scene;
  48982. private _pointerCaptures;
  48983. private _lastPointerEvents;
  48984. private static _DefaultUtilityLayer;
  48985. private static _DefaultKeepDepthUtilityLayer;
  48986. private _sharedGizmoLight;
  48987. private _renderCamera;
  48988. /**
  48989. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  48990. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  48991. * @returns the camera that is used when rendering the utility layer
  48992. */
  48993. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  48994. /**
  48995. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  48996. * @param cam the camera that should be used when rendering the utility layer
  48997. */
  48998. setRenderCamera(cam: Nullable<Camera>): void;
  48999. /**
  49000. * @hidden
  49001. * Light which used by gizmos to get light shading
  49002. */
  49003. _getSharedGizmoLight(): HemisphericLight;
  49004. /**
  49005. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49006. */
  49007. pickUtilitySceneFirst: boolean;
  49008. /**
  49009. * 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)
  49010. */
  49011. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49012. /**
  49013. * 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)
  49014. */
  49015. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49016. /**
  49017. * The scene that is rendered on top of the original scene
  49018. */
  49019. utilityLayerScene: Scene;
  49020. /**
  49021. * If the utility layer should automatically be rendered on top of existing scene
  49022. */
  49023. shouldRender: boolean;
  49024. /**
  49025. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49026. */
  49027. onlyCheckPointerDownEvents: boolean;
  49028. /**
  49029. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49030. */
  49031. processAllEvents: boolean;
  49032. /**
  49033. * Observable raised when the pointer move from the utility layer scene to the main scene
  49034. */
  49035. onPointerOutObservable: Observable<number>;
  49036. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49037. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49038. private _afterRenderObserver;
  49039. private _sceneDisposeObserver;
  49040. private _originalPointerObserver;
  49041. /**
  49042. * Instantiates a UtilityLayerRenderer
  49043. * @param originalScene the original scene that will be rendered on top of
  49044. * @param handleEvents boolean indicating if the utility layer should handle events
  49045. */
  49046. constructor(
  49047. /** the original scene that will be rendered on top of */
  49048. originalScene: Scene, handleEvents?: boolean);
  49049. private _notifyObservers;
  49050. /**
  49051. * Renders the utility layers scene on top of the original scene
  49052. */
  49053. render(): void;
  49054. /**
  49055. * Disposes of the renderer
  49056. */
  49057. dispose(): void;
  49058. private _updateCamera;
  49059. }
  49060. }
  49061. declare module BABYLON {
  49062. /**
  49063. * Options interface for the pointer selection module
  49064. */
  49065. export interface IWebXRControllerPointerSelectionOptions {
  49066. /**
  49067. * if provided, this scene will be used to render meshes.
  49068. */
  49069. customUtilityLayerScene?: Scene;
  49070. /**
  49071. * 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)
  49072. * If not disabled, the last picked point will be used to execute a pointer up event
  49073. * If disabled, pointer up event will be triggered right after the pointer down event.
  49074. * Used in screen and gaze target ray mode only
  49075. */
  49076. disablePointerUpOnTouchOut: boolean;
  49077. /**
  49078. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  49079. */
  49080. forceGazeMode: boolean;
  49081. /**
  49082. * 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
  49083. * to start a new countdown to the pointer down event.
  49084. * Defaults to 1.
  49085. */
  49086. gazeModePointerMovedFactor?: number;
  49087. /**
  49088. * Different button type to use instead of the main component
  49089. */
  49090. overrideButtonId?: string;
  49091. /**
  49092. * use this rendering group id for the meshes (optional)
  49093. */
  49094. renderingGroupId?: number;
  49095. /**
  49096. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49097. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49098. * 3000 means 3 seconds between pointing at something and selecting it
  49099. */
  49100. timeToSelect?: number;
  49101. /**
  49102. * Should meshes created here be added to a utility layer or the main scene
  49103. */
  49104. useUtilityLayer?: boolean;
  49105. /**
  49106. * Optional WebXR camera to be used for gaze selection
  49107. */
  49108. gazeCamera?: WebXRCamera;
  49109. /**
  49110. * the xr input to use with this pointer selection
  49111. */
  49112. xrInput: WebXRInput;
  49113. }
  49114. /**
  49115. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49116. */
  49117. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49118. private readonly _options;
  49119. private static _idCounter;
  49120. private _attachController;
  49121. private _controllers;
  49122. private _scene;
  49123. private _tmpVectorForPickCompare;
  49124. /**
  49125. * The module's name
  49126. */
  49127. static readonly Name: string;
  49128. /**
  49129. * The (Babylon) version of this module.
  49130. * This is an integer representing the implementation version.
  49131. * This number does not correspond to the WebXR specs version
  49132. */
  49133. static readonly Version: number;
  49134. /**
  49135. * Disable lighting on the laser pointer (so it will always be visible)
  49136. */
  49137. disablePointerLighting: boolean;
  49138. /**
  49139. * Disable lighting on the selection mesh (so it will always be visible)
  49140. */
  49141. disableSelectionMeshLighting: boolean;
  49142. /**
  49143. * Should the laser pointer be displayed
  49144. */
  49145. displayLaserPointer: boolean;
  49146. /**
  49147. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49148. */
  49149. displaySelectionMesh: boolean;
  49150. /**
  49151. * This color will be set to the laser pointer when selection is triggered
  49152. */
  49153. laserPointerPickedColor: Color3;
  49154. /**
  49155. * Default color of the laser pointer
  49156. */
  49157. laserPointerDefaultColor: Color3;
  49158. /**
  49159. * default color of the selection ring
  49160. */
  49161. selectionMeshDefaultColor: Color3;
  49162. /**
  49163. * This color will be applied to the selection ring when selection is triggered
  49164. */
  49165. selectionMeshPickedColor: Color3;
  49166. /**
  49167. * Optional filter to be used for ray selection. This predicate shares behavior with
  49168. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49169. */
  49170. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49171. /**
  49172. * constructs a new background remover module
  49173. * @param _xrSessionManager the session manager for this module
  49174. * @param _options read-only options to be used in this module
  49175. */
  49176. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49177. /**
  49178. * attach this feature
  49179. * Will usually be called by the features manager
  49180. *
  49181. * @returns true if successful.
  49182. */
  49183. attach(): boolean;
  49184. /**
  49185. * detach this feature.
  49186. * Will usually be called by the features manager
  49187. *
  49188. * @returns true if successful.
  49189. */
  49190. detach(): boolean;
  49191. /**
  49192. * Will get the mesh under a specific pointer.
  49193. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49194. * @param controllerId the controllerId to check
  49195. * @returns The mesh under pointer or null if no mesh is under the pointer
  49196. */
  49197. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49198. /**
  49199. * Get the xr controller that correlates to the pointer id in the pointer event
  49200. *
  49201. * @param id the pointer id to search for
  49202. * @returns the controller that correlates to this id or null if not found
  49203. */
  49204. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49205. protected _onXRFrame(_xrFrame: XRFrame): void;
  49206. private _attachGazeMode;
  49207. private _attachScreenRayMode;
  49208. private _attachTrackedPointerRayMode;
  49209. private _convertNormalToDirectionOfRay;
  49210. private _detachController;
  49211. private _generateNewMeshPair;
  49212. private _pickingMoved;
  49213. private _updatePointerDistance;
  49214. /** @hidden */
  49215. get lasterPointerDefaultColor(): Color3;
  49216. }
  49217. }
  49218. declare module BABYLON {
  49219. /**
  49220. * Button which can be used to enter a different mode of XR
  49221. */
  49222. export class WebXREnterExitUIButton {
  49223. /** button element */
  49224. element: HTMLElement;
  49225. /** XR initialization options for the button */
  49226. sessionMode: XRSessionMode;
  49227. /** Reference space type */
  49228. referenceSpaceType: XRReferenceSpaceType;
  49229. /**
  49230. * Creates a WebXREnterExitUIButton
  49231. * @param element button element
  49232. * @param sessionMode XR initialization session mode
  49233. * @param referenceSpaceType the type of reference space to be used
  49234. */
  49235. constructor(
  49236. /** button element */
  49237. element: HTMLElement,
  49238. /** XR initialization options for the button */
  49239. sessionMode: XRSessionMode,
  49240. /** Reference space type */
  49241. referenceSpaceType: XRReferenceSpaceType);
  49242. /**
  49243. * Extendable function which can be used to update the button's visuals when the state changes
  49244. * @param activeButton the current active button in the UI
  49245. */
  49246. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49247. }
  49248. /**
  49249. * Options to create the webXR UI
  49250. */
  49251. export class WebXREnterExitUIOptions {
  49252. /**
  49253. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  49254. */
  49255. customButtons?: Array<WebXREnterExitUIButton>;
  49256. /**
  49257. * A reference space type to use when creating the default button.
  49258. * Default is local-floor
  49259. */
  49260. referenceSpaceType?: XRReferenceSpaceType;
  49261. /**
  49262. * Context to enter xr with
  49263. */
  49264. renderTarget?: Nullable<WebXRRenderTarget>;
  49265. /**
  49266. * A session mode to use when creating the default button.
  49267. * Default is immersive-vr
  49268. */
  49269. sessionMode?: XRSessionMode;
  49270. /**
  49271. * A list of optional features to init the session with
  49272. */
  49273. optionalFeatures?: string[];
  49274. /**
  49275. * A list of optional features to init the session with
  49276. */
  49277. requiredFeatures?: string[];
  49278. }
  49279. /**
  49280. * UI to allow the user to enter/exit XR mode
  49281. */
  49282. export class WebXREnterExitUI implements IDisposable {
  49283. private scene;
  49284. /** version of the options passed to this UI */
  49285. options: WebXREnterExitUIOptions;
  49286. private _activeButton;
  49287. private _buttons;
  49288. /**
  49289. * The HTML Div Element to which buttons are added.
  49290. */
  49291. readonly overlay: HTMLDivElement;
  49292. /**
  49293. * Fired every time the active button is changed.
  49294. *
  49295. * When xr is entered via a button that launches xr that button will be the callback parameter
  49296. *
  49297. * When exiting xr the callback parameter will be null)
  49298. */
  49299. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  49300. /**
  49301. *
  49302. * @param scene babylon scene object to use
  49303. * @param options (read-only) version of the options passed to this UI
  49304. */
  49305. private constructor();
  49306. /**
  49307. * Creates UI to allow the user to enter/exit XR mode
  49308. * @param scene the scene to add the ui to
  49309. * @param helper the xr experience helper to enter/exit xr with
  49310. * @param options options to configure the UI
  49311. * @returns the created ui
  49312. */
  49313. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  49314. /**
  49315. * Disposes of the XR UI component
  49316. */
  49317. dispose(): void;
  49318. private _updateButtons;
  49319. }
  49320. }
  49321. declare module BABYLON {
  49322. /**
  49323. * Class containing static functions to help procedurally build meshes
  49324. */
  49325. export class LinesBuilder {
  49326. /**
  49327. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  49328. * * 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
  49329. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  49330. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  49331. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  49332. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  49333. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49334. * * 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
  49335. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  49336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49337. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  49338. * @param name defines the name of the new line system
  49339. * @param options defines the options used to create the line system
  49340. * @param scene defines the hosting scene
  49341. * @returns a new line system mesh
  49342. */
  49343. static CreateLineSystem(name: string, options: {
  49344. lines: Vector3[][];
  49345. updatable?: boolean;
  49346. instance?: Nullable<LinesMesh>;
  49347. colors?: Nullable<Color4[][]>;
  49348. useVertexAlpha?: boolean;
  49349. }, scene: Nullable<Scene>): LinesMesh;
  49350. /**
  49351. * Creates a line mesh
  49352. * 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
  49353. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49354. * * The parameter `points` is an array successive Vector3
  49355. * * 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
  49356. * * The optional parameter `colors` is an array of successive Color4, one per line point
  49357. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  49358. * * When updating an instance, remember that only point positions can change, not the number of points
  49359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  49361. * @param name defines the name of the new line system
  49362. * @param options defines the options used to create the line system
  49363. * @param scene defines the hosting scene
  49364. * @returns a new line mesh
  49365. */
  49366. static CreateLines(name: string, options: {
  49367. points: Vector3[];
  49368. updatable?: boolean;
  49369. instance?: Nullable<LinesMesh>;
  49370. colors?: Color4[];
  49371. useVertexAlpha?: boolean;
  49372. }, scene?: Nullable<Scene>): LinesMesh;
  49373. /**
  49374. * Creates a dashed line mesh
  49375. * * 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
  49376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  49377. * * The parameter `points` is an array successive Vector3
  49378. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  49379. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  49380. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  49381. * * 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
  49382. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  49383. * * When updating an instance, remember that only point positions can change, not the number of points
  49384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49385. * @param name defines the name of the mesh
  49386. * @param options defines the options used to create the mesh
  49387. * @param scene defines the hosting scene
  49388. * @returns the dashed line mesh
  49389. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  49390. */
  49391. static CreateDashedLines(name: string, options: {
  49392. points: Vector3[];
  49393. dashSize?: number;
  49394. gapSize?: number;
  49395. dashNb?: number;
  49396. updatable?: boolean;
  49397. instance?: LinesMesh;
  49398. useVertexAlpha?: boolean;
  49399. }, scene?: Nullable<Scene>): LinesMesh;
  49400. }
  49401. }
  49402. declare module BABYLON {
  49403. /**
  49404. * Construction options for a timer
  49405. */
  49406. export interface ITimerOptions<T> {
  49407. /**
  49408. * Time-to-end
  49409. */
  49410. timeout: number;
  49411. /**
  49412. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  49413. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  49414. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  49415. */
  49416. contextObservable: Observable<T>;
  49417. /**
  49418. * Optional parameters when adding an observer to the observable
  49419. */
  49420. observableParameters?: {
  49421. mask?: number;
  49422. insertFirst?: boolean;
  49423. scope?: any;
  49424. };
  49425. /**
  49426. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  49427. */
  49428. breakCondition?: (data?: ITimerData<T>) => boolean;
  49429. /**
  49430. * Will be triggered when the time condition has met
  49431. */
  49432. onEnded?: (data: ITimerData<any>) => void;
  49433. /**
  49434. * Will be triggered when the break condition has met (prematurely ended)
  49435. */
  49436. onAborted?: (data: ITimerData<any>) => void;
  49437. /**
  49438. * Optional function to execute on each tick (or count)
  49439. */
  49440. onTick?: (data: ITimerData<any>) => void;
  49441. }
  49442. /**
  49443. * An interface defining the data sent by the timer
  49444. */
  49445. export interface ITimerData<T> {
  49446. /**
  49447. * When did it start
  49448. */
  49449. startTime: number;
  49450. /**
  49451. * Time now
  49452. */
  49453. currentTime: number;
  49454. /**
  49455. * Time passed since started
  49456. */
  49457. deltaTime: number;
  49458. /**
  49459. * How much is completed, in [0.0...1.0].
  49460. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  49461. */
  49462. completeRate: number;
  49463. /**
  49464. * What the registered observable sent in the last count
  49465. */
  49466. payload: T;
  49467. }
  49468. /**
  49469. * The current state of the timer
  49470. */
  49471. export enum TimerState {
  49472. /**
  49473. * Timer initialized, not yet started
  49474. */
  49475. INIT = 0,
  49476. /**
  49477. * Timer started and counting
  49478. */
  49479. STARTED = 1,
  49480. /**
  49481. * Timer ended (whether aborted or time reached)
  49482. */
  49483. ENDED = 2
  49484. }
  49485. /**
  49486. * A simple version of the timer. Will take options and start the timer immediately after calling it
  49487. *
  49488. * @param options options with which to initialize this timer
  49489. */
  49490. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  49491. /**
  49492. * An advanced implementation of a timer class
  49493. */
  49494. export class AdvancedTimer<T = any> implements IDisposable {
  49495. /**
  49496. * Will notify each time the timer calculates the remaining time
  49497. */
  49498. onEachCountObservable: Observable<ITimerData<T>>;
  49499. /**
  49500. * Will trigger when the timer was aborted due to the break condition
  49501. */
  49502. onTimerAbortedObservable: Observable<ITimerData<T>>;
  49503. /**
  49504. * Will trigger when the timer ended successfully
  49505. */
  49506. onTimerEndedObservable: Observable<ITimerData<T>>;
  49507. /**
  49508. * Will trigger when the timer state has changed
  49509. */
  49510. onStateChangedObservable: Observable<TimerState>;
  49511. private _observer;
  49512. private _contextObservable;
  49513. private _observableParameters;
  49514. private _startTime;
  49515. private _timer;
  49516. private _state;
  49517. private _breakCondition;
  49518. private _timeToEnd;
  49519. private _breakOnNextTick;
  49520. /**
  49521. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  49522. * @param options construction options for this advanced timer
  49523. */
  49524. constructor(options: ITimerOptions<T>);
  49525. /**
  49526. * set a breaking condition for this timer. Default is to never break during count
  49527. * @param predicate the new break condition. Returns true to break, false otherwise
  49528. */
  49529. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  49530. /**
  49531. * Reset ALL associated observables in this advanced timer
  49532. */
  49533. clearObservables(): void;
  49534. /**
  49535. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  49536. *
  49537. * @param timeToEnd how much time to measure until timer ended
  49538. */
  49539. start(timeToEnd?: number): void;
  49540. /**
  49541. * Will force a stop on the next tick.
  49542. */
  49543. stop(): void;
  49544. /**
  49545. * Dispose this timer, clearing all resources
  49546. */
  49547. dispose(): void;
  49548. private _setState;
  49549. private _tick;
  49550. private _stop;
  49551. }
  49552. }
  49553. declare module BABYLON {
  49554. /**
  49555. * The options container for the teleportation module
  49556. */
  49557. export interface IWebXRTeleportationOptions {
  49558. /**
  49559. * if provided, this scene will be used to render meshes.
  49560. */
  49561. customUtilityLayerScene?: Scene;
  49562. /**
  49563. * Values to configure the default target mesh
  49564. */
  49565. defaultTargetMeshOptions?: {
  49566. /**
  49567. * Fill color of the teleportation area
  49568. */
  49569. teleportationFillColor?: string;
  49570. /**
  49571. * Border color for the teleportation area
  49572. */
  49573. teleportationBorderColor?: string;
  49574. /**
  49575. * Disable the mesh's animation sequence
  49576. */
  49577. disableAnimation?: boolean;
  49578. /**
  49579. * Disable lighting on the material or the ring and arrow
  49580. */
  49581. disableLighting?: boolean;
  49582. /**
  49583. * Override the default material of the torus and arrow
  49584. */
  49585. torusArrowMaterial?: Material;
  49586. };
  49587. /**
  49588. * A list of meshes to use as floor meshes.
  49589. * Meshes can be added and removed after initializing the feature using the
  49590. * addFloorMesh and removeFloorMesh functions
  49591. * If empty, rotation will still work
  49592. */
  49593. floorMeshes?: AbstractMesh[];
  49594. /**
  49595. * use this rendering group id for the meshes (optional)
  49596. */
  49597. renderingGroupId?: number;
  49598. /**
  49599. * Should teleportation move only to snap points
  49600. */
  49601. snapPointsOnly?: boolean;
  49602. /**
  49603. * An array of points to which the teleportation will snap to.
  49604. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  49605. */
  49606. snapPositions?: Vector3[];
  49607. /**
  49608. * How close should the teleportation ray be in order to snap to position.
  49609. * Default to 0.8 units (meters)
  49610. */
  49611. snapToPositionRadius?: number;
  49612. /**
  49613. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  49614. * If you want to support rotation, make sure your mesh has a direction indicator.
  49615. *
  49616. * When left untouched, the default mesh will be initialized.
  49617. */
  49618. teleportationTargetMesh?: AbstractMesh;
  49619. /**
  49620. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  49621. */
  49622. timeToTeleport?: number;
  49623. /**
  49624. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  49625. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  49626. */
  49627. useMainComponentOnly?: boolean;
  49628. /**
  49629. * Should meshes created here be added to a utility layer or the main scene
  49630. */
  49631. useUtilityLayer?: boolean;
  49632. /**
  49633. * Babylon XR Input class for controller
  49634. */
  49635. xrInput: WebXRInput;
  49636. /**
  49637. * Meshes that the teleportation ray cannot go through
  49638. */
  49639. pickBlockerMeshes?: AbstractMesh[];
  49640. }
  49641. /**
  49642. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  49643. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  49644. * the input of the attached controllers.
  49645. */
  49646. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  49647. private _options;
  49648. private _controllers;
  49649. private _currentTeleportationControllerId;
  49650. private _floorMeshes;
  49651. private _quadraticBezierCurve;
  49652. private _selectionFeature;
  49653. private _snapToPositions;
  49654. private _snappedToPoint;
  49655. private _teleportationRingMaterial?;
  49656. private _tmpRay;
  49657. private _tmpVector;
  49658. private _tmpQuaternion;
  49659. /**
  49660. * The module's name
  49661. */
  49662. static readonly Name: string;
  49663. /**
  49664. * The (Babylon) version of this module.
  49665. * This is an integer representing the implementation version.
  49666. * This number does not correspond to the webxr specs version
  49667. */
  49668. static readonly Version: number;
  49669. /**
  49670. * Is movement backwards enabled
  49671. */
  49672. backwardsMovementEnabled: boolean;
  49673. /**
  49674. * Distance to travel when moving backwards
  49675. */
  49676. backwardsTeleportationDistance: number;
  49677. /**
  49678. * The distance from the user to the inspection point in the direction of the controller
  49679. * A higher number will allow the user to move further
  49680. * defaults to 5 (meters, in xr units)
  49681. */
  49682. parabolicCheckRadius: number;
  49683. /**
  49684. * Should the module support parabolic ray on top of direct ray
  49685. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  49686. * Very helpful when moving between floors / different heights
  49687. */
  49688. parabolicRayEnabled: boolean;
  49689. /**
  49690. * How much rotation should be applied when rotating right and left
  49691. */
  49692. rotationAngle: number;
  49693. /**
  49694. * Is rotation enabled when moving forward?
  49695. * Disabling this feature will prevent the user from deciding the direction when teleporting
  49696. */
  49697. rotationEnabled: boolean;
  49698. /**
  49699. * constructs a new anchor system
  49700. * @param _xrSessionManager an instance of WebXRSessionManager
  49701. * @param _options configuration object for this feature
  49702. */
  49703. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  49704. /**
  49705. * Get the snapPointsOnly flag
  49706. */
  49707. get snapPointsOnly(): boolean;
  49708. /**
  49709. * Sets the snapPointsOnly flag
  49710. * @param snapToPoints should teleportation be exclusively to snap points
  49711. */
  49712. set snapPointsOnly(snapToPoints: boolean);
  49713. /**
  49714. * Add a new mesh to the floor meshes array
  49715. * @param mesh the mesh to use as floor mesh
  49716. */
  49717. addFloorMesh(mesh: AbstractMesh): void;
  49718. /**
  49719. * Add a new snap-to point to fix teleportation to this position
  49720. * @param newSnapPoint The new Snap-To point
  49721. */
  49722. addSnapPoint(newSnapPoint: Vector3): void;
  49723. attach(): boolean;
  49724. detach(): boolean;
  49725. dispose(): void;
  49726. /**
  49727. * Remove a mesh from the floor meshes array
  49728. * @param mesh the mesh to remove
  49729. */
  49730. removeFloorMesh(mesh: AbstractMesh): void;
  49731. /**
  49732. * Remove a mesh from the floor meshes array using its name
  49733. * @param name the mesh name to remove
  49734. */
  49735. removeFloorMeshByName(name: string): void;
  49736. /**
  49737. * 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
  49738. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  49739. * @returns was the point found and removed or not
  49740. */
  49741. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  49742. /**
  49743. * This function sets a selection feature that will be disabled when
  49744. * the forward ray is shown and will be reattached when hidden.
  49745. * This is used to remove the selection rays when moving.
  49746. * @param selectionFeature the feature to disable when forward movement is enabled
  49747. */
  49748. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  49749. protected _onXRFrame(_xrFrame: XRFrame): void;
  49750. private _attachController;
  49751. private _createDefaultTargetMesh;
  49752. private _detachController;
  49753. private _findClosestSnapPointWithRadius;
  49754. private _setTargetMeshPosition;
  49755. private _setTargetMeshVisibility;
  49756. private _showParabolicPath;
  49757. private _teleportForward;
  49758. }
  49759. }
  49760. declare module BABYLON {
  49761. /**
  49762. * Options for the default xr helper
  49763. */
  49764. export class WebXRDefaultExperienceOptions {
  49765. /**
  49766. * Enable or disable default UI to enter XR
  49767. */
  49768. disableDefaultUI?: boolean;
  49769. /**
  49770. * Should teleportation not initialize. defaults to false.
  49771. */
  49772. disableTeleportation?: boolean;
  49773. /**
  49774. * Floor meshes that will be used for teleport
  49775. */
  49776. floorMeshes?: Array<AbstractMesh>;
  49777. /**
  49778. * If set to true, the first frame will not be used to reset position
  49779. * The first frame is mainly used when copying transformation from the old camera
  49780. * Mainly used in AR
  49781. */
  49782. ignoreNativeCameraTransformation?: boolean;
  49783. /**
  49784. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  49785. */
  49786. inputOptions?: IWebXRInputOptions;
  49787. /**
  49788. * optional configuration for the output canvas
  49789. */
  49790. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  49791. /**
  49792. * optional UI options. This can be used among other to change session mode and reference space type
  49793. */
  49794. uiOptions?: WebXREnterExitUIOptions;
  49795. /**
  49796. * When loading teleportation and pointer select, use stable versions instead of latest.
  49797. */
  49798. useStablePlugins?: boolean;
  49799. /**
  49800. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  49801. */
  49802. renderingGroupId?: number;
  49803. /**
  49804. * A list of optional features to init the session with
  49805. * If set to true, all features we support will be added
  49806. */
  49807. optionalFeatures?: boolean | string[];
  49808. }
  49809. /**
  49810. * Default experience which provides a similar setup to the previous webVRExperience
  49811. */
  49812. export class WebXRDefaultExperience {
  49813. /**
  49814. * Base experience
  49815. */
  49816. baseExperience: WebXRExperienceHelper;
  49817. /**
  49818. * Enables ui for entering/exiting xr
  49819. */
  49820. enterExitUI: WebXREnterExitUI;
  49821. /**
  49822. * Input experience extension
  49823. */
  49824. input: WebXRInput;
  49825. /**
  49826. * Enables laser pointer and selection
  49827. */
  49828. pointerSelection: WebXRControllerPointerSelection;
  49829. /**
  49830. * Default target xr should render to
  49831. */
  49832. renderTarget: WebXRRenderTarget;
  49833. /**
  49834. * Enables teleportation
  49835. */
  49836. teleportation: WebXRMotionControllerTeleportation;
  49837. private constructor();
  49838. /**
  49839. * Creates the default xr experience
  49840. * @param scene scene
  49841. * @param options options for basic configuration
  49842. * @returns resulting WebXRDefaultExperience
  49843. */
  49844. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  49845. /**
  49846. * DIsposes of the experience helper
  49847. */
  49848. dispose(): void;
  49849. }
  49850. }
  49851. declare module BABYLON {
  49852. /**
  49853. * Options to modify the vr teleportation behavior.
  49854. */
  49855. export interface VRTeleportationOptions {
  49856. /**
  49857. * The name of the mesh which should be used as the teleportation floor. (default: null)
  49858. */
  49859. floorMeshName?: string;
  49860. /**
  49861. * A list of meshes to be used as the teleportation floor. (default: empty)
  49862. */
  49863. floorMeshes?: Mesh[];
  49864. /**
  49865. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  49866. */
  49867. teleportationMode?: number;
  49868. /**
  49869. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  49870. */
  49871. teleportationTime?: number;
  49872. /**
  49873. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  49874. */
  49875. teleportationSpeed?: number;
  49876. /**
  49877. * The easing function used in the animation or null for Linear. (default CircleEase)
  49878. */
  49879. easingFunction?: EasingFunction;
  49880. }
  49881. /**
  49882. * Options to modify the vr experience helper's behavior.
  49883. */
  49884. export interface VRExperienceHelperOptions extends WebVROptions {
  49885. /**
  49886. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  49887. */
  49888. createDeviceOrientationCamera?: boolean;
  49889. /**
  49890. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  49891. */
  49892. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  49893. /**
  49894. * Uses the main button on the controller to toggle the laser casted. (default: true)
  49895. */
  49896. laserToggle?: boolean;
  49897. /**
  49898. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  49899. */
  49900. floorMeshes?: Mesh[];
  49901. /**
  49902. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  49903. */
  49904. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  49905. /**
  49906. * Defines if WebXR should be used instead of WebVR (if available)
  49907. */
  49908. useXR?: boolean;
  49909. }
  49910. /**
  49911. * Event containing information after VR has been entered
  49912. */
  49913. export class OnAfterEnteringVRObservableEvent {
  49914. /**
  49915. * If entering vr was successful
  49916. */
  49917. success: boolean;
  49918. }
  49919. /**
  49920. * Helps to quickly add VR support to an existing scene.
  49921. * See https://doc.babylonjs.com/how_to/webvr_helper
  49922. */
  49923. export class VRExperienceHelper {
  49924. /** Options to modify the vr experience helper's behavior. */
  49925. webVROptions: VRExperienceHelperOptions;
  49926. private _scene;
  49927. private _position;
  49928. private _btnVR;
  49929. private _btnVRDisplayed;
  49930. private _webVRsupported;
  49931. private _webVRready;
  49932. private _webVRrequesting;
  49933. private _webVRpresenting;
  49934. private _hasEnteredVR;
  49935. private _fullscreenVRpresenting;
  49936. private _inputElement;
  49937. private _webVRCamera;
  49938. private _vrDeviceOrientationCamera;
  49939. private _deviceOrientationCamera;
  49940. private _existingCamera;
  49941. private _onKeyDown;
  49942. private _onVrDisplayPresentChange;
  49943. private _onVRDisplayChanged;
  49944. private _onVRRequestPresentStart;
  49945. private _onVRRequestPresentComplete;
  49946. /**
  49947. * 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)
  49948. */
  49949. enableGazeEvenWhenNoPointerLock: boolean;
  49950. /**
  49951. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  49952. */
  49953. exitVROnDoubleTap: boolean;
  49954. /**
  49955. * Observable raised right before entering VR.
  49956. */
  49957. onEnteringVRObservable: Observable<VRExperienceHelper>;
  49958. /**
  49959. * Observable raised when entering VR has completed.
  49960. */
  49961. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  49962. /**
  49963. * Observable raised when exiting VR.
  49964. */
  49965. onExitingVRObservable: Observable<VRExperienceHelper>;
  49966. /**
  49967. * Observable raised when controller mesh is loaded.
  49968. */
  49969. onControllerMeshLoadedObservable: Observable<WebVRController>;
  49970. /** Return this.onEnteringVRObservable
  49971. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  49972. */
  49973. get onEnteringVR(): Observable<VRExperienceHelper>;
  49974. /** Return this.onExitingVRObservable
  49975. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  49976. */
  49977. get onExitingVR(): Observable<VRExperienceHelper>;
  49978. /** Return this.onControllerMeshLoadedObservable
  49979. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  49980. */
  49981. get onControllerMeshLoaded(): Observable<WebVRController>;
  49982. private _rayLength;
  49983. private _useCustomVRButton;
  49984. private _teleportationRequested;
  49985. private _teleportActive;
  49986. private _floorMeshName;
  49987. private _floorMeshesCollection;
  49988. private _teleportationMode;
  49989. private _teleportationTime;
  49990. private _teleportationSpeed;
  49991. private _teleportationEasing;
  49992. private _rotationAllowed;
  49993. private _teleportBackwardsVector;
  49994. private _teleportationTarget;
  49995. private _isDefaultTeleportationTarget;
  49996. private _postProcessMove;
  49997. private _teleportationFillColor;
  49998. private _teleportationBorderColor;
  49999. private _rotationAngle;
  50000. private _haloCenter;
  50001. private _cameraGazer;
  50002. private _padSensibilityUp;
  50003. private _padSensibilityDown;
  50004. private _leftController;
  50005. private _rightController;
  50006. private _gazeColor;
  50007. private _laserColor;
  50008. private _pickedLaserColor;
  50009. private _pickedGazeColor;
  50010. /**
  50011. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50012. */
  50013. onNewMeshSelected: Observable<AbstractMesh>;
  50014. /**
  50015. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50016. * This observable will provide the mesh and the controller used to select the mesh
  50017. */
  50018. onMeshSelectedWithController: Observable<{
  50019. mesh: AbstractMesh;
  50020. controller: WebVRController;
  50021. }>;
  50022. /**
  50023. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50024. */
  50025. onNewMeshPicked: Observable<PickingInfo>;
  50026. private _circleEase;
  50027. /**
  50028. * Observable raised before camera teleportation
  50029. */
  50030. onBeforeCameraTeleport: Observable<Vector3>;
  50031. /**
  50032. * Observable raised after camera teleportation
  50033. */
  50034. onAfterCameraTeleport: Observable<Vector3>;
  50035. /**
  50036. * Observable raised when current selected mesh gets unselected
  50037. */
  50038. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50039. private _raySelectionPredicate;
  50040. /**
  50041. * To be optionaly changed by user to define custom ray selection
  50042. */
  50043. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50044. /**
  50045. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50046. */
  50047. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50048. /**
  50049. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50050. */
  50051. teleportationEnabled: boolean;
  50052. private _defaultHeight;
  50053. private _teleportationInitialized;
  50054. private _interactionsEnabled;
  50055. private _interactionsRequested;
  50056. private _displayGaze;
  50057. private _displayLaserPointer;
  50058. /**
  50059. * The mesh used to display where the user is going to teleport.
  50060. */
  50061. get teleportationTarget(): Mesh;
  50062. /**
  50063. * Sets the mesh to be used to display where the user is going to teleport.
  50064. */
  50065. set teleportationTarget(value: Mesh);
  50066. /**
  50067. * 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
  50068. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50069. * See https://doc.babylonjs.com/resources/baking_transformations
  50070. */
  50071. get gazeTrackerMesh(): Mesh;
  50072. set gazeTrackerMesh(value: Mesh);
  50073. /**
  50074. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50075. */
  50076. updateGazeTrackerScale: boolean;
  50077. /**
  50078. * If the gaze trackers color should be updated when selecting meshes
  50079. */
  50080. updateGazeTrackerColor: boolean;
  50081. /**
  50082. * If the controller laser color should be updated when selecting meshes
  50083. */
  50084. updateControllerLaserColor: boolean;
  50085. /**
  50086. * The gaze tracking mesh corresponding to the left controller
  50087. */
  50088. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50089. /**
  50090. * The gaze tracking mesh corresponding to the right controller
  50091. */
  50092. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50093. /**
  50094. * If the ray of the gaze should be displayed.
  50095. */
  50096. get displayGaze(): boolean;
  50097. /**
  50098. * Sets if the ray of the gaze should be displayed.
  50099. */
  50100. set displayGaze(value: boolean);
  50101. /**
  50102. * If the ray of the LaserPointer should be displayed.
  50103. */
  50104. get displayLaserPointer(): boolean;
  50105. /**
  50106. * Sets if the ray of the LaserPointer should be displayed.
  50107. */
  50108. set displayLaserPointer(value: boolean);
  50109. /**
  50110. * The deviceOrientationCamera used as the camera when not in VR.
  50111. */
  50112. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50113. /**
  50114. * Based on the current WebVR support, returns the current VR camera used.
  50115. */
  50116. get currentVRCamera(): Nullable<Camera>;
  50117. /**
  50118. * The webVRCamera which is used when in VR.
  50119. */
  50120. get webVRCamera(): WebVRFreeCamera;
  50121. /**
  50122. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50123. */
  50124. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50125. /**
  50126. * The html button that is used to trigger entering into VR.
  50127. */
  50128. get vrButton(): Nullable<HTMLButtonElement>;
  50129. private get _teleportationRequestInitiated();
  50130. /**
  50131. * Defines whether or not Pointer lock should be requested when switching to
  50132. * full screen.
  50133. */
  50134. requestPointerLockOnFullScreen: boolean;
  50135. /**
  50136. * If asking to force XR, this will be populated with the default xr experience
  50137. */
  50138. xr: WebXRDefaultExperience;
  50139. /**
  50140. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50141. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50142. */
  50143. xrTestDone: boolean;
  50144. /**
  50145. * Instantiates a VRExperienceHelper.
  50146. * Helps to quickly add VR support to an existing scene.
  50147. * @param scene The scene the VRExperienceHelper belongs to.
  50148. * @param webVROptions Options to modify the vr experience helper's behavior.
  50149. */
  50150. constructor(scene: Scene,
  50151. /** Options to modify the vr experience helper's behavior. */
  50152. webVROptions?: VRExperienceHelperOptions);
  50153. private completeVRInit;
  50154. private _onDefaultMeshLoaded;
  50155. private _onResize;
  50156. private _onFullscreenChange;
  50157. /**
  50158. * Gets a value indicating if we are currently in VR mode.
  50159. */
  50160. get isInVRMode(): boolean;
  50161. private onVrDisplayPresentChange;
  50162. private onVRDisplayChanged;
  50163. private moveButtonToBottomRight;
  50164. private displayVRButton;
  50165. private updateButtonVisibility;
  50166. private _cachedAngularSensibility;
  50167. /**
  50168. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50169. * Otherwise, will use the fullscreen API.
  50170. */
  50171. enterVR(): void;
  50172. /**
  50173. * Attempt to exit VR, or fullscreen.
  50174. */
  50175. exitVR(): void;
  50176. /**
  50177. * The position of the vr experience helper.
  50178. */
  50179. get position(): Vector3;
  50180. /**
  50181. * Sets the position of the vr experience helper.
  50182. */
  50183. set position(value: Vector3);
  50184. /**
  50185. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50186. */
  50187. enableInteractions(): void;
  50188. private get _noControllerIsActive();
  50189. private beforeRender;
  50190. private _isTeleportationFloor;
  50191. /**
  50192. * Adds a floor mesh to be used for teleportation.
  50193. * @param floorMesh the mesh to be used for teleportation.
  50194. */
  50195. addFloorMesh(floorMesh: Mesh): void;
  50196. /**
  50197. * Removes a floor mesh from being used for teleportation.
  50198. * @param floorMesh the mesh to be removed.
  50199. */
  50200. removeFloorMesh(floorMesh: Mesh): void;
  50201. /**
  50202. * Enables interactions and teleportation using the VR controllers and gaze.
  50203. * @param vrTeleportationOptions options to modify teleportation behavior.
  50204. */
  50205. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50206. private _onNewGamepadConnected;
  50207. private _tryEnableInteractionOnController;
  50208. private _onNewGamepadDisconnected;
  50209. private _enableInteractionOnController;
  50210. private _checkTeleportWithRay;
  50211. private _checkRotate;
  50212. private _checkTeleportBackwards;
  50213. private _enableTeleportationOnController;
  50214. private _createTeleportationCircles;
  50215. private _displayTeleportationTarget;
  50216. private _hideTeleportationTarget;
  50217. private _rotateCamera;
  50218. private _moveTeleportationSelectorTo;
  50219. private _workingVector;
  50220. private _workingQuaternion;
  50221. private _workingMatrix;
  50222. /**
  50223. * Time Constant Teleportation Mode
  50224. */
  50225. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  50226. /**
  50227. * Speed Constant Teleportation Mode
  50228. */
  50229. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  50230. /**
  50231. * Teleports the users feet to the desired location
  50232. * @param location The location where the user's feet should be placed
  50233. */
  50234. teleportCamera(location: Vector3): void;
  50235. private _convertNormalToDirectionOfRay;
  50236. private _castRayAndSelectObject;
  50237. private _notifySelectedMeshUnselected;
  50238. /**
  50239. * Permanently set new colors for the laser pointer
  50240. * @param color the new laser color
  50241. * @param pickedColor the new laser color when picked mesh detected
  50242. */
  50243. setLaserColor(color: Color3, pickedColor?: Color3): void;
  50244. /**
  50245. * Set lighting enabled / disabled on the laser pointer of both controllers
  50246. * @param enabled should the lighting be enabled on the laser pointer
  50247. */
  50248. setLaserLightingState(enabled?: boolean): void;
  50249. /**
  50250. * Permanently set new colors for the gaze pointer
  50251. * @param color the new gaze color
  50252. * @param pickedColor the new gaze color when picked mesh detected
  50253. */
  50254. setGazeColor(color: Color3, pickedColor?: Color3): void;
  50255. /**
  50256. * Sets the color of the laser ray from the vr controllers.
  50257. * @param color new color for the ray.
  50258. */
  50259. changeLaserColor(color: Color3): void;
  50260. /**
  50261. * Sets the color of the ray from the vr headsets gaze.
  50262. * @param color new color for the ray.
  50263. */
  50264. changeGazeColor(color: Color3): void;
  50265. /**
  50266. * Exits VR and disposes of the vr experience helper
  50267. */
  50268. dispose(): void;
  50269. /**
  50270. * Gets the name of the VRExperienceHelper class
  50271. * @returns "VRExperienceHelper"
  50272. */
  50273. getClassName(): string;
  50274. }
  50275. }
  50276. declare module BABYLON {
  50277. /**
  50278. * Contains an array of blocks representing the octree
  50279. */
  50280. export interface IOctreeContainer<T> {
  50281. /**
  50282. * Blocks within the octree
  50283. */
  50284. blocks: Array<OctreeBlock<T>>;
  50285. }
  50286. /**
  50287. * Class used to store a cell in an octree
  50288. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50289. */
  50290. export class OctreeBlock<T> {
  50291. /**
  50292. * Gets the content of the current block
  50293. */
  50294. entries: T[];
  50295. /**
  50296. * Gets the list of block children
  50297. */
  50298. blocks: Array<OctreeBlock<T>>;
  50299. private _depth;
  50300. private _maxDepth;
  50301. private _capacity;
  50302. private _minPoint;
  50303. private _maxPoint;
  50304. private _boundingVectors;
  50305. private _creationFunc;
  50306. /**
  50307. * Creates a new block
  50308. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  50309. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  50310. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50311. * @param depth defines the current depth of this block in the octree
  50312. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  50313. * @param creationFunc defines a callback to call when an element is added to the block
  50314. */
  50315. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  50316. /**
  50317. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  50318. */
  50319. get capacity(): number;
  50320. /**
  50321. * Gets the minimum vector (in world space) of the block's bounding box
  50322. */
  50323. get minPoint(): Vector3;
  50324. /**
  50325. * Gets the maximum vector (in world space) of the block's bounding box
  50326. */
  50327. get maxPoint(): Vector3;
  50328. /**
  50329. * Add a new element to this block
  50330. * @param entry defines the element to add
  50331. */
  50332. addEntry(entry: T): void;
  50333. /**
  50334. * Remove an element from this block
  50335. * @param entry defines the element to remove
  50336. */
  50337. removeEntry(entry: T): void;
  50338. /**
  50339. * Add an array of elements to this block
  50340. * @param entries defines the array of elements to add
  50341. */
  50342. addEntries(entries: T[]): void;
  50343. /**
  50344. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  50345. * @param frustumPlanes defines the frustum planes to test
  50346. * @param selection defines the array to store current content if selection is positive
  50347. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50348. */
  50349. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50350. /**
  50351. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  50352. * @param sphereCenter defines the bounding sphere center
  50353. * @param sphereRadius defines the bounding sphere radius
  50354. * @param selection defines the array to store current content if selection is positive
  50355. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50356. */
  50357. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  50358. /**
  50359. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  50360. * @param ray defines the ray to test with
  50361. * @param selection defines the array to store current content if selection is positive
  50362. */
  50363. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  50364. /**
  50365. * Subdivide the content into child blocks (this block will then be empty)
  50366. */
  50367. createInnerBlocks(): void;
  50368. /**
  50369. * @hidden
  50370. */
  50371. 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;
  50372. }
  50373. }
  50374. declare module BABYLON {
  50375. /**
  50376. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  50377. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50378. */
  50379. export class Octree<T> {
  50380. /** 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.) */
  50381. maxDepth: number;
  50382. /**
  50383. * Blocks within the octree containing objects
  50384. */
  50385. blocks: Array<OctreeBlock<T>>;
  50386. /**
  50387. * Content stored in the octree
  50388. */
  50389. dynamicContent: T[];
  50390. private _maxBlockCapacity;
  50391. private _selectionContent;
  50392. private _creationFunc;
  50393. /**
  50394. * Creates a octree
  50395. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50396. * @param creationFunc function to be used to instatiate the octree
  50397. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  50398. * @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.)
  50399. */
  50400. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  50401. /** 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.) */
  50402. maxDepth?: number);
  50403. /**
  50404. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  50405. * @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);
  50406. * @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);
  50407. * @param entries meshes to be added to the octree blocks
  50408. */
  50409. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  50410. /**
  50411. * Adds a mesh to the octree
  50412. * @param entry Mesh to add to the octree
  50413. */
  50414. addMesh(entry: T): void;
  50415. /**
  50416. * Remove an element from the octree
  50417. * @param entry defines the element to remove
  50418. */
  50419. removeMesh(entry: T): void;
  50420. /**
  50421. * Selects an array of meshes within the frustum
  50422. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  50423. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  50424. * @returns array of meshes within the frustum
  50425. */
  50426. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  50427. /**
  50428. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  50429. * @param sphereCenter defines the bounding sphere center
  50430. * @param sphereRadius defines the bounding sphere radius
  50431. * @param allowDuplicate defines if the selection array can contains duplicated entries
  50432. * @returns an array of objects that intersect the sphere
  50433. */
  50434. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  50435. /**
  50436. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  50437. * @param ray defines the ray to test with
  50438. * @returns array of intersected objects
  50439. */
  50440. intersectsRay(ray: Ray): SmartArray<T>;
  50441. /**
  50442. * Adds a mesh into the octree block if it intersects the block
  50443. */
  50444. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  50445. /**
  50446. * Adds a submesh into the octree block if it intersects the block
  50447. */
  50448. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  50449. }
  50450. }
  50451. declare module BABYLON {
  50452. interface Scene {
  50453. /**
  50454. * @hidden
  50455. * Backing Filed
  50456. */
  50457. _selectionOctree: Octree<AbstractMesh>;
  50458. /**
  50459. * Gets the octree used to boost mesh selection (picking)
  50460. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50461. */
  50462. selectionOctree: Octree<AbstractMesh>;
  50463. /**
  50464. * Creates or updates the octree used to boost selection (picking)
  50465. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50466. * @param maxCapacity defines the maximum capacity per leaf
  50467. * @param maxDepth defines the maximum depth of the octree
  50468. * @returns an octree of AbstractMesh
  50469. */
  50470. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  50471. }
  50472. interface AbstractMesh {
  50473. /**
  50474. * @hidden
  50475. * Backing Field
  50476. */
  50477. _submeshesOctree: Octree<SubMesh>;
  50478. /**
  50479. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  50480. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  50481. * @param maxCapacity defines the maximum size of each block (64 by default)
  50482. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  50483. * @returns the new octree
  50484. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  50485. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  50486. */
  50487. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  50488. }
  50489. /**
  50490. * Defines the octree scene component responsible to manage any octrees
  50491. * in a given scene.
  50492. */
  50493. export class OctreeSceneComponent {
  50494. /**
  50495. * The component name help to identify the component in the list of scene components.
  50496. */
  50497. readonly name: string;
  50498. /**
  50499. * The scene the component belongs to.
  50500. */
  50501. scene: Scene;
  50502. /**
  50503. * Indicates if the meshes have been checked to make sure they are isEnabled()
  50504. */
  50505. readonly checksIsEnabled: boolean;
  50506. /**
  50507. * Creates a new instance of the component for the given scene
  50508. * @param scene Defines the scene to register the component in
  50509. */
  50510. constructor(scene: Scene);
  50511. /**
  50512. * Registers the component in a given scene
  50513. */
  50514. register(): void;
  50515. /**
  50516. * Return the list of active meshes
  50517. * @returns the list of active meshes
  50518. */
  50519. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  50520. /**
  50521. * Return the list of active sub meshes
  50522. * @param mesh The mesh to get the candidates sub meshes from
  50523. * @returns the list of active sub meshes
  50524. */
  50525. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  50526. private _tempRay;
  50527. /**
  50528. * Return the list of sub meshes intersecting with a given local ray
  50529. * @param mesh defines the mesh to find the submesh for
  50530. * @param localRay defines the ray in local space
  50531. * @returns the list of intersecting sub meshes
  50532. */
  50533. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  50534. /**
  50535. * Return the list of sub meshes colliding with a collider
  50536. * @param mesh defines the mesh to find the submesh for
  50537. * @param collider defines the collider to evaluate the collision against
  50538. * @returns the list of colliding sub meshes
  50539. */
  50540. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  50541. /**
  50542. * Rebuilds the elements related to this component in case of
  50543. * context lost for instance.
  50544. */
  50545. rebuild(): void;
  50546. /**
  50547. * Disposes the component and the associated ressources.
  50548. */
  50549. dispose(): void;
  50550. }
  50551. }
  50552. declare module BABYLON {
  50553. /**
  50554. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  50555. */
  50556. export class Gizmo implements IDisposable {
  50557. /** The utility layer the gizmo will be added to */
  50558. gizmoLayer: UtilityLayerRenderer;
  50559. /**
  50560. * The root mesh of the gizmo
  50561. */
  50562. _rootMesh: Mesh;
  50563. private _attachedMesh;
  50564. private _attachedNode;
  50565. /**
  50566. * Ratio for the scale of the gizmo (Default: 1)
  50567. */
  50568. protected _scaleRatio: number;
  50569. /**
  50570. * boolean updated by pointermove when a gizmo mesh is hovered
  50571. */
  50572. protected _isHovered: boolean;
  50573. /**
  50574. * Ratio for the scale of the gizmo (Default: 1)
  50575. */
  50576. set scaleRatio(value: number);
  50577. get scaleRatio(): number;
  50578. /**
  50579. * True when the mouse pointer is hovered a gizmo mesh
  50580. */
  50581. get isHovered(): boolean;
  50582. /**
  50583. * If a custom mesh has been set (Default: false)
  50584. */
  50585. protected _customMeshSet: boolean;
  50586. /**
  50587. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  50588. * * When set, interactions will be enabled
  50589. */
  50590. get attachedMesh(): Nullable<AbstractMesh>;
  50591. set attachedMesh(value: Nullable<AbstractMesh>);
  50592. /**
  50593. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  50594. * * When set, interactions will be enabled
  50595. */
  50596. get attachedNode(): Nullable<Node>;
  50597. set attachedNode(value: Nullable<Node>);
  50598. /**
  50599. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50600. * @param mesh The mesh to replace the default mesh of the gizmo
  50601. */
  50602. setCustomMesh(mesh: Mesh): void;
  50603. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  50604. /**
  50605. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  50606. */
  50607. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50608. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50609. /**
  50610. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  50611. */
  50612. updateGizmoPositionToMatchAttachedMesh: boolean;
  50613. /**
  50614. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  50615. */
  50616. updateScale: boolean;
  50617. protected _interactionsEnabled: boolean;
  50618. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50619. private _beforeRenderObserver;
  50620. private _tempQuaternion;
  50621. private _tempVector;
  50622. private _tempVector2;
  50623. private _tempMatrix1;
  50624. private _tempMatrix2;
  50625. private _rightHandtoLeftHandMatrix;
  50626. /**
  50627. * Creates a gizmo
  50628. * @param gizmoLayer The utility layer the gizmo will be added to
  50629. */
  50630. constructor(
  50631. /** The utility layer the gizmo will be added to */
  50632. gizmoLayer?: UtilityLayerRenderer);
  50633. /**
  50634. * Updates the gizmo to match the attached mesh's position/rotation
  50635. */
  50636. protected _update(): void;
  50637. /**
  50638. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  50639. * @param value Node, TransformNode or mesh
  50640. */
  50641. protected _matrixChanged(): void;
  50642. /**
  50643. * Disposes of the gizmo
  50644. */
  50645. dispose(): void;
  50646. }
  50647. }
  50648. declare module BABYLON {
  50649. /**
  50650. * Single plane drag gizmo
  50651. */
  50652. export class PlaneDragGizmo extends Gizmo {
  50653. /**
  50654. * Drag behavior responsible for the gizmos dragging interactions
  50655. */
  50656. dragBehavior: PointerDragBehavior;
  50657. private _pointerObserver;
  50658. /**
  50659. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50660. */
  50661. snapDistance: number;
  50662. /**
  50663. * Event that fires each time the gizmo snaps to a new location.
  50664. * * snapDistance is the the change in distance
  50665. */
  50666. onSnapObservable: Observable<{
  50667. snapDistance: number;
  50668. }>;
  50669. private _plane;
  50670. private _coloredMaterial;
  50671. private _hoverMaterial;
  50672. private _isEnabled;
  50673. private _parent;
  50674. /** @hidden */
  50675. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  50676. /** @hidden */
  50677. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50678. /**
  50679. * Creates a PlaneDragGizmo
  50680. * @param gizmoLayer The utility layer the gizmo will be added to
  50681. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  50682. * @param color The color of the gizmo
  50683. */
  50684. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  50685. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50686. /**
  50687. * If the gizmo is enabled
  50688. */
  50689. set isEnabled(value: boolean);
  50690. get isEnabled(): boolean;
  50691. /**
  50692. * Disposes of the gizmo
  50693. */
  50694. dispose(): void;
  50695. }
  50696. }
  50697. declare module BABYLON {
  50698. /**
  50699. * Gizmo that enables dragging a mesh along 3 axis
  50700. */
  50701. export class PositionGizmo extends Gizmo {
  50702. /**
  50703. * Internal gizmo used for interactions on the x axis
  50704. */
  50705. xGizmo: AxisDragGizmo;
  50706. /**
  50707. * Internal gizmo used for interactions on the y axis
  50708. */
  50709. yGizmo: AxisDragGizmo;
  50710. /**
  50711. * Internal gizmo used for interactions on the z axis
  50712. */
  50713. zGizmo: AxisDragGizmo;
  50714. /**
  50715. * Internal gizmo used for interactions on the yz plane
  50716. */
  50717. xPlaneGizmo: PlaneDragGizmo;
  50718. /**
  50719. * Internal gizmo used for interactions on the xz plane
  50720. */
  50721. yPlaneGizmo: PlaneDragGizmo;
  50722. /**
  50723. * Internal gizmo used for interactions on the xy plane
  50724. */
  50725. zPlaneGizmo: PlaneDragGizmo;
  50726. /**
  50727. * private variables
  50728. */
  50729. private _meshAttached;
  50730. private _nodeAttached;
  50731. private _snapDistance;
  50732. /** Fires an event when any of it's sub gizmos are dragged */
  50733. onDragStartObservable: Observable<unknown>;
  50734. /** Fires an event when any of it's sub gizmos are released from dragging */
  50735. onDragEndObservable: Observable<unknown>;
  50736. /**
  50737. * If set to true, planar drag is enabled
  50738. */
  50739. private _planarGizmoEnabled;
  50740. get attachedMesh(): Nullable<AbstractMesh>;
  50741. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50742. get attachedNode(): Nullable<Node>;
  50743. set attachedNode(node: Nullable<Node>);
  50744. /**
  50745. * True when the mouse pointer is hovering a gizmo mesh
  50746. */
  50747. get isHovered(): boolean;
  50748. /**
  50749. * Creates a PositionGizmo
  50750. * @param gizmoLayer The utility layer the gizmo will be added to
  50751. @param thickness display gizmo axis thickness
  50752. */
  50753. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  50754. /**
  50755. * If the planar drag gizmo is enabled
  50756. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  50757. */
  50758. set planarGizmoEnabled(value: boolean);
  50759. get planarGizmoEnabled(): boolean;
  50760. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50761. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50762. /**
  50763. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50764. */
  50765. set snapDistance(value: number);
  50766. get snapDistance(): number;
  50767. /**
  50768. * Ratio for the scale of the gizmo (Default: 1)
  50769. */
  50770. set scaleRatio(value: number);
  50771. get scaleRatio(): number;
  50772. /**
  50773. * Disposes of the gizmo
  50774. */
  50775. dispose(): void;
  50776. /**
  50777. * CustomMeshes are not supported by this gizmo
  50778. * @param mesh The mesh to replace the default mesh of the gizmo
  50779. */
  50780. setCustomMesh(mesh: Mesh): void;
  50781. }
  50782. }
  50783. declare module BABYLON {
  50784. /**
  50785. * Single axis drag gizmo
  50786. */
  50787. export class AxisDragGizmo extends Gizmo {
  50788. /**
  50789. * Drag behavior responsible for the gizmos dragging interactions
  50790. */
  50791. dragBehavior: PointerDragBehavior;
  50792. private _pointerObserver;
  50793. /**
  50794. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50795. */
  50796. snapDistance: number;
  50797. /**
  50798. * Event that fires each time the gizmo snaps to a new location.
  50799. * * snapDistance is the the change in distance
  50800. */
  50801. onSnapObservable: Observable<{
  50802. snapDistance: number;
  50803. }>;
  50804. private _isEnabled;
  50805. private _parent;
  50806. private _arrow;
  50807. private _coloredMaterial;
  50808. private _hoverMaterial;
  50809. /** @hidden */
  50810. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  50811. /** @hidden */
  50812. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  50813. /**
  50814. * Creates an AxisDragGizmo
  50815. * @param gizmoLayer The utility layer the gizmo will be added to
  50816. * @param dragAxis The axis which the gizmo will be able to drag on
  50817. * @param color The color of the gizmo
  50818. * @param thickness display gizmo axis thickness
  50819. */
  50820. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  50821. protected _attachedNodeChanged(value: Nullable<Node>): void;
  50822. /**
  50823. * If the gizmo is enabled
  50824. */
  50825. set isEnabled(value: boolean);
  50826. get isEnabled(): boolean;
  50827. /**
  50828. * Disposes of the gizmo
  50829. */
  50830. dispose(): void;
  50831. }
  50832. }
  50833. declare module BABYLON.Debug {
  50834. /**
  50835. * The Axes viewer will show 3 axes in a specific point in space
  50836. */
  50837. export class AxesViewer {
  50838. private _xAxis;
  50839. private _yAxis;
  50840. private _zAxis;
  50841. private _scaleLinesFactor;
  50842. private _instanced;
  50843. /**
  50844. * Gets the hosting scene
  50845. */
  50846. scene: Nullable<Scene>;
  50847. /**
  50848. * Gets or sets a number used to scale line length
  50849. */
  50850. scaleLines: number;
  50851. /** Gets the node hierarchy used to render x-axis */
  50852. get xAxis(): TransformNode;
  50853. /** Gets the node hierarchy used to render y-axis */
  50854. get yAxis(): TransformNode;
  50855. /** Gets the node hierarchy used to render z-axis */
  50856. get zAxis(): TransformNode;
  50857. /**
  50858. * Creates a new AxesViewer
  50859. * @param scene defines the hosting scene
  50860. * @param scaleLines defines a number used to scale line length (1 by default)
  50861. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  50862. * @param xAxis defines the node hierarchy used to render the x-axis
  50863. * @param yAxis defines the node hierarchy used to render the y-axis
  50864. * @param zAxis defines the node hierarchy used to render the z-axis
  50865. */
  50866. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  50867. /**
  50868. * Force the viewer to update
  50869. * @param position defines the position of the viewer
  50870. * @param xaxis defines the x axis of the viewer
  50871. * @param yaxis defines the y axis of the viewer
  50872. * @param zaxis defines the z axis of the viewer
  50873. */
  50874. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  50875. /**
  50876. * Creates an instance of this axes viewer.
  50877. * @returns a new axes viewer with instanced meshes
  50878. */
  50879. createInstance(): AxesViewer;
  50880. /** Releases resources */
  50881. dispose(): void;
  50882. private static _SetRenderingGroupId;
  50883. }
  50884. }
  50885. declare module BABYLON.Debug {
  50886. /**
  50887. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  50888. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  50889. */
  50890. export class BoneAxesViewer extends AxesViewer {
  50891. /**
  50892. * Gets or sets the target mesh where to display the axes viewer
  50893. */
  50894. mesh: Nullable<Mesh>;
  50895. /**
  50896. * Gets or sets the target bone where to display the axes viewer
  50897. */
  50898. bone: Nullable<Bone>;
  50899. /** Gets current position */
  50900. pos: Vector3;
  50901. /** Gets direction of X axis */
  50902. xaxis: Vector3;
  50903. /** Gets direction of Y axis */
  50904. yaxis: Vector3;
  50905. /** Gets direction of Z axis */
  50906. zaxis: Vector3;
  50907. /**
  50908. * Creates a new BoneAxesViewer
  50909. * @param scene defines the hosting scene
  50910. * @param bone defines the target bone
  50911. * @param mesh defines the target mesh
  50912. * @param scaleLines defines a scaling factor for line length (1 by default)
  50913. */
  50914. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  50915. /**
  50916. * Force the viewer to update
  50917. */
  50918. update(): void;
  50919. /** Releases resources */
  50920. dispose(): void;
  50921. }
  50922. }
  50923. declare module BABYLON {
  50924. /**
  50925. * Interface used to define scene explorer extensibility option
  50926. */
  50927. export interface IExplorerExtensibilityOption {
  50928. /**
  50929. * Define the option label
  50930. */
  50931. label: string;
  50932. /**
  50933. * Defines the action to execute on click
  50934. */
  50935. action: (entity: any) => void;
  50936. }
  50937. /**
  50938. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  50939. */
  50940. export interface IExplorerExtensibilityGroup {
  50941. /**
  50942. * Defines a predicate to test if a given type mut be extended
  50943. */
  50944. predicate: (entity: any) => boolean;
  50945. /**
  50946. * Gets the list of options added to a type
  50947. */
  50948. entries: IExplorerExtensibilityOption[];
  50949. }
  50950. /**
  50951. * Interface used to define the options to use to create the Inspector
  50952. */
  50953. export interface IInspectorOptions {
  50954. /**
  50955. * Display in overlay mode (default: false)
  50956. */
  50957. overlay?: boolean;
  50958. /**
  50959. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  50960. */
  50961. globalRoot?: HTMLElement;
  50962. /**
  50963. * Display the Scene explorer
  50964. */
  50965. showExplorer?: boolean;
  50966. /**
  50967. * Display the property inspector
  50968. */
  50969. showInspector?: boolean;
  50970. /**
  50971. * Display in embed mode (both panes on the right)
  50972. */
  50973. embedMode?: boolean;
  50974. /**
  50975. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  50976. */
  50977. handleResize?: boolean;
  50978. /**
  50979. * Allow the panes to popup (default: true)
  50980. */
  50981. enablePopup?: boolean;
  50982. /**
  50983. * Allow the panes to be closed by users (default: true)
  50984. */
  50985. enableClose?: boolean;
  50986. /**
  50987. * Optional list of extensibility entries
  50988. */
  50989. explorerExtensibility?: IExplorerExtensibilityGroup[];
  50990. /**
  50991. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  50992. */
  50993. inspectorURL?: string;
  50994. /**
  50995. * Optional initial tab (default to DebugLayerTab.Properties)
  50996. */
  50997. initialTab?: DebugLayerTab;
  50998. }
  50999. interface Scene {
  51000. /**
  51001. * @hidden
  51002. * Backing field
  51003. */
  51004. _debugLayer: DebugLayer;
  51005. /**
  51006. * Gets the debug layer (aka Inspector) associated with the scene
  51007. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51008. */
  51009. debugLayer: DebugLayer;
  51010. }
  51011. /**
  51012. * Enum of inspector action tab
  51013. */
  51014. export enum DebugLayerTab {
  51015. /**
  51016. * Properties tag (default)
  51017. */
  51018. Properties = 0,
  51019. /**
  51020. * Debug tab
  51021. */
  51022. Debug = 1,
  51023. /**
  51024. * Statistics tab
  51025. */
  51026. Statistics = 2,
  51027. /**
  51028. * Tools tab
  51029. */
  51030. Tools = 3,
  51031. /**
  51032. * Settings tab
  51033. */
  51034. Settings = 4
  51035. }
  51036. /**
  51037. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51038. * what is happening in your scene
  51039. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51040. */
  51041. export class DebugLayer {
  51042. /**
  51043. * Define the url to get the inspector script from.
  51044. * By default it uses the babylonjs CDN.
  51045. * @ignoreNaming
  51046. */
  51047. static InspectorURL: string;
  51048. private _scene;
  51049. private BJSINSPECTOR;
  51050. private _onPropertyChangedObservable?;
  51051. /**
  51052. * Observable triggered when a property is changed through the inspector.
  51053. */
  51054. get onPropertyChangedObservable(): any;
  51055. /**
  51056. * Instantiates a new debug layer.
  51057. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51058. * what is happening in your scene
  51059. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51060. * @param scene Defines the scene to inspect
  51061. */
  51062. constructor(scene: Scene);
  51063. /** Creates the inspector window. */
  51064. private _createInspector;
  51065. /**
  51066. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51067. * @param entity defines the entity to select
  51068. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51069. */
  51070. select(entity: any, lineContainerTitles?: string | string[]): void;
  51071. /** Get the inspector from bundle or global */
  51072. private _getGlobalInspector;
  51073. /**
  51074. * Get if the inspector is visible or not.
  51075. * @returns true if visible otherwise, false
  51076. */
  51077. isVisible(): boolean;
  51078. /**
  51079. * Hide the inspector and close its window.
  51080. */
  51081. hide(): void;
  51082. /**
  51083. * Update the scene in the inspector
  51084. */
  51085. setAsActiveScene(): void;
  51086. /**
  51087. * Launch the debugLayer.
  51088. * @param config Define the configuration of the inspector
  51089. * @return a promise fulfilled when the debug layer is visible
  51090. */
  51091. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51092. }
  51093. }
  51094. declare module BABYLON {
  51095. /**
  51096. * Class containing static functions to help procedurally build meshes
  51097. */
  51098. export class BoxBuilder {
  51099. /**
  51100. * Creates a box mesh
  51101. * * The parameter `size` sets the size (float) of each box side (default 1)
  51102. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51103. * * 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)
  51104. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51105. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51106. * * 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
  51107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51108. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51109. * @param name defines the name of the mesh
  51110. * @param options defines the options used to create the mesh
  51111. * @param scene defines the hosting scene
  51112. * @returns the box mesh
  51113. */
  51114. static CreateBox(name: string, options: {
  51115. size?: number;
  51116. width?: number;
  51117. height?: number;
  51118. depth?: number;
  51119. faceUV?: Vector4[];
  51120. faceColors?: Color4[];
  51121. sideOrientation?: number;
  51122. frontUVs?: Vector4;
  51123. backUVs?: Vector4;
  51124. wrap?: boolean;
  51125. topBaseAt?: number;
  51126. bottomBaseAt?: number;
  51127. updatable?: boolean;
  51128. }, scene?: Nullable<Scene>): Mesh;
  51129. }
  51130. }
  51131. declare module BABYLON.Debug {
  51132. /**
  51133. * Used to show the physics impostor around the specific mesh
  51134. */
  51135. export class PhysicsViewer {
  51136. /** @hidden */
  51137. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  51138. /** @hidden */
  51139. protected _meshes: Array<Nullable<AbstractMesh>>;
  51140. /** @hidden */
  51141. protected _scene: Nullable<Scene>;
  51142. /** @hidden */
  51143. protected _numMeshes: number;
  51144. /** @hidden */
  51145. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  51146. private _renderFunction;
  51147. private _utilityLayer;
  51148. private _debugBoxMesh;
  51149. private _debugSphereMesh;
  51150. private _debugCylinderMesh;
  51151. private _debugMaterial;
  51152. private _debugMeshMeshes;
  51153. /**
  51154. * Creates a new PhysicsViewer
  51155. * @param scene defines the hosting scene
  51156. */
  51157. constructor(scene: Scene);
  51158. /** @hidden */
  51159. protected _updateDebugMeshes(): void;
  51160. /**
  51161. * Renders a specified physic impostor
  51162. * @param impostor defines the impostor to render
  51163. * @param targetMesh defines the mesh represented by the impostor
  51164. * @returns the new debug mesh used to render the impostor
  51165. */
  51166. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  51167. /**
  51168. * Hides a specified physic impostor
  51169. * @param impostor defines the impostor to hide
  51170. */
  51171. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  51172. private _getDebugMaterial;
  51173. private _getDebugBoxMesh;
  51174. private _getDebugSphereMesh;
  51175. private _getDebugCylinderMesh;
  51176. private _getDebugMeshMesh;
  51177. private _getDebugMesh;
  51178. /** Releases all resources */
  51179. dispose(): void;
  51180. }
  51181. }
  51182. declare module BABYLON {
  51183. /**
  51184. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51185. * in order to better appreciate the issue one might have.
  51186. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51187. */
  51188. export class RayHelper {
  51189. /**
  51190. * Defines the ray we are currently tryin to visualize.
  51191. */
  51192. ray: Nullable<Ray>;
  51193. private _renderPoints;
  51194. private _renderLine;
  51195. private _renderFunction;
  51196. private _scene;
  51197. private _onAfterRenderObserver;
  51198. private _onAfterStepObserver;
  51199. private _attachedToMesh;
  51200. private _meshSpaceDirection;
  51201. private _meshSpaceOrigin;
  51202. /**
  51203. * Helper function to create a colored helper in a scene in one line.
  51204. * @param ray Defines the ray we are currently tryin to visualize
  51205. * @param scene Defines the scene the ray is used in
  51206. * @param color Defines the color we want to see the ray in
  51207. * @returns The newly created ray helper.
  51208. */
  51209. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  51210. /**
  51211. * Instantiate a new ray helper.
  51212. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  51213. * in order to better appreciate the issue one might have.
  51214. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  51215. * @param ray Defines the ray we are currently tryin to visualize
  51216. */
  51217. constructor(ray: Ray);
  51218. /**
  51219. * Shows the ray we are willing to debug.
  51220. * @param scene Defines the scene the ray needs to be rendered in
  51221. * @param color Defines the color the ray needs to be rendered in
  51222. */
  51223. show(scene: Scene, color?: Color3): void;
  51224. /**
  51225. * Hides the ray we are debugging.
  51226. */
  51227. hide(): void;
  51228. private _render;
  51229. /**
  51230. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  51231. * @param mesh Defines the mesh we want the helper attached to
  51232. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  51233. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  51234. * @param length Defines the length of the ray
  51235. */
  51236. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  51237. /**
  51238. * Detach the ray helper from the mesh it has previously been attached to.
  51239. */
  51240. detachFromMesh(): void;
  51241. private _updateToMesh;
  51242. /**
  51243. * Dispose the helper and release its associated resources.
  51244. */
  51245. dispose(): void;
  51246. }
  51247. }
  51248. declare module BABYLON {
  51249. /**
  51250. * Defines the options associated with the creation of a SkeletonViewer.
  51251. */
  51252. export interface ISkeletonViewerOptions {
  51253. /** Should the system pause animations before building the Viewer? */
  51254. pauseAnimations: boolean;
  51255. /** Should the system return the skeleton to rest before building? */
  51256. returnToRest: boolean;
  51257. /** public Display Mode of the Viewer */
  51258. displayMode: number;
  51259. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51260. displayOptions: ISkeletonViewerDisplayOptions;
  51261. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  51262. computeBonesUsingShaders: boolean;
  51263. /** Flag ignore non weighted bones */
  51264. useAllBones: boolean;
  51265. }
  51266. /**
  51267. * Defines how to display the various bone meshes for the viewer.
  51268. */
  51269. export interface ISkeletonViewerDisplayOptions {
  51270. /** How far down to start tapering the bone spurs */
  51271. midStep?: number;
  51272. /** How big is the midStep? */
  51273. midStepFactor?: number;
  51274. /** Base for the Sphere Size */
  51275. sphereBaseSize?: number;
  51276. /** The ratio of the sphere to the longest bone in units */
  51277. sphereScaleUnit?: number;
  51278. /** Ratio for the Sphere Size */
  51279. sphereFactor?: number;
  51280. /** Whether a spur should attach its far end to the child bone position */
  51281. spurFollowsChild?: boolean;
  51282. /** Whether to show local axes or not */
  51283. showLocalAxes?: boolean;
  51284. /** Length of each local axis */
  51285. localAxesSize?: number;
  51286. }
  51287. /**
  51288. * Defines the constructor options for the BoneWeight Shader.
  51289. */
  51290. export interface IBoneWeightShaderOptions {
  51291. /** Skeleton to Map */
  51292. skeleton: Skeleton;
  51293. /** Colors for Uninfluenced bones */
  51294. colorBase?: Color3;
  51295. /** Colors for 0.0-0.25 Weight bones */
  51296. colorZero?: Color3;
  51297. /** Color for 0.25-0.5 Weight Influence */
  51298. colorQuarter?: Color3;
  51299. /** Color for 0.5-0.75 Weight Influence */
  51300. colorHalf?: Color3;
  51301. /** Color for 0.75-1 Weight Influence */
  51302. colorFull?: Color3;
  51303. /** Color for Zero Weight Influence */
  51304. targetBoneIndex?: number;
  51305. }
  51306. /**
  51307. * Simple structure of the gradient steps for the Color Map.
  51308. */
  51309. export interface ISkeletonMapShaderColorMapKnot {
  51310. /** Color of the Knot */
  51311. color: Color3;
  51312. /** Location of the Knot */
  51313. location: number;
  51314. }
  51315. /**
  51316. * Defines the constructor options for the SkeletonMap Shader.
  51317. */
  51318. export interface ISkeletonMapShaderOptions {
  51319. /** Skeleton to Map */
  51320. skeleton: Skeleton;
  51321. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  51322. colorMap?: ISkeletonMapShaderColorMapKnot[];
  51323. }
  51324. }
  51325. declare module BABYLON {
  51326. /**
  51327. * Class containing static functions to help procedurally build meshes
  51328. */
  51329. export class RibbonBuilder {
  51330. /**
  51331. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51332. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51333. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51334. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51335. * * 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
  51336. * * 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
  51337. * * 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
  51338. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51339. * * 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
  51340. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51341. * * 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
  51342. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51343. * * 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
  51344. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51346. * @param name defines the name of the mesh
  51347. * @param options defines the options used to create the mesh
  51348. * @param scene defines the hosting scene
  51349. * @returns the ribbon mesh
  51350. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51351. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51352. */
  51353. static CreateRibbon(name: string, options: {
  51354. pathArray: Vector3[][];
  51355. closeArray?: boolean;
  51356. closePath?: boolean;
  51357. offset?: number;
  51358. updatable?: boolean;
  51359. sideOrientation?: number;
  51360. frontUVs?: Vector4;
  51361. backUVs?: Vector4;
  51362. instance?: Mesh;
  51363. invertUV?: boolean;
  51364. uvs?: Vector2[];
  51365. colors?: Color4[];
  51366. }, scene?: Nullable<Scene>): Mesh;
  51367. }
  51368. }
  51369. declare module BABYLON {
  51370. /**
  51371. * Class containing static functions to help procedurally build meshes
  51372. */
  51373. export class ShapeBuilder {
  51374. /**
  51375. * 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.
  51376. * * 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.
  51377. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51378. * * 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.
  51379. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51380. * * 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
  51381. * * 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
  51382. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51383. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51384. * * 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
  51385. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51387. * @param name defines the name of the mesh
  51388. * @param options defines the options used to create the mesh
  51389. * @param scene defines the hosting scene
  51390. * @returns the extruded shape mesh
  51391. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51392. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51393. */
  51394. static ExtrudeShape(name: string, options: {
  51395. shape: Vector3[];
  51396. path: Vector3[];
  51397. scale?: number;
  51398. rotation?: number;
  51399. cap?: number;
  51400. updatable?: boolean;
  51401. sideOrientation?: number;
  51402. frontUVs?: Vector4;
  51403. backUVs?: Vector4;
  51404. instance?: Mesh;
  51405. invertUV?: boolean;
  51406. }, scene?: Nullable<Scene>): Mesh;
  51407. /**
  51408. * Creates an custom extruded shape mesh.
  51409. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51410. * * 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.
  51411. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51412. * * 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
  51413. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51414. * * 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
  51415. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51416. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51417. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51418. * * 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
  51419. * * 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
  51420. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51422. * * 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
  51423. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51425. * @param name defines the name of the mesh
  51426. * @param options defines the options used to create the mesh
  51427. * @param scene defines the hosting scene
  51428. * @returns the custom extruded shape mesh
  51429. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51431. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51432. */
  51433. static ExtrudeShapeCustom(name: string, options: {
  51434. shape: Vector3[];
  51435. path: Vector3[];
  51436. scaleFunction?: any;
  51437. rotationFunction?: any;
  51438. ribbonCloseArray?: boolean;
  51439. ribbonClosePath?: boolean;
  51440. cap?: number;
  51441. updatable?: boolean;
  51442. sideOrientation?: number;
  51443. frontUVs?: Vector4;
  51444. backUVs?: Vector4;
  51445. instance?: Mesh;
  51446. invertUV?: boolean;
  51447. }, scene?: Nullable<Scene>): Mesh;
  51448. private static _ExtrudeShapeGeneric;
  51449. }
  51450. }
  51451. declare module BABYLON.Debug {
  51452. /**
  51453. * Class used to render a debug view of a given skeleton
  51454. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  51455. */
  51456. export class SkeletonViewer {
  51457. /** defines the skeleton to render */
  51458. skeleton: Skeleton;
  51459. /** defines the mesh attached to the skeleton */
  51460. mesh: AbstractMesh;
  51461. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51462. autoUpdateBonesMatrices: boolean;
  51463. /** defines the rendering group id to use with the viewer */
  51464. renderingGroupId: number;
  51465. /** is the options for the viewer */
  51466. options: Partial<ISkeletonViewerOptions>;
  51467. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  51468. static readonly DISPLAY_LINES: number;
  51469. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  51470. static readonly DISPLAY_SPHERES: number;
  51471. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  51472. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  51473. /** public static method to create a BoneWeight Shader
  51474. * @param options The constructor options
  51475. * @param scene The scene that the shader is scoped to
  51476. * @returns The created ShaderMaterial
  51477. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  51478. */
  51479. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  51480. /** public static method to create a BoneWeight Shader
  51481. * @param options The constructor options
  51482. * @param scene The scene that the shader is scoped to
  51483. * @returns The created ShaderMaterial
  51484. */
  51485. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  51486. /** private static method to create a BoneWeight Shader
  51487. * @param size The size of the buffer to create (usually the bone count)
  51488. * @param colorMap The gradient data to generate
  51489. * @param scene The scene that the shader is scoped to
  51490. * @returns an Array of floats from the color gradient values
  51491. */
  51492. private static _CreateBoneMapColorBuffer;
  51493. /** If SkeletonViewer scene scope. */
  51494. private _scene;
  51495. /** Gets or sets the color used to render the skeleton */
  51496. color: Color3;
  51497. /** Array of the points of the skeleton fo the line view. */
  51498. private _debugLines;
  51499. /** The SkeletonViewers Mesh. */
  51500. private _debugMesh;
  51501. /** The local axes Meshes. */
  51502. private _localAxes;
  51503. /** If SkeletonViewer is enabled. */
  51504. private _isEnabled;
  51505. /** If SkeletonViewer is ready. */
  51506. private _ready;
  51507. /** SkeletonViewer render observable. */
  51508. private _obs;
  51509. /** The Utility Layer to render the gizmos in. */
  51510. private _utilityLayer;
  51511. private _boneIndices;
  51512. /** Gets the Scene. */
  51513. get scene(): Scene;
  51514. /** Gets the utilityLayer. */
  51515. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  51516. /** Checks Ready Status. */
  51517. get isReady(): Boolean;
  51518. /** Sets Ready Status. */
  51519. set ready(value: boolean);
  51520. /** Gets the debugMesh */
  51521. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  51522. /** Sets the debugMesh */
  51523. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  51524. /** Gets the displayMode */
  51525. get displayMode(): number;
  51526. /** Sets the displayMode */
  51527. set displayMode(value: number);
  51528. /**
  51529. * Creates a new SkeletonViewer
  51530. * @param skeleton defines the skeleton to render
  51531. * @param mesh defines the mesh attached to the skeleton
  51532. * @param scene defines the hosting scene
  51533. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  51534. * @param renderingGroupId defines the rendering group id to use with the viewer
  51535. * @param options All of the extra constructor options for the SkeletonViewer
  51536. */
  51537. constructor(
  51538. /** defines the skeleton to render */
  51539. skeleton: Skeleton,
  51540. /** defines the mesh attached to the skeleton */
  51541. mesh: AbstractMesh,
  51542. /** The Scene scope*/
  51543. scene: Scene,
  51544. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  51545. autoUpdateBonesMatrices?: boolean,
  51546. /** defines the rendering group id to use with the viewer */
  51547. renderingGroupId?: number,
  51548. /** is the options for the viewer */
  51549. options?: Partial<ISkeletonViewerOptions>);
  51550. /** The Dynamic bindings for the update functions */
  51551. private _bindObs;
  51552. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  51553. update(): void;
  51554. /** Gets or sets a boolean indicating if the viewer is enabled */
  51555. set isEnabled(value: boolean);
  51556. get isEnabled(): boolean;
  51557. private _getBonePosition;
  51558. private _getLinesForBonesWithLength;
  51559. private _getLinesForBonesNoLength;
  51560. /** function to revert the mesh and scene back to the initial state. */
  51561. private _revert;
  51562. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  51563. private _getAbsoluteBindPoseToRef;
  51564. /** function to build and bind sphere joint points and spur bone representations. */
  51565. private _buildSpheresAndSpurs;
  51566. private _buildLocalAxes;
  51567. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  51568. private _displayLinesUpdate;
  51569. /** Changes the displayMode of the skeleton viewer
  51570. * @param mode The displayMode numerical value
  51571. */
  51572. changeDisplayMode(mode: number): void;
  51573. /** Sets a display option of the skeleton viewer
  51574. *
  51575. * | Option | Type | Default | Description |
  51576. * | ---------------- | ------- | ------- | ----------- |
  51577. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51578. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51579. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51580. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  51581. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  51582. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  51583. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  51584. *
  51585. * @param option String of the option name
  51586. * @param value The numerical option value
  51587. */
  51588. changeDisplayOptions(option: string, value: number): void;
  51589. /** Release associated resources */
  51590. dispose(): void;
  51591. }
  51592. }
  51593. declare module BABYLON {
  51594. /**
  51595. * Enum for Device Types
  51596. */
  51597. export enum DeviceType {
  51598. /** Generic */
  51599. Generic = 0,
  51600. /** Keyboard */
  51601. Keyboard = 1,
  51602. /** Mouse */
  51603. Mouse = 2,
  51604. /** Touch Pointers */
  51605. Touch = 3,
  51606. /** PS4 Dual Shock */
  51607. DualShock = 4,
  51608. /** Xbox */
  51609. Xbox = 5,
  51610. /** Switch Controller */
  51611. Switch = 6
  51612. }
  51613. /**
  51614. * Enum for All Pointers (Touch/Mouse)
  51615. */
  51616. export enum PointerInput {
  51617. /** Horizontal Axis */
  51618. Horizontal = 0,
  51619. /** Vertical Axis */
  51620. Vertical = 1,
  51621. /** Left Click or Touch */
  51622. LeftClick = 2,
  51623. /** Middle Click */
  51624. MiddleClick = 3,
  51625. /** Right Click */
  51626. RightClick = 4,
  51627. /** Browser Back */
  51628. BrowserBack = 5,
  51629. /** Browser Forward */
  51630. BrowserForward = 6
  51631. }
  51632. /**
  51633. * Enum for Dual Shock Gamepad
  51634. */
  51635. export enum DualShockInput {
  51636. /** Cross */
  51637. Cross = 0,
  51638. /** Circle */
  51639. Circle = 1,
  51640. /** Square */
  51641. Square = 2,
  51642. /** Triangle */
  51643. Triangle = 3,
  51644. /** L1 */
  51645. L1 = 4,
  51646. /** R1 */
  51647. R1 = 5,
  51648. /** L2 */
  51649. L2 = 6,
  51650. /** R2 */
  51651. R2 = 7,
  51652. /** Share */
  51653. Share = 8,
  51654. /** Options */
  51655. Options = 9,
  51656. /** L3 */
  51657. L3 = 10,
  51658. /** R3 */
  51659. R3 = 11,
  51660. /** DPadUp */
  51661. DPadUp = 12,
  51662. /** DPadDown */
  51663. DPadDown = 13,
  51664. /** DPadLeft */
  51665. DPadLeft = 14,
  51666. /** DRight */
  51667. DPadRight = 15,
  51668. /** Home */
  51669. Home = 16,
  51670. /** TouchPad */
  51671. TouchPad = 17,
  51672. /** LStickXAxis */
  51673. LStickXAxis = 18,
  51674. /** LStickYAxis */
  51675. LStickYAxis = 19,
  51676. /** RStickXAxis */
  51677. RStickXAxis = 20,
  51678. /** RStickYAxis */
  51679. RStickYAxis = 21
  51680. }
  51681. /**
  51682. * Enum for Xbox Gamepad
  51683. */
  51684. export enum XboxInput {
  51685. /** A */
  51686. A = 0,
  51687. /** B */
  51688. B = 1,
  51689. /** X */
  51690. X = 2,
  51691. /** Y */
  51692. Y = 3,
  51693. /** LB */
  51694. LB = 4,
  51695. /** RB */
  51696. RB = 5,
  51697. /** LT */
  51698. LT = 6,
  51699. /** RT */
  51700. RT = 7,
  51701. /** Back */
  51702. Back = 8,
  51703. /** Start */
  51704. Start = 9,
  51705. /** LS */
  51706. LS = 10,
  51707. /** RS */
  51708. RS = 11,
  51709. /** DPadUp */
  51710. DPadUp = 12,
  51711. /** DPadDown */
  51712. DPadDown = 13,
  51713. /** DPadLeft */
  51714. DPadLeft = 14,
  51715. /** DRight */
  51716. DPadRight = 15,
  51717. /** Home */
  51718. Home = 16,
  51719. /** LStickXAxis */
  51720. LStickXAxis = 17,
  51721. /** LStickYAxis */
  51722. LStickYAxis = 18,
  51723. /** RStickXAxis */
  51724. RStickXAxis = 19,
  51725. /** RStickYAxis */
  51726. RStickYAxis = 20
  51727. }
  51728. /**
  51729. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  51730. */
  51731. export enum SwitchInput {
  51732. /** B */
  51733. B = 0,
  51734. /** A */
  51735. A = 1,
  51736. /** Y */
  51737. Y = 2,
  51738. /** X */
  51739. X = 3,
  51740. /** L */
  51741. L = 4,
  51742. /** R */
  51743. R = 5,
  51744. /** ZL */
  51745. ZL = 6,
  51746. /** ZR */
  51747. ZR = 7,
  51748. /** Minus */
  51749. Minus = 8,
  51750. /** Plus */
  51751. Plus = 9,
  51752. /** LS */
  51753. LS = 10,
  51754. /** RS */
  51755. RS = 11,
  51756. /** DPadUp */
  51757. DPadUp = 12,
  51758. /** DPadDown */
  51759. DPadDown = 13,
  51760. /** DPadLeft */
  51761. DPadLeft = 14,
  51762. /** DRight */
  51763. DPadRight = 15,
  51764. /** Home */
  51765. Home = 16,
  51766. /** Capture */
  51767. Capture = 17,
  51768. /** LStickXAxis */
  51769. LStickXAxis = 18,
  51770. /** LStickYAxis */
  51771. LStickYAxis = 19,
  51772. /** RStickXAxis */
  51773. RStickXAxis = 20,
  51774. /** RStickYAxis */
  51775. RStickYAxis = 21
  51776. }
  51777. }
  51778. declare module BABYLON {
  51779. /**
  51780. * This class will take all inputs from Keyboard, Pointer, and
  51781. * any Gamepads and provide a polling system that all devices
  51782. * will use. This class assumes that there will only be one
  51783. * pointer device and one keyboard.
  51784. */
  51785. export class DeviceInputSystem implements IDisposable {
  51786. /**
  51787. * Callback to be triggered when a device is connected
  51788. */
  51789. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51790. /**
  51791. * Callback to be triggered when a device is disconnected
  51792. */
  51793. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  51794. /**
  51795. * Callback to be triggered when event driven input is updated
  51796. */
  51797. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  51798. private _inputs;
  51799. private _gamepads;
  51800. private _keyboardActive;
  51801. private _pointerActive;
  51802. private _elementToAttachTo;
  51803. private _keyboardDownEvent;
  51804. private _keyboardUpEvent;
  51805. private _pointerMoveEvent;
  51806. private _pointerDownEvent;
  51807. private _pointerUpEvent;
  51808. private _gamepadConnectedEvent;
  51809. private _gamepadDisconnectedEvent;
  51810. private static _MAX_KEYCODES;
  51811. private static _MAX_POINTER_INPUTS;
  51812. private constructor();
  51813. /**
  51814. * Creates a new DeviceInputSystem instance
  51815. * @param engine Engine to pull input element from
  51816. * @returns The new instance
  51817. */
  51818. static Create(engine: Engine): DeviceInputSystem;
  51819. /**
  51820. * Checks for current device input value, given an id and input index
  51821. * @param deviceName Id of connected device
  51822. * @param inputIndex Index of device input
  51823. * @returns Current value of input
  51824. */
  51825. /**
  51826. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  51827. * @param deviceType Enum specifiying device type
  51828. * @param deviceSlot "Slot" or index that device is referenced in
  51829. * @param inputIndex Id of input to be checked
  51830. * @returns Current value of input
  51831. */
  51832. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  51833. /**
  51834. * Dispose of all the eventlisteners
  51835. */
  51836. dispose(): void;
  51837. /**
  51838. * Add device and inputs to device array
  51839. * @param deviceType Enum specifiying device type
  51840. * @param deviceSlot "Slot" or index that device is referenced in
  51841. * @param numberOfInputs Number of input entries to create for given device
  51842. */
  51843. private _registerDevice;
  51844. /**
  51845. * Given a specific device name, remove that device from the device map
  51846. * @param deviceType Enum specifiying device type
  51847. * @param deviceSlot "Slot" or index that device is referenced in
  51848. */
  51849. private _unregisterDevice;
  51850. /**
  51851. * Handle all actions that come from keyboard interaction
  51852. */
  51853. private _handleKeyActions;
  51854. /**
  51855. * Handle all actions that come from pointer interaction
  51856. */
  51857. private _handlePointerActions;
  51858. /**
  51859. * Handle all actions that come from gamepad interaction
  51860. */
  51861. private _handleGamepadActions;
  51862. /**
  51863. * Update all non-event based devices with each frame
  51864. * @param deviceType Enum specifiying device type
  51865. * @param deviceSlot "Slot" or index that device is referenced in
  51866. * @param inputIndex Id of input to be checked
  51867. */
  51868. private _updateDevice;
  51869. /**
  51870. * Gets DeviceType from the device name
  51871. * @param deviceName Name of Device from DeviceInputSystem
  51872. * @returns DeviceType enum value
  51873. */
  51874. private _getGamepadDeviceType;
  51875. }
  51876. }
  51877. declare module BABYLON {
  51878. /**
  51879. * Type to handle enforcement of inputs
  51880. */
  51881. 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;
  51882. }
  51883. declare module BABYLON {
  51884. /**
  51885. * Class that handles all input for a specific device
  51886. */
  51887. export class DeviceSource<T extends DeviceType> {
  51888. /** Type of device */
  51889. readonly deviceType: DeviceType;
  51890. /** "Slot" or index that device is referenced in */
  51891. readonly deviceSlot: number;
  51892. /**
  51893. * Observable to handle device input changes per device
  51894. */
  51895. readonly onInputChangedObservable: Observable<{
  51896. inputIndex: DeviceInput<T>;
  51897. previousState: Nullable<number>;
  51898. currentState: Nullable<number>;
  51899. }>;
  51900. private readonly _deviceInputSystem;
  51901. /**
  51902. * Default Constructor
  51903. * @param deviceInputSystem Reference to DeviceInputSystem
  51904. * @param deviceType Type of device
  51905. * @param deviceSlot "Slot" or index that device is referenced in
  51906. */
  51907. constructor(deviceInputSystem: DeviceInputSystem,
  51908. /** Type of device */
  51909. deviceType: DeviceType,
  51910. /** "Slot" or index that device is referenced in */
  51911. deviceSlot?: number);
  51912. /**
  51913. * Get input for specific input
  51914. * @param inputIndex index of specific input on device
  51915. * @returns Input value from DeviceInputSystem
  51916. */
  51917. getInput(inputIndex: DeviceInput<T>): number;
  51918. }
  51919. /**
  51920. * Class to keep track of devices
  51921. */
  51922. export class DeviceSourceManager implements IDisposable {
  51923. /**
  51924. * Observable to be triggered when before a device is connected
  51925. */
  51926. readonly onBeforeDeviceConnectedObservable: Observable<{
  51927. deviceType: DeviceType;
  51928. deviceSlot: number;
  51929. }>;
  51930. /**
  51931. * Observable to be triggered when before a device is disconnected
  51932. */
  51933. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  51934. deviceType: DeviceType;
  51935. deviceSlot: number;
  51936. }>;
  51937. /**
  51938. * Observable to be triggered when after a device is connected
  51939. */
  51940. readonly onAfterDeviceConnectedObservable: Observable<{
  51941. deviceType: DeviceType;
  51942. deviceSlot: number;
  51943. }>;
  51944. /**
  51945. * Observable to be triggered when after a device is disconnected
  51946. */
  51947. readonly onAfterDeviceDisconnectedObservable: Observable<{
  51948. deviceType: DeviceType;
  51949. deviceSlot: number;
  51950. }>;
  51951. private readonly _devices;
  51952. private readonly _firstDevice;
  51953. private readonly _deviceInputSystem;
  51954. /**
  51955. * Default Constructor
  51956. * @param engine engine to pull input element from
  51957. */
  51958. constructor(engine: Engine);
  51959. /**
  51960. * Gets a DeviceSource, given a type and slot
  51961. * @param deviceType Enum specifying device type
  51962. * @param deviceSlot "Slot" or index that device is referenced in
  51963. * @returns DeviceSource object
  51964. */
  51965. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  51966. /**
  51967. * Gets an array of DeviceSource objects for a given device type
  51968. * @param deviceType Enum specifying device type
  51969. * @returns Array of DeviceSource objects
  51970. */
  51971. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  51972. /**
  51973. * Dispose of DeviceInputSystem and other parts
  51974. */
  51975. dispose(): void;
  51976. /**
  51977. * Function to add device name to device list
  51978. * @param deviceType Enum specifying device type
  51979. * @param deviceSlot "Slot" or index that device is referenced in
  51980. */
  51981. private _addDevice;
  51982. /**
  51983. * Function to remove device name to device list
  51984. * @param deviceType Enum specifying device type
  51985. * @param deviceSlot "Slot" or index that device is referenced in
  51986. */
  51987. private _removeDevice;
  51988. /**
  51989. * Updates array storing first connected device of each type
  51990. * @param type Type of Device
  51991. */
  51992. private _updateFirstDevices;
  51993. }
  51994. }
  51995. declare module BABYLON {
  51996. /**
  51997. * Options to create the null engine
  51998. */
  51999. export class NullEngineOptions {
  52000. /**
  52001. * Render width (Default: 512)
  52002. */
  52003. renderWidth: number;
  52004. /**
  52005. * Render height (Default: 256)
  52006. */
  52007. renderHeight: number;
  52008. /**
  52009. * Texture size (Default: 512)
  52010. */
  52011. textureSize: number;
  52012. /**
  52013. * If delta time between frames should be constant
  52014. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52015. */
  52016. deterministicLockstep: boolean;
  52017. /**
  52018. * Maximum about of steps between frames (Default: 4)
  52019. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52020. */
  52021. lockstepMaxSteps: number;
  52022. /**
  52023. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  52024. */
  52025. useHighPrecisionMatrix?: boolean;
  52026. }
  52027. /**
  52028. * The null engine class provides support for headless version of babylon.js.
  52029. * This can be used in server side scenario or for testing purposes
  52030. */
  52031. export class NullEngine extends Engine {
  52032. private _options;
  52033. /**
  52034. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52035. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52036. * @returns true if engine is in deterministic lock step mode
  52037. */
  52038. isDeterministicLockStep(): boolean;
  52039. /**
  52040. * Gets the max steps when engine is running in deterministic lock step
  52041. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52042. * @returns the max steps
  52043. */
  52044. getLockstepMaxSteps(): number;
  52045. /**
  52046. * Gets the current hardware scaling level.
  52047. * By default the hardware scaling level is computed from the window device ratio.
  52048. * 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.
  52049. * @returns a number indicating the current hardware scaling level
  52050. */
  52051. getHardwareScalingLevel(): number;
  52052. constructor(options?: NullEngineOptions);
  52053. /**
  52054. * Creates a vertex buffer
  52055. * @param vertices the data for the vertex buffer
  52056. * @returns the new WebGL static buffer
  52057. */
  52058. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52059. /**
  52060. * Creates a new index buffer
  52061. * @param indices defines the content of the index buffer
  52062. * @param updatable defines if the index buffer must be updatable
  52063. * @returns a new webGL buffer
  52064. */
  52065. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52066. /**
  52067. * Clear the current render buffer or the current render target (if any is set up)
  52068. * @param color defines the color to use
  52069. * @param backBuffer defines if the back buffer must be cleared
  52070. * @param depth defines if the depth buffer must be cleared
  52071. * @param stencil defines if the stencil buffer must be cleared
  52072. */
  52073. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52074. /**
  52075. * Gets the current render width
  52076. * @param useScreen defines if screen size must be used (or the current render target if any)
  52077. * @returns a number defining the current render width
  52078. */
  52079. getRenderWidth(useScreen?: boolean): number;
  52080. /**
  52081. * Gets the current render height
  52082. * @param useScreen defines if screen size must be used (or the current render target if any)
  52083. * @returns a number defining the current render height
  52084. */
  52085. getRenderHeight(useScreen?: boolean): number;
  52086. /**
  52087. * Set the WebGL's viewport
  52088. * @param viewport defines the viewport element to be used
  52089. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52090. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52091. */
  52092. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52093. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52094. /**
  52095. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52096. * @param pipelineContext defines the pipeline context to use
  52097. * @param uniformsNames defines the list of uniform names
  52098. * @returns an array of webGL uniform locations
  52099. */
  52100. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52101. /**
  52102. * Gets the lsit of active attributes for a given webGL program
  52103. * @param pipelineContext defines the pipeline context to use
  52104. * @param attributesNames defines the list of attribute names to get
  52105. * @returns an array of indices indicating the offset of each attribute
  52106. */
  52107. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52108. /**
  52109. * Binds an effect to the webGL context
  52110. * @param effect defines the effect to bind
  52111. */
  52112. bindSamplers(effect: Effect): void;
  52113. /**
  52114. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52115. * @param effect defines the effect to activate
  52116. */
  52117. enableEffect(effect: Effect): void;
  52118. /**
  52119. * Set various states to the webGL context
  52120. * @param culling defines backface culling state
  52121. * @param zOffset defines the value to apply to zOffset (0 by default)
  52122. * @param force defines if states must be applied even if cache is up to date
  52123. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52124. */
  52125. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52126. /**
  52127. * Set the value of an uniform to an array of int32
  52128. * @param uniform defines the webGL uniform location where to store the value
  52129. * @param array defines the array of int32 to store
  52130. * @returns true if value was set
  52131. */
  52132. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52133. /**
  52134. * Set the value of an uniform to an array of int32 (stored as vec2)
  52135. * @param uniform defines the webGL uniform location where to store the value
  52136. * @param array defines the array of int32 to store
  52137. * @returns true if value was set
  52138. */
  52139. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52140. /**
  52141. * Set the value of an uniform to an array of int32 (stored as vec3)
  52142. * @param uniform defines the webGL uniform location where to store the value
  52143. * @param array defines the array of int32 to store
  52144. * @returns true if value was set
  52145. */
  52146. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52147. /**
  52148. * Set the value of an uniform to an array of int32 (stored as vec4)
  52149. * @param uniform defines the webGL uniform location where to store the value
  52150. * @param array defines the array of int32 to store
  52151. * @returns true if value was set
  52152. */
  52153. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  52154. /**
  52155. * Set the value of an uniform to an array of float32
  52156. * @param uniform defines the webGL uniform location where to store the value
  52157. * @param array defines the array of float32 to store
  52158. * @returns true if value was set
  52159. */
  52160. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52161. /**
  52162. * Set the value of an uniform to an array of float32 (stored as vec2)
  52163. * @param uniform defines the webGL uniform location where to store the value
  52164. * @param array defines the array of float32 to store
  52165. * @returns true if value was set
  52166. */
  52167. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52168. /**
  52169. * Set the value of an uniform to an array of float32 (stored as vec3)
  52170. * @param uniform defines the webGL uniform location where to store the value
  52171. * @param array defines the array of float32 to store
  52172. * @returns true if value was set
  52173. */
  52174. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52175. /**
  52176. * Set the value of an uniform to an array of float32 (stored as vec4)
  52177. * @param uniform defines the webGL uniform location where to store the value
  52178. * @param array defines the array of float32 to store
  52179. * @returns true if value was set
  52180. */
  52181. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  52182. /**
  52183. * Set the value of an uniform to an array of number
  52184. * @param uniform defines the webGL uniform location where to store the value
  52185. * @param array defines the array of number to store
  52186. * @returns true if value was set
  52187. */
  52188. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  52189. /**
  52190. * Set the value of an uniform to an array of number (stored as vec2)
  52191. * @param uniform defines the webGL uniform location where to store the value
  52192. * @param array defines the array of number to store
  52193. * @returns true if value was set
  52194. */
  52195. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  52196. /**
  52197. * Set the value of an uniform to an array of number (stored as vec3)
  52198. * @param uniform defines the webGL uniform location where to store the value
  52199. * @param array defines the array of number to store
  52200. * @returns true if value was set
  52201. */
  52202. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  52203. /**
  52204. * Set the value of an uniform to an array of number (stored as vec4)
  52205. * @param uniform defines the webGL uniform location where to store the value
  52206. * @param array defines the array of number to store
  52207. * @returns true if value was set
  52208. */
  52209. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  52210. /**
  52211. * Set the value of an uniform to an array of float32 (stored as matrices)
  52212. * @param uniform defines the webGL uniform location where to store the value
  52213. * @param matrices defines the array of float32 to store
  52214. * @returns true if value was set
  52215. */
  52216. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  52217. /**
  52218. * Set the value of an uniform to a matrix (3x3)
  52219. * @param uniform defines the webGL uniform location where to store the value
  52220. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52221. * @returns true if value was set
  52222. */
  52223. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52224. /**
  52225. * Set the value of an uniform to a matrix (2x2)
  52226. * @param uniform defines the webGL uniform location where to store the value
  52227. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52228. * @returns true if value was set
  52229. */
  52230. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  52231. /**
  52232. * Set the value of an uniform to a number (float)
  52233. * @param uniform defines the webGL uniform location where to store the value
  52234. * @param value defines the float number to store
  52235. * @returns true if value was set
  52236. */
  52237. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  52238. /**
  52239. * Set the value of an uniform to a vec2
  52240. * @param uniform defines the webGL uniform location where to store the value
  52241. * @param x defines the 1st component of the value
  52242. * @param y defines the 2nd component of the value
  52243. * @returns true if value was set
  52244. */
  52245. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  52246. /**
  52247. * Set the value of an uniform to a vec3
  52248. * @param uniform defines the webGL uniform location where to store the value
  52249. * @param x defines the 1st component of the value
  52250. * @param y defines the 2nd component of the value
  52251. * @param z defines the 3rd component of the value
  52252. * @returns true if value was set
  52253. */
  52254. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  52255. /**
  52256. * Set the value of an uniform to a boolean
  52257. * @param uniform defines the webGL uniform location where to store the value
  52258. * @param bool defines the boolean to store
  52259. * @returns true if value was set
  52260. */
  52261. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  52262. /**
  52263. * Set the value of an uniform to a vec4
  52264. * @param uniform defines the webGL uniform location where to store the value
  52265. * @param x defines the 1st component of the value
  52266. * @param y defines the 2nd component of the value
  52267. * @param z defines the 3rd component of the value
  52268. * @param w defines the 4th component of the value
  52269. * @returns true if value was set
  52270. */
  52271. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  52272. /**
  52273. * Sets the current alpha mode
  52274. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52275. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52276. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52277. */
  52278. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52279. /**
  52280. * Bind webGl buffers directly to the webGL context
  52281. * @param vertexBuffers defines the vertex buffer to bind
  52282. * @param indexBuffer defines the index buffer to bind
  52283. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52284. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52285. * @param effect defines the effect associated with the vertex buffer
  52286. */
  52287. bindBuffers(vertexBuffers: {
  52288. [key: string]: VertexBuffer;
  52289. }, indexBuffer: DataBuffer, effect: Effect): void;
  52290. /**
  52291. * Force the entire cache to be cleared
  52292. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52293. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52294. */
  52295. wipeCaches(bruteForce?: boolean): void;
  52296. /**
  52297. * Send a draw order
  52298. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52299. * @param indexStart defines the starting index
  52300. * @param indexCount defines the number of index to draw
  52301. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52302. */
  52303. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52304. /**
  52305. * Draw a list of indexed primitives
  52306. * @param fillMode defines the primitive to use
  52307. * @param indexStart defines the starting index
  52308. * @param indexCount defines the number of index to draw
  52309. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52310. */
  52311. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52312. /**
  52313. * Draw a list of unindexed primitives
  52314. * @param fillMode defines the primitive to use
  52315. * @param verticesStart defines the index of first vertex to draw
  52316. * @param verticesCount defines the count of vertices to draw
  52317. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52318. */
  52319. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52320. /** @hidden */
  52321. _createTexture(): WebGLTexture;
  52322. /** @hidden */
  52323. _releaseTexture(texture: InternalTexture): void;
  52324. /**
  52325. * Usually called from Texture.ts.
  52326. * Passed information to create a WebGLTexture
  52327. * @param urlArg defines a value which contains one of the following:
  52328. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52329. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52330. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52332. * @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)
  52333. * @param scene needed for loading to the correct scene
  52334. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52335. * @param onLoad optional callback to be called upon successful completion
  52336. * @param onError optional callback to be called upon failure
  52337. * @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
  52338. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52339. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52340. * @param forcedExtension defines the extension to use to pick the right loader
  52341. * @param mimeType defines an optional mime type
  52342. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52343. */
  52344. 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;
  52345. /**
  52346. * Creates a new render target texture
  52347. * @param size defines the size of the texture
  52348. * @param options defines the options used to create the texture
  52349. * @returns a new render target texture stored in an InternalTexture
  52350. */
  52351. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52352. /**
  52353. * Update the sampling mode of a given texture
  52354. * @param samplingMode defines the required sampling mode
  52355. * @param texture defines the texture to update
  52356. */
  52357. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52358. /**
  52359. * Binds the frame buffer to the specified texture.
  52360. * @param texture The texture to render to or null for the default canvas
  52361. * @param faceIndex The face of the texture to render to in case of cube texture
  52362. * @param requiredWidth The width of the target to render to
  52363. * @param requiredHeight The height of the target to render to
  52364. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52365. * @param lodLevel defines le lod level to bind to the frame buffer
  52366. */
  52367. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52368. /**
  52369. * Unbind the current render target texture from the webGL context
  52370. * @param texture defines the render target texture to unbind
  52371. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52372. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52373. */
  52374. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52375. /**
  52376. * Creates a dynamic vertex buffer
  52377. * @param vertices the data for the dynamic vertex buffer
  52378. * @returns the new WebGL dynamic buffer
  52379. */
  52380. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52381. /**
  52382. * Update the content of a dynamic texture
  52383. * @param texture defines the texture to update
  52384. * @param canvas defines the canvas containing the source
  52385. * @param invertY defines if data must be stored with Y axis inverted
  52386. * @param premulAlpha defines if alpha is stored as premultiplied
  52387. * @param format defines the format of the data
  52388. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  52389. */
  52390. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  52391. /**
  52392. * Gets a boolean indicating if all created effects are ready
  52393. * @returns true if all effects are ready
  52394. */
  52395. areAllEffectsReady(): boolean;
  52396. /**
  52397. * @hidden
  52398. * Get the current error code of the webGL context
  52399. * @returns the error code
  52400. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  52401. */
  52402. getError(): number;
  52403. /** @hidden */
  52404. _getUnpackAlignement(): number;
  52405. /** @hidden */
  52406. _unpackFlipY(value: boolean): void;
  52407. /**
  52408. * Update a dynamic index buffer
  52409. * @param indexBuffer defines the target index buffer
  52410. * @param indices defines the data to update
  52411. * @param offset defines the offset in the target index buffer where update should start
  52412. */
  52413. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  52414. /**
  52415. * Updates a dynamic vertex buffer.
  52416. * @param vertexBuffer the vertex buffer to update
  52417. * @param vertices the data used to update the vertex buffer
  52418. * @param byteOffset the byte offset of the data (optional)
  52419. * @param byteLength the byte length of the data (optional)
  52420. */
  52421. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  52422. /** @hidden */
  52423. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  52424. /** @hidden */
  52425. _bindTexture(channel: number, texture: InternalTexture): void;
  52426. protected _deleteBuffer(buffer: WebGLBuffer): void;
  52427. /**
  52428. * 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
  52429. */
  52430. releaseEffects(): void;
  52431. displayLoadingUI(): void;
  52432. hideLoadingUI(): void;
  52433. /** @hidden */
  52434. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52435. /** @hidden */
  52436. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52437. /** @hidden */
  52438. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  52439. /** @hidden */
  52440. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  52441. }
  52442. }
  52443. declare module BABYLON {
  52444. /**
  52445. * @hidden
  52446. **/
  52447. export class _TimeToken {
  52448. _startTimeQuery: Nullable<WebGLQuery>;
  52449. _endTimeQuery: Nullable<WebGLQuery>;
  52450. _timeElapsedQuery: Nullable<WebGLQuery>;
  52451. _timeElapsedQueryEnded: boolean;
  52452. }
  52453. }
  52454. declare module BABYLON {
  52455. /** @hidden */
  52456. export class _OcclusionDataStorage {
  52457. /** @hidden */
  52458. occlusionInternalRetryCounter: number;
  52459. /** @hidden */
  52460. isOcclusionQueryInProgress: boolean;
  52461. /** @hidden */
  52462. isOccluded: boolean;
  52463. /** @hidden */
  52464. occlusionRetryCount: number;
  52465. /** @hidden */
  52466. occlusionType: number;
  52467. /** @hidden */
  52468. occlusionQueryAlgorithmType: number;
  52469. }
  52470. interface Engine {
  52471. /**
  52472. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  52473. * @return the new query
  52474. */
  52475. createQuery(): WebGLQuery;
  52476. /**
  52477. * Delete and release a webGL query
  52478. * @param query defines the query to delete
  52479. * @return the current engine
  52480. */
  52481. deleteQuery(query: WebGLQuery): Engine;
  52482. /**
  52483. * Check if a given query has resolved and got its value
  52484. * @param query defines the query to check
  52485. * @returns true if the query got its value
  52486. */
  52487. isQueryResultAvailable(query: WebGLQuery): boolean;
  52488. /**
  52489. * Gets the value of a given query
  52490. * @param query defines the query to check
  52491. * @returns the value of the query
  52492. */
  52493. getQueryResult(query: WebGLQuery): number;
  52494. /**
  52495. * Initiates an occlusion query
  52496. * @param algorithmType defines the algorithm to use
  52497. * @param query defines the query to use
  52498. * @returns the current engine
  52499. * @see https://doc.babylonjs.com/features/occlusionquery
  52500. */
  52501. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  52502. /**
  52503. * Ends an occlusion query
  52504. * @see https://doc.babylonjs.com/features/occlusionquery
  52505. * @param algorithmType defines the algorithm to use
  52506. * @returns the current engine
  52507. */
  52508. endOcclusionQuery(algorithmType: number): Engine;
  52509. /**
  52510. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  52511. * Please note that only one query can be issued at a time
  52512. * @returns a time token used to track the time span
  52513. */
  52514. startTimeQuery(): Nullable<_TimeToken>;
  52515. /**
  52516. * Ends a time query
  52517. * @param token defines the token used to measure the time span
  52518. * @returns the time spent (in ns)
  52519. */
  52520. endTimeQuery(token: _TimeToken): int;
  52521. /** @hidden */
  52522. _currentNonTimestampToken: Nullable<_TimeToken>;
  52523. /** @hidden */
  52524. _createTimeQuery(): WebGLQuery;
  52525. /** @hidden */
  52526. _deleteTimeQuery(query: WebGLQuery): void;
  52527. /** @hidden */
  52528. _getGlAlgorithmType(algorithmType: number): number;
  52529. /** @hidden */
  52530. _getTimeQueryResult(query: WebGLQuery): any;
  52531. /** @hidden */
  52532. _getTimeQueryAvailability(query: WebGLQuery): any;
  52533. }
  52534. interface AbstractMesh {
  52535. /**
  52536. * Backing filed
  52537. * @hidden
  52538. */
  52539. __occlusionDataStorage: _OcclusionDataStorage;
  52540. /**
  52541. * Access property
  52542. * @hidden
  52543. */
  52544. _occlusionDataStorage: _OcclusionDataStorage;
  52545. /**
  52546. * 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.
  52547. * The default value is -1 which means don't break the query and wait till the result
  52548. * @see https://doc.babylonjs.com/features/occlusionquery
  52549. */
  52550. occlusionRetryCount: number;
  52551. /**
  52552. * 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:
  52553. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  52554. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  52555. * * 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.
  52556. * @see https://doc.babylonjs.com/features/occlusionquery
  52557. */
  52558. occlusionType: number;
  52559. /**
  52560. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  52561. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  52562. * * 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.
  52563. * @see https://doc.babylonjs.com/features/occlusionquery
  52564. */
  52565. occlusionQueryAlgorithmType: number;
  52566. /**
  52567. * 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
  52568. * @see https://doc.babylonjs.com/features/occlusionquery
  52569. */
  52570. isOccluded: boolean;
  52571. /**
  52572. * Flag to check the progress status of the query
  52573. * @see https://doc.babylonjs.com/features/occlusionquery
  52574. */
  52575. isOcclusionQueryInProgress: boolean;
  52576. }
  52577. }
  52578. declare module BABYLON {
  52579. /** @hidden */
  52580. export var _forceTransformFeedbackToBundle: boolean;
  52581. interface Engine {
  52582. /**
  52583. * Creates a webGL transform feedback object
  52584. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  52585. * @returns the webGL transform feedback object
  52586. */
  52587. createTransformFeedback(): WebGLTransformFeedback;
  52588. /**
  52589. * Delete a webGL transform feedback object
  52590. * @param value defines the webGL transform feedback object to delete
  52591. */
  52592. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  52593. /**
  52594. * Bind a webGL transform feedback object to the webgl context
  52595. * @param value defines the webGL transform feedback object to bind
  52596. */
  52597. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  52598. /**
  52599. * Begins a transform feedback operation
  52600. * @param usePoints defines if points or triangles must be used
  52601. */
  52602. beginTransformFeedback(usePoints: boolean): void;
  52603. /**
  52604. * Ends a transform feedback operation
  52605. */
  52606. endTransformFeedback(): void;
  52607. /**
  52608. * Specify the varyings to use with transform feedback
  52609. * @param program defines the associated webGL program
  52610. * @param value defines the list of strings representing the varying names
  52611. */
  52612. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  52613. /**
  52614. * Bind a webGL buffer for a transform feedback operation
  52615. * @param value defines the webGL buffer to bind
  52616. */
  52617. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  52618. }
  52619. }
  52620. declare module BABYLON {
  52621. /**
  52622. * Class used to define an additional view for the engine
  52623. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52624. */
  52625. export class EngineView {
  52626. /** Defines the canvas where to render the view */
  52627. target: HTMLCanvasElement;
  52628. /** Defines an optional camera used to render the view (will use active camera else) */
  52629. camera?: Camera;
  52630. }
  52631. interface Engine {
  52632. /**
  52633. * Gets or sets the HTML element to use for attaching events
  52634. */
  52635. inputElement: Nullable<HTMLElement>;
  52636. /**
  52637. * Gets the current engine view
  52638. * @see https://doc.babylonjs.com/how_to/multi_canvases
  52639. */
  52640. activeView: Nullable<EngineView>;
  52641. /** Gets or sets the list of views */
  52642. views: EngineView[];
  52643. /**
  52644. * Register a new child canvas
  52645. * @param canvas defines the canvas to register
  52646. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  52647. * @returns the associated view
  52648. */
  52649. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  52650. /**
  52651. * Remove a registered child canvas
  52652. * @param canvas defines the canvas to remove
  52653. * @returns the current engine
  52654. */
  52655. unRegisterView(canvas: HTMLCanvasElement): Engine;
  52656. }
  52657. }
  52658. declare module BABYLON {
  52659. interface Engine {
  52660. /** @hidden */
  52661. _excludedCompressedTextures: string[];
  52662. /** @hidden */
  52663. _textureFormatInUse: string;
  52664. /**
  52665. * Gets the list of texture formats supported
  52666. */
  52667. readonly texturesSupported: Array<string>;
  52668. /**
  52669. * Gets the texture format in use
  52670. */
  52671. readonly textureFormatInUse: Nullable<string>;
  52672. /**
  52673. * Set the compressed texture extensions or file names to skip.
  52674. *
  52675. * @param skippedFiles defines the list of those texture files you want to skip
  52676. * Example: [".dds", ".env", "myfile.png"]
  52677. */
  52678. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  52679. /**
  52680. * Set the compressed texture format to use, based on the formats you have, and the formats
  52681. * supported by the hardware / browser.
  52682. *
  52683. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  52684. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  52685. * to API arguments needed to compressed textures. This puts the burden on the container
  52686. * generator to house the arcane code for determining these for current & future formats.
  52687. *
  52688. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  52689. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  52690. *
  52691. * Note: The result of this call is not taken into account when a texture is base64.
  52692. *
  52693. * @param formatsAvailable defines the list of those format families you have created
  52694. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  52695. *
  52696. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  52697. * @returns The extension selected.
  52698. */
  52699. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  52700. }
  52701. }
  52702. declare module BABYLON {
  52703. /**
  52704. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  52705. */
  52706. export interface CubeMapInfo {
  52707. /**
  52708. * The pixel array for the front face.
  52709. * This is stored in format, left to right, up to down format.
  52710. */
  52711. front: Nullable<ArrayBufferView>;
  52712. /**
  52713. * The pixel array for the back face.
  52714. * This is stored in format, left to right, up to down format.
  52715. */
  52716. back: Nullable<ArrayBufferView>;
  52717. /**
  52718. * The pixel array for the left face.
  52719. * This is stored in format, left to right, up to down format.
  52720. */
  52721. left: Nullable<ArrayBufferView>;
  52722. /**
  52723. * The pixel array for the right face.
  52724. * This is stored in format, left to right, up to down format.
  52725. */
  52726. right: Nullable<ArrayBufferView>;
  52727. /**
  52728. * The pixel array for the up face.
  52729. * This is stored in format, left to right, up to down format.
  52730. */
  52731. up: Nullable<ArrayBufferView>;
  52732. /**
  52733. * The pixel array for the down face.
  52734. * This is stored in format, left to right, up to down format.
  52735. */
  52736. down: Nullable<ArrayBufferView>;
  52737. /**
  52738. * The size of the cubemap stored.
  52739. *
  52740. * Each faces will be size * size pixels.
  52741. */
  52742. size: number;
  52743. /**
  52744. * The format of the texture.
  52745. *
  52746. * RGBA, RGB.
  52747. */
  52748. format: number;
  52749. /**
  52750. * The type of the texture data.
  52751. *
  52752. * UNSIGNED_INT, FLOAT.
  52753. */
  52754. type: number;
  52755. /**
  52756. * Specifies whether the texture is in gamma space.
  52757. */
  52758. gammaSpace: boolean;
  52759. }
  52760. /**
  52761. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  52762. */
  52763. export class PanoramaToCubeMapTools {
  52764. private static FACE_LEFT;
  52765. private static FACE_RIGHT;
  52766. private static FACE_FRONT;
  52767. private static FACE_BACK;
  52768. private static FACE_DOWN;
  52769. private static FACE_UP;
  52770. /**
  52771. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  52772. *
  52773. * @param float32Array The source data.
  52774. * @param inputWidth The width of the input panorama.
  52775. * @param inputHeight The height of the input panorama.
  52776. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  52777. * @return The cubemap data
  52778. */
  52779. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  52780. private static CreateCubemapTexture;
  52781. private static CalcProjectionSpherical;
  52782. }
  52783. }
  52784. declare module BABYLON {
  52785. /**
  52786. * Helper class dealing with the extraction of spherical polynomial dataArray
  52787. * from a cube map.
  52788. */
  52789. export class CubeMapToSphericalPolynomialTools {
  52790. private static FileFaces;
  52791. /**
  52792. * Converts a texture to the according Spherical Polynomial data.
  52793. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52794. *
  52795. * @param texture The texture to extract the information from.
  52796. * @return The Spherical Polynomial data.
  52797. */
  52798. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  52799. /**
  52800. * Converts a cubemap to the according Spherical Polynomial data.
  52801. * This extracts the first 3 orders only as they are the only one used in the lighting.
  52802. *
  52803. * @param cubeInfo The Cube map to extract the information from.
  52804. * @return The Spherical Polynomial data.
  52805. */
  52806. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  52807. }
  52808. }
  52809. declare module BABYLON {
  52810. interface BaseTexture {
  52811. /**
  52812. * Get the polynomial representation of the texture data.
  52813. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  52814. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  52815. */
  52816. sphericalPolynomial: Nullable<SphericalPolynomial>;
  52817. }
  52818. }
  52819. declare module BABYLON {
  52820. /** @hidden */
  52821. export var rgbdEncodePixelShader: {
  52822. name: string;
  52823. shader: string;
  52824. };
  52825. }
  52826. declare module BABYLON {
  52827. /** @hidden */
  52828. export var rgbdDecodePixelShader: {
  52829. name: string;
  52830. shader: string;
  52831. };
  52832. }
  52833. declare module BABYLON {
  52834. /**
  52835. * Raw texture data and descriptor sufficient for WebGL texture upload
  52836. */
  52837. export interface EnvironmentTextureInfo {
  52838. /**
  52839. * Version of the environment map
  52840. */
  52841. version: number;
  52842. /**
  52843. * Width of image
  52844. */
  52845. width: number;
  52846. /**
  52847. * Irradiance information stored in the file.
  52848. */
  52849. irradiance: any;
  52850. /**
  52851. * Specular information stored in the file.
  52852. */
  52853. specular: any;
  52854. }
  52855. /**
  52856. * Defines One Image in the file. It requires only the position in the file
  52857. * as well as the length.
  52858. */
  52859. interface BufferImageData {
  52860. /**
  52861. * Length of the image data.
  52862. */
  52863. length: number;
  52864. /**
  52865. * Position of the data from the null terminator delimiting the end of the JSON.
  52866. */
  52867. position: number;
  52868. }
  52869. /**
  52870. * Defines the specular data enclosed in the file.
  52871. * This corresponds to the version 1 of the data.
  52872. */
  52873. export interface EnvironmentTextureSpecularInfoV1 {
  52874. /**
  52875. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  52876. */
  52877. specularDataPosition?: number;
  52878. /**
  52879. * This contains all the images data needed to reconstruct the cubemap.
  52880. */
  52881. mipmaps: Array<BufferImageData>;
  52882. /**
  52883. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  52884. */
  52885. lodGenerationScale: number;
  52886. }
  52887. /**
  52888. * Sets of helpers addressing the serialization and deserialization of environment texture
  52889. * stored in a BabylonJS env file.
  52890. * Those files are usually stored as .env files.
  52891. */
  52892. export class EnvironmentTextureTools {
  52893. /**
  52894. * Magic number identifying the env file.
  52895. */
  52896. private static _MagicBytes;
  52897. /**
  52898. * Gets the environment info from an env file.
  52899. * @param data The array buffer containing the .env bytes.
  52900. * @returns the environment file info (the json header) if successfully parsed.
  52901. */
  52902. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  52903. /**
  52904. * Creates an environment texture from a loaded cube texture.
  52905. * @param texture defines the cube texture to convert in env file
  52906. * @return a promise containing the environment data if succesfull.
  52907. */
  52908. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  52909. /**
  52910. * Creates a JSON representation of the spherical data.
  52911. * @param texture defines the texture containing the polynomials
  52912. * @return the JSON representation of the spherical info
  52913. */
  52914. private static _CreateEnvTextureIrradiance;
  52915. /**
  52916. * Creates the ArrayBufferViews used for initializing environment texture image data.
  52917. * @param data the image data
  52918. * @param info parameters that determine what views will be created for accessing the underlying buffer
  52919. * @return the views described by info providing access to the underlying buffer
  52920. */
  52921. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  52922. /**
  52923. * Uploads the texture info contained in the env file to the GPU.
  52924. * @param texture defines the internal texture to upload to
  52925. * @param data defines the data to load
  52926. * @param info defines the texture info retrieved through the GetEnvInfo method
  52927. * @returns a promise
  52928. */
  52929. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  52930. private static _OnImageReadyAsync;
  52931. /**
  52932. * Uploads the levels of image data to the GPU.
  52933. * @param texture defines the internal texture to upload to
  52934. * @param imageData defines the array buffer views of image data [mipmap][face]
  52935. * @returns a promise
  52936. */
  52937. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  52938. /**
  52939. * Uploads spherical polynomials information to the texture.
  52940. * @param texture defines the texture we are trying to upload the information to
  52941. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  52942. */
  52943. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  52944. /** @hidden */
  52945. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52946. }
  52947. }
  52948. declare module BABYLON {
  52949. /**
  52950. * Class used to inline functions in shader code
  52951. */
  52952. export class ShaderCodeInliner {
  52953. private static readonly _RegexpFindFunctionNameAndType;
  52954. private _sourceCode;
  52955. private _functionDescr;
  52956. private _numMaxIterations;
  52957. /** Gets or sets the token used to mark the functions to inline */
  52958. inlineToken: string;
  52959. /** Gets or sets the debug mode */
  52960. debug: boolean;
  52961. /** Gets the code after the inlining process */
  52962. get code(): string;
  52963. /**
  52964. * Initializes the inliner
  52965. * @param sourceCode shader code source to inline
  52966. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  52967. */
  52968. constructor(sourceCode: string, numMaxIterations?: number);
  52969. /**
  52970. * Start the processing of the shader code
  52971. */
  52972. processCode(): void;
  52973. private _collectFunctions;
  52974. private _processInlining;
  52975. private _extractBetweenMarkers;
  52976. private _skipWhitespaces;
  52977. private _removeComments;
  52978. private _replaceFunctionCallsByCode;
  52979. private _findBackward;
  52980. private _escapeRegExp;
  52981. private _replaceNames;
  52982. }
  52983. }
  52984. declare module BABYLON {
  52985. /**
  52986. * Container for accessors for natively-stored mesh data buffers.
  52987. */
  52988. class NativeDataBuffer extends DataBuffer {
  52989. /**
  52990. * Accessor value used to identify/retrieve a natively-stored index buffer.
  52991. */
  52992. nativeIndexBuffer?: any;
  52993. /**
  52994. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  52995. */
  52996. nativeVertexBuffer?: any;
  52997. }
  52998. /** @hidden */
  52999. class NativeTexture extends InternalTexture {
  53000. getInternalTexture(): InternalTexture;
  53001. getViewCount(): number;
  53002. }
  53003. /** @hidden */
  53004. export class NativeEngine extends Engine {
  53005. private readonly _native;
  53006. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53007. private readonly INVALID_HANDLE;
  53008. private _boundBuffersVertexArray;
  53009. private _currentDepthTest;
  53010. getHardwareScalingLevel(): number;
  53011. constructor();
  53012. dispose(): void;
  53013. /**
  53014. * Can be used to override the current requestAnimationFrame requester.
  53015. * @hidden
  53016. */
  53017. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53018. /**
  53019. * Override default engine behavior.
  53020. * @param color
  53021. * @param backBuffer
  53022. * @param depth
  53023. * @param stencil
  53024. */
  53025. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53026. /**
  53027. * Gets host document
  53028. * @returns the host document object
  53029. */
  53030. getHostDocument(): Nullable<Document>;
  53031. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53032. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53033. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53034. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  53035. [key: string]: VertexBuffer;
  53036. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  53037. bindBuffers(vertexBuffers: {
  53038. [key: string]: VertexBuffer;
  53039. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  53040. recordVertexArrayObject(vertexBuffers: {
  53041. [key: string]: VertexBuffer;
  53042. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53043. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53044. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53045. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53046. /**
  53047. * Draw a list of indexed primitives
  53048. * @param fillMode defines the primitive to use
  53049. * @param indexStart defines the starting index
  53050. * @param indexCount defines the number of index to draw
  53051. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53052. */
  53053. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53054. /**
  53055. * Draw a list of unindexed primitives
  53056. * @param fillMode defines the primitive to use
  53057. * @param verticesStart defines the index of first vertex to draw
  53058. * @param verticesCount defines the count of vertices to draw
  53059. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53060. */
  53061. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53062. createPipelineContext(): IPipelineContext;
  53063. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53064. /** @hidden */
  53065. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53066. /** @hidden */
  53067. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53068. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53069. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53070. protected _setProgram(program: WebGLProgram): void;
  53071. _releaseEffect(effect: Effect): void;
  53072. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53073. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53074. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53075. bindSamplers(effect: Effect): void;
  53076. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53077. getRenderWidth(useScreen?: boolean): number;
  53078. getRenderHeight(useScreen?: boolean): number;
  53079. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53080. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53081. /**
  53082. * Set the z offset to apply to current rendering
  53083. * @param value defines the offset to apply
  53084. */
  53085. setZOffset(value: number): void;
  53086. /**
  53087. * Gets the current value of the zOffset
  53088. * @returns the current zOffset state
  53089. */
  53090. getZOffset(): number;
  53091. /**
  53092. * Enable or disable depth buffering
  53093. * @param enable defines the state to set
  53094. */
  53095. setDepthBuffer(enable: boolean): void;
  53096. /**
  53097. * Gets a boolean indicating if depth writing is enabled
  53098. * @returns the current depth writing state
  53099. */
  53100. getDepthWrite(): boolean;
  53101. setDepthFunctionToGreater(): void;
  53102. setDepthFunctionToGreaterOrEqual(): void;
  53103. setDepthFunctionToLess(): void;
  53104. setDepthFunctionToLessOrEqual(): void;
  53105. /**
  53106. * Enable or disable depth writing
  53107. * @param enable defines the state to set
  53108. */
  53109. setDepthWrite(enable: boolean): void;
  53110. /**
  53111. * Enable or disable color writing
  53112. * @param enable defines the state to set
  53113. */
  53114. setColorWrite(enable: boolean): void;
  53115. /**
  53116. * Gets a boolean indicating if color writing is enabled
  53117. * @returns the current color writing state
  53118. */
  53119. getColorWrite(): boolean;
  53120. /**
  53121. * Sets alpha constants used by some alpha blending modes
  53122. * @param r defines the red component
  53123. * @param g defines the green component
  53124. * @param b defines the blue component
  53125. * @param a defines the alpha component
  53126. */
  53127. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53128. /**
  53129. * Sets the current alpha mode
  53130. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53131. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53132. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53133. */
  53134. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53135. /**
  53136. * Gets the current alpha mode
  53137. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53138. * @returns the current alpha mode
  53139. */
  53140. getAlphaMode(): number;
  53141. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  53142. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53143. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53144. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53145. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  53146. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53147. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53148. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53149. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  53150. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  53151. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  53152. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  53153. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  53154. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  53155. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53156. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  53157. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  53158. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  53159. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  53160. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  53161. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  53162. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  53163. wipeCaches(bruteForce?: boolean): void;
  53164. _createTexture(): WebGLTexture;
  53165. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  53166. /**
  53167. * Usually called from Texture.ts.
  53168. * Passed information to create a WebGLTexture
  53169. * @param url defines a value which contains one of the following:
  53170. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  53171. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  53172. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  53173. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  53174. * @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)
  53175. * @param scene needed for loading to the correct scene
  53176. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  53177. * @param onLoad optional callback to be called upon successful completion
  53178. * @param onError optional callback to be called upon failure
  53179. * @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
  53180. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  53181. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  53182. * @param forcedExtension defines the extension to use to pick the right loader
  53183. * @param mimeType defines an optional mime type
  53184. * @returns a InternalTexture for assignment back into BABYLON.Texture
  53185. */
  53186. 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;
  53187. /**
  53188. * Creates a cube texture
  53189. * @param rootUrl defines the url where the files to load is located
  53190. * @param scene defines the current scene
  53191. * @param files defines the list of files to load (1 per face)
  53192. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  53193. * @param onLoad defines an optional callback raised when the texture is loaded
  53194. * @param onError defines an optional callback raised if there is an issue to load the texture
  53195. * @param format defines the format of the data
  53196. * @param forcedExtension defines the extension to use to pick the right loader
  53197. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  53198. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  53199. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  53200. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  53201. * @returns the cube texture as an InternalTexture
  53202. */
  53203. 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;
  53204. createRenderTargetTexture(size: number | {
  53205. width: number;
  53206. height: number;
  53207. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  53208. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  53209. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  53210. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  53211. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  53212. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  53213. /**
  53214. * Updates a dynamic vertex buffer.
  53215. * @param vertexBuffer the vertex buffer to update
  53216. * @param data the data used to update the vertex buffer
  53217. * @param byteOffset the byte offset of the data (optional)
  53218. * @param byteLength the byte length of the data (optional)
  53219. */
  53220. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  53221. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  53222. private _updateAnisotropicLevel;
  53223. private _getAddressMode;
  53224. /** @hidden */
  53225. _bindTexture(channel: number, texture: InternalTexture): void;
  53226. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  53227. releaseEffects(): void;
  53228. /** @hidden */
  53229. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53230. /** @hidden */
  53231. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53232. /** @hidden */
  53233. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53234. /** @hidden */
  53235. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53236. private _getNativeSamplingMode;
  53237. private _getNativeTextureFormat;
  53238. private _getNativeAlphaMode;
  53239. private _getNativeAttribType;
  53240. }
  53241. }
  53242. declare module BABYLON {
  53243. /**
  53244. * Gather the list of clipboard event types as constants.
  53245. */
  53246. export class ClipboardEventTypes {
  53247. /**
  53248. * The clipboard event is fired when a copy command is active (pressed).
  53249. */
  53250. static readonly COPY: number;
  53251. /**
  53252. * The clipboard event is fired when a cut command is active (pressed).
  53253. */
  53254. static readonly CUT: number;
  53255. /**
  53256. * The clipboard event is fired when a paste command is active (pressed).
  53257. */
  53258. static readonly PASTE: number;
  53259. }
  53260. /**
  53261. * This class is used to store clipboard related info for the onClipboardObservable event.
  53262. */
  53263. export class ClipboardInfo {
  53264. /**
  53265. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53266. */
  53267. type: number;
  53268. /**
  53269. * Defines the related dom event
  53270. */
  53271. event: ClipboardEvent;
  53272. /**
  53273. *Creates an instance of ClipboardInfo.
  53274. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  53275. * @param event Defines the related dom event
  53276. */
  53277. constructor(
  53278. /**
  53279. * Defines the type of event (BABYLON.ClipboardEventTypes)
  53280. */
  53281. type: number,
  53282. /**
  53283. * Defines the related dom event
  53284. */
  53285. event: ClipboardEvent);
  53286. /**
  53287. * Get the clipboard event's type from the keycode.
  53288. * @param keyCode Defines the keyCode for the current keyboard event.
  53289. * @return {number}
  53290. */
  53291. static GetTypeFromCharacter(keyCode: number): number;
  53292. }
  53293. }
  53294. declare module BABYLON {
  53295. /**
  53296. * Google Daydream controller
  53297. */
  53298. export class DaydreamController extends WebVRController {
  53299. /**
  53300. * Base Url for the controller model.
  53301. */
  53302. static MODEL_BASE_URL: string;
  53303. /**
  53304. * File name for the controller model.
  53305. */
  53306. static MODEL_FILENAME: string;
  53307. /**
  53308. * Gamepad Id prefix used to identify Daydream Controller.
  53309. */
  53310. static readonly GAMEPAD_ID_PREFIX: string;
  53311. /**
  53312. * Creates a new DaydreamController from a gamepad
  53313. * @param vrGamepad the gamepad that the controller should be created from
  53314. */
  53315. constructor(vrGamepad: any);
  53316. /**
  53317. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53318. * @param scene scene in which to add meshes
  53319. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53320. */
  53321. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53322. /**
  53323. * Called once for each button that changed state since the last frame
  53324. * @param buttonIdx Which button index changed
  53325. * @param state New state of the button
  53326. * @param changes Which properties on the state changed since last frame
  53327. */
  53328. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53329. }
  53330. }
  53331. declare module BABYLON {
  53332. /**
  53333. * Gear VR Controller
  53334. */
  53335. export class GearVRController extends WebVRController {
  53336. /**
  53337. * Base Url for the controller model.
  53338. */
  53339. static MODEL_BASE_URL: string;
  53340. /**
  53341. * File name for the controller model.
  53342. */
  53343. static MODEL_FILENAME: string;
  53344. /**
  53345. * Gamepad Id prefix used to identify this controller.
  53346. */
  53347. static readonly GAMEPAD_ID_PREFIX: string;
  53348. private readonly _buttonIndexToObservableNameMap;
  53349. /**
  53350. * Creates a new GearVRController from a gamepad
  53351. * @param vrGamepad the gamepad that the controller should be created from
  53352. */
  53353. constructor(vrGamepad: any);
  53354. /**
  53355. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53356. * @param scene scene in which to add meshes
  53357. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53358. */
  53359. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53360. /**
  53361. * Called once for each button that changed state since the last frame
  53362. * @param buttonIdx Which button index changed
  53363. * @param state New state of the button
  53364. * @param changes Which properties on the state changed since last frame
  53365. */
  53366. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53367. }
  53368. }
  53369. declare module BABYLON {
  53370. /**
  53371. * Generic Controller
  53372. */
  53373. export class GenericController extends WebVRController {
  53374. /**
  53375. * Base Url for the controller model.
  53376. */
  53377. static readonly MODEL_BASE_URL: string;
  53378. /**
  53379. * File name for the controller model.
  53380. */
  53381. static readonly MODEL_FILENAME: string;
  53382. /**
  53383. * Creates a new GenericController from a gamepad
  53384. * @param vrGamepad the gamepad that the controller should be created from
  53385. */
  53386. constructor(vrGamepad: any);
  53387. /**
  53388. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53389. * @param scene scene in which to add meshes
  53390. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53391. */
  53392. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53393. /**
  53394. * Called once for each button that changed state since the last frame
  53395. * @param buttonIdx Which button index changed
  53396. * @param state New state of the button
  53397. * @param changes Which properties on the state changed since last frame
  53398. */
  53399. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53400. }
  53401. }
  53402. declare module BABYLON {
  53403. /**
  53404. * Oculus Touch Controller
  53405. */
  53406. export class OculusTouchController extends WebVRController {
  53407. /**
  53408. * Base Url for the controller model.
  53409. */
  53410. static MODEL_BASE_URL: string;
  53411. /**
  53412. * File name for the left controller model.
  53413. */
  53414. static MODEL_LEFT_FILENAME: string;
  53415. /**
  53416. * File name for the right controller model.
  53417. */
  53418. static MODEL_RIGHT_FILENAME: string;
  53419. /**
  53420. * Base Url for the Quest controller model.
  53421. */
  53422. static QUEST_MODEL_BASE_URL: string;
  53423. /**
  53424. * @hidden
  53425. * If the controllers are running on a device that needs the updated Quest controller models
  53426. */
  53427. static _IsQuest: boolean;
  53428. /**
  53429. * Fired when the secondary trigger on this controller is modified
  53430. */
  53431. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  53432. /**
  53433. * Fired when the thumb rest on this controller is modified
  53434. */
  53435. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  53436. /**
  53437. * Creates a new OculusTouchController from a gamepad
  53438. * @param vrGamepad the gamepad that the controller should be created from
  53439. */
  53440. constructor(vrGamepad: any);
  53441. /**
  53442. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53443. * @param scene scene in which to add meshes
  53444. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53445. */
  53446. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53447. /**
  53448. * Fired when the A button on this controller is modified
  53449. */
  53450. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53451. /**
  53452. * Fired when the B button on this controller is modified
  53453. */
  53454. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53455. /**
  53456. * Fired when the X button on this controller is modified
  53457. */
  53458. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53459. /**
  53460. * Fired when the Y button on this controller is modified
  53461. */
  53462. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53463. /**
  53464. * Called once for each button that changed state since the last frame
  53465. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  53466. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  53467. * 2) secondary trigger (same)
  53468. * 3) A (right) X (left), touch, pressed = value
  53469. * 4) B / Y
  53470. * 5) thumb rest
  53471. * @param buttonIdx Which button index changed
  53472. * @param state New state of the button
  53473. * @param changes Which properties on the state changed since last frame
  53474. */
  53475. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53476. }
  53477. }
  53478. declare module BABYLON {
  53479. /**
  53480. * Vive Controller
  53481. */
  53482. export class ViveController extends WebVRController {
  53483. /**
  53484. * Base Url for the controller model.
  53485. */
  53486. static MODEL_BASE_URL: string;
  53487. /**
  53488. * File name for the controller model.
  53489. */
  53490. static MODEL_FILENAME: string;
  53491. /**
  53492. * Creates a new ViveController from a gamepad
  53493. * @param vrGamepad the gamepad that the controller should be created from
  53494. */
  53495. constructor(vrGamepad: any);
  53496. /**
  53497. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53498. * @param scene scene in which to add meshes
  53499. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53500. */
  53501. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  53502. /**
  53503. * Fired when the left button on this controller is modified
  53504. */
  53505. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53506. /**
  53507. * Fired when the right button on this controller is modified
  53508. */
  53509. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53510. /**
  53511. * Fired when the menu button on this controller is modified
  53512. */
  53513. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53514. /**
  53515. * Called once for each button that changed state since the last frame
  53516. * Vive mapping:
  53517. * 0: touchpad
  53518. * 1: trigger
  53519. * 2: left AND right buttons
  53520. * 3: menu button
  53521. * @param buttonIdx Which button index changed
  53522. * @param state New state of the button
  53523. * @param changes Which properties on the state changed since last frame
  53524. */
  53525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53526. }
  53527. }
  53528. declare module BABYLON {
  53529. /**
  53530. * Defines the WindowsMotionController object that the state of the windows motion controller
  53531. */
  53532. export class WindowsMotionController extends WebVRController {
  53533. /**
  53534. * The base url used to load the left and right controller models
  53535. */
  53536. static MODEL_BASE_URL: string;
  53537. /**
  53538. * The name of the left controller model file
  53539. */
  53540. static MODEL_LEFT_FILENAME: string;
  53541. /**
  53542. * The name of the right controller model file
  53543. */
  53544. static MODEL_RIGHT_FILENAME: string;
  53545. /**
  53546. * The controller name prefix for this controller type
  53547. */
  53548. static readonly GAMEPAD_ID_PREFIX: string;
  53549. /**
  53550. * The controller id pattern for this controller type
  53551. */
  53552. private static readonly GAMEPAD_ID_PATTERN;
  53553. private _loadedMeshInfo;
  53554. protected readonly _mapping: {
  53555. buttons: string[];
  53556. buttonMeshNames: {
  53557. trigger: string;
  53558. menu: string;
  53559. grip: string;
  53560. thumbstick: string;
  53561. trackpad: string;
  53562. };
  53563. buttonObservableNames: {
  53564. trigger: string;
  53565. menu: string;
  53566. grip: string;
  53567. thumbstick: string;
  53568. trackpad: string;
  53569. };
  53570. axisMeshNames: string[];
  53571. pointingPoseMeshName: string;
  53572. };
  53573. /**
  53574. * Fired when the trackpad on this controller is clicked
  53575. */
  53576. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53577. /**
  53578. * Fired when the trackpad on this controller is modified
  53579. */
  53580. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53581. /**
  53582. * The current x and y values of this controller's trackpad
  53583. */
  53584. trackpad: StickValues;
  53585. /**
  53586. * Creates a new WindowsMotionController from a gamepad
  53587. * @param vrGamepad the gamepad that the controller should be created from
  53588. */
  53589. constructor(vrGamepad: any);
  53590. /**
  53591. * Fired when the trigger on this controller is modified
  53592. */
  53593. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53594. /**
  53595. * Fired when the menu button on this controller is modified
  53596. */
  53597. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53598. /**
  53599. * Fired when the grip button on this controller is modified
  53600. */
  53601. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53602. /**
  53603. * Fired when the thumbstick button on this controller is modified
  53604. */
  53605. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53606. /**
  53607. * Fired when the touchpad button on this controller is modified
  53608. */
  53609. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53610. /**
  53611. * Fired when the touchpad values on this controller are modified
  53612. */
  53613. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  53614. protected _updateTrackpad(): void;
  53615. /**
  53616. * Called once per frame by the engine.
  53617. */
  53618. update(): void;
  53619. /**
  53620. * Called once for each button that changed state since the last frame
  53621. * @param buttonIdx Which button index changed
  53622. * @param state New state of the button
  53623. * @param changes Which properties on the state changed since last frame
  53624. */
  53625. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  53626. /**
  53627. * Moves the buttons on the controller mesh based on their current state
  53628. * @param buttonName the name of the button to move
  53629. * @param buttonValue the value of the button which determines the buttons new position
  53630. */
  53631. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  53632. /**
  53633. * Moves the axis on the controller mesh based on its current state
  53634. * @param axis the index of the axis
  53635. * @param axisValue the value of the axis which determines the meshes new position
  53636. * @hidden
  53637. */
  53638. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  53639. /**
  53640. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  53641. * @param scene scene in which to add meshes
  53642. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  53643. */
  53644. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  53645. /**
  53646. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  53647. * can be transformed by button presses and axes values, based on this._mapping.
  53648. *
  53649. * @param scene scene in which the meshes exist
  53650. * @param meshes list of meshes that make up the controller model to process
  53651. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  53652. */
  53653. private processModel;
  53654. private createMeshInfo;
  53655. /**
  53656. * Gets the ray of the controller in the direction the controller is pointing
  53657. * @param length the length the resulting ray should be
  53658. * @returns a ray in the direction the controller is pointing
  53659. */
  53660. getForwardRay(length?: number): Ray;
  53661. /**
  53662. * Disposes of the controller
  53663. */
  53664. dispose(): void;
  53665. }
  53666. /**
  53667. * This class represents a new windows motion controller in XR.
  53668. */
  53669. export class XRWindowsMotionController extends WindowsMotionController {
  53670. /**
  53671. * Changing the original WIndowsMotionController mapping to fir the new mapping
  53672. */
  53673. protected readonly _mapping: {
  53674. buttons: string[];
  53675. buttonMeshNames: {
  53676. trigger: string;
  53677. menu: string;
  53678. grip: string;
  53679. thumbstick: string;
  53680. trackpad: string;
  53681. };
  53682. buttonObservableNames: {
  53683. trigger: string;
  53684. menu: string;
  53685. grip: string;
  53686. thumbstick: string;
  53687. trackpad: string;
  53688. };
  53689. axisMeshNames: string[];
  53690. pointingPoseMeshName: string;
  53691. };
  53692. /**
  53693. * Construct a new XR-Based windows motion controller
  53694. *
  53695. * @param gamepadInfo the gamepad object from the browser
  53696. */
  53697. constructor(gamepadInfo: any);
  53698. /**
  53699. * holds the thumbstick values (X,Y)
  53700. */
  53701. thumbstickValues: StickValues;
  53702. /**
  53703. * Fired when the thumbstick on this controller is clicked
  53704. */
  53705. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  53706. /**
  53707. * Fired when the thumbstick on this controller is modified
  53708. */
  53709. onThumbstickValuesChangedObservable: Observable<StickValues>;
  53710. /**
  53711. * Fired when the touchpad button on this controller is modified
  53712. */
  53713. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  53714. /**
  53715. * Fired when the touchpad values on this controller are modified
  53716. */
  53717. onTrackpadValuesChangedObservable: Observable<StickValues>;
  53718. /**
  53719. * Fired when the thumbstick button on this controller is modified
  53720. * here to prevent breaking changes
  53721. */
  53722. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  53723. /**
  53724. * updating the thumbstick(!) and not the trackpad.
  53725. * This is named this way due to the difference between WebVR and XR and to avoid
  53726. * changing the parent class.
  53727. */
  53728. protected _updateTrackpad(): void;
  53729. /**
  53730. * Disposes the class with joy
  53731. */
  53732. dispose(): void;
  53733. }
  53734. }
  53735. declare module BABYLON {
  53736. /**
  53737. * Class containing static functions to help procedurally build meshes
  53738. */
  53739. export class PolyhedronBuilder {
  53740. /**
  53741. * Creates a polyhedron mesh
  53742. * * 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
  53743. * * The parameter `size` (positive float, default 1) sets the polygon size
  53744. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  53745. * * 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`
  53746. * * 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
  53747. * * 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)`)
  53748. * * 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
  53749. * * 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
  53750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53751. * * 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
  53752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53753. * @param name defines the name of the mesh
  53754. * @param options defines the options used to create the mesh
  53755. * @param scene defines the hosting scene
  53756. * @returns the polyhedron mesh
  53757. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  53758. */
  53759. static CreatePolyhedron(name: string, options: {
  53760. type?: number;
  53761. size?: number;
  53762. sizeX?: number;
  53763. sizeY?: number;
  53764. sizeZ?: number;
  53765. custom?: any;
  53766. faceUV?: Vector4[];
  53767. faceColors?: Color4[];
  53768. flat?: boolean;
  53769. updatable?: boolean;
  53770. sideOrientation?: number;
  53771. frontUVs?: Vector4;
  53772. backUVs?: Vector4;
  53773. }, scene?: Nullable<Scene>): Mesh;
  53774. }
  53775. }
  53776. declare module BABYLON {
  53777. /**
  53778. * Gizmo that enables scaling a mesh along 3 axis
  53779. */
  53780. export class ScaleGizmo extends Gizmo {
  53781. /**
  53782. * Internal gizmo used for interactions on the x axis
  53783. */
  53784. xGizmo: AxisScaleGizmo;
  53785. /**
  53786. * Internal gizmo used for interactions on the y axis
  53787. */
  53788. yGizmo: AxisScaleGizmo;
  53789. /**
  53790. * Internal gizmo used for interactions on the z axis
  53791. */
  53792. zGizmo: AxisScaleGizmo;
  53793. /**
  53794. * Internal gizmo used to scale all axis equally
  53795. */
  53796. uniformScaleGizmo: AxisScaleGizmo;
  53797. private _meshAttached;
  53798. private _nodeAttached;
  53799. private _snapDistance;
  53800. private _uniformScalingMesh;
  53801. private _octahedron;
  53802. private _sensitivity;
  53803. /** Fires an event when any of it's sub gizmos are dragged */
  53804. onDragStartObservable: Observable<unknown>;
  53805. /** Fires an event when any of it's sub gizmos are released from dragging */
  53806. onDragEndObservable: Observable<unknown>;
  53807. get attachedMesh(): Nullable<AbstractMesh>;
  53808. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53809. get attachedNode(): Nullable<Node>;
  53810. set attachedNode(node: Nullable<Node>);
  53811. /**
  53812. * True when the mouse pointer is hovering a gizmo mesh
  53813. */
  53814. get isHovered(): boolean;
  53815. /**
  53816. * Creates a ScaleGizmo
  53817. * @param gizmoLayer The utility layer the gizmo will be added to
  53818. * @param thickness display gizmo axis thickness
  53819. */
  53820. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53821. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53822. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53823. /**
  53824. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53825. */
  53826. set snapDistance(value: number);
  53827. get snapDistance(): number;
  53828. /**
  53829. * Ratio for the scale of the gizmo (Default: 1)
  53830. */
  53831. set scaleRatio(value: number);
  53832. get scaleRatio(): number;
  53833. /**
  53834. * Sensitivity factor for dragging (Default: 1)
  53835. */
  53836. set sensitivity(value: number);
  53837. get sensitivity(): number;
  53838. /**
  53839. * Disposes of the gizmo
  53840. */
  53841. dispose(): void;
  53842. }
  53843. }
  53844. declare module BABYLON {
  53845. /**
  53846. * Single axis scale gizmo
  53847. */
  53848. export class AxisScaleGizmo extends Gizmo {
  53849. /**
  53850. * Drag behavior responsible for the gizmos dragging interactions
  53851. */
  53852. dragBehavior: PointerDragBehavior;
  53853. private _pointerObserver;
  53854. /**
  53855. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53856. */
  53857. snapDistance: number;
  53858. /**
  53859. * Event that fires each time the gizmo snaps to a new location.
  53860. * * snapDistance is the the change in distance
  53861. */
  53862. onSnapObservable: Observable<{
  53863. snapDistance: number;
  53864. }>;
  53865. /**
  53866. * If the scaling operation should be done on all axis (default: false)
  53867. */
  53868. uniformScaling: boolean;
  53869. /**
  53870. * Custom sensitivity value for the drag strength
  53871. */
  53872. sensitivity: number;
  53873. private _isEnabled;
  53874. private _parent;
  53875. private _arrow;
  53876. private _coloredMaterial;
  53877. private _hoverMaterial;
  53878. /**
  53879. * Creates an AxisScaleGizmo
  53880. * @param gizmoLayer The utility layer the gizmo will be added to
  53881. * @param dragAxis The axis which the gizmo will be able to scale on
  53882. * @param color The color of the gizmo
  53883. * @param thickness display gizmo axis thickness
  53884. */
  53885. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  53886. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53887. /**
  53888. * If the gizmo is enabled
  53889. */
  53890. set isEnabled(value: boolean);
  53891. get isEnabled(): boolean;
  53892. /**
  53893. * Disposes of the gizmo
  53894. */
  53895. dispose(): void;
  53896. /**
  53897. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53898. * @param mesh The mesh to replace the default mesh of the gizmo
  53899. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  53900. */
  53901. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  53902. }
  53903. }
  53904. declare module BABYLON {
  53905. /**
  53906. * Bounding box gizmo
  53907. */
  53908. export class BoundingBoxGizmo extends Gizmo {
  53909. private _lineBoundingBox;
  53910. private _rotateSpheresParent;
  53911. private _scaleBoxesParent;
  53912. private _boundingDimensions;
  53913. private _renderObserver;
  53914. private _pointerObserver;
  53915. private _scaleDragSpeed;
  53916. private _tmpQuaternion;
  53917. private _tmpVector;
  53918. private _tmpRotationMatrix;
  53919. /**
  53920. * 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)
  53921. */
  53922. ignoreChildren: boolean;
  53923. /**
  53924. * 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)
  53925. */
  53926. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  53927. /**
  53928. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  53929. */
  53930. rotationSphereSize: number;
  53931. /**
  53932. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  53933. */
  53934. scaleBoxSize: number;
  53935. /**
  53936. * 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)
  53937. */
  53938. fixedDragMeshScreenSize: boolean;
  53939. /**
  53940. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  53941. */
  53942. fixedDragMeshScreenSizeDistanceFactor: number;
  53943. /**
  53944. * Fired when a rotation sphere or scale box is dragged
  53945. */
  53946. onDragStartObservable: Observable<{}>;
  53947. /**
  53948. * Fired when a scale box is dragged
  53949. */
  53950. onScaleBoxDragObservable: Observable<{}>;
  53951. /**
  53952. * Fired when a scale box drag is ended
  53953. */
  53954. onScaleBoxDragEndObservable: Observable<{}>;
  53955. /**
  53956. * Fired when a rotation sphere is dragged
  53957. */
  53958. onRotationSphereDragObservable: Observable<{}>;
  53959. /**
  53960. * Fired when a rotation sphere drag is ended
  53961. */
  53962. onRotationSphereDragEndObservable: Observable<{}>;
  53963. /**
  53964. * Relative bounding box pivot used when scaling the attached node. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  53965. */
  53966. scalePivot: Nullable<Vector3>;
  53967. /**
  53968. * Mesh used as a pivot to rotate the attached node
  53969. */
  53970. private _anchorMesh;
  53971. private _existingMeshScale;
  53972. private _dragMesh;
  53973. private pointerDragBehavior;
  53974. private coloredMaterial;
  53975. private hoverColoredMaterial;
  53976. /**
  53977. * Sets the color of the bounding box gizmo
  53978. * @param color the color to set
  53979. */
  53980. setColor(color: Color3): void;
  53981. /**
  53982. * Creates an BoundingBoxGizmo
  53983. * @param gizmoLayer The utility layer the gizmo will be added to
  53984. * @param color The color of the gizmo
  53985. */
  53986. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  53987. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  53988. private _selectNode;
  53989. /**
  53990. * Updates the bounding box information for the Gizmo
  53991. */
  53992. updateBoundingBox(): void;
  53993. private _updateRotationSpheres;
  53994. private _updateScaleBoxes;
  53995. /**
  53996. * Enables rotation on the specified axis and disables rotation on the others
  53997. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  53998. */
  53999. setEnabledRotationAxis(axis: string): void;
  54000. /**
  54001. * Enables/disables scaling
  54002. * @param enable if scaling should be enabled
  54003. * @param homogeneousScaling defines if scaling should only be homogeneous
  54004. */
  54005. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54006. private _updateDummy;
  54007. /**
  54008. * Enables a pointer drag behavior on the bounding box of the gizmo
  54009. */
  54010. enableDragBehavior(): void;
  54011. /**
  54012. * Disposes of the gizmo
  54013. */
  54014. dispose(): void;
  54015. /**
  54016. * 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)
  54017. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54018. * @returns the bounding box mesh with the passed in mesh as a child
  54019. */
  54020. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54021. /**
  54022. * CustomMeshes are not supported by this gizmo
  54023. * @param mesh The mesh to replace the default mesh of the gizmo
  54024. */
  54025. setCustomMesh(mesh: Mesh): void;
  54026. }
  54027. }
  54028. declare module BABYLON {
  54029. /**
  54030. * Single plane rotation gizmo
  54031. */
  54032. export class PlaneRotationGizmo extends Gizmo {
  54033. /**
  54034. * Drag behavior responsible for the gizmos dragging interactions
  54035. */
  54036. dragBehavior: PointerDragBehavior;
  54037. private _pointerObserver;
  54038. /**
  54039. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54040. */
  54041. snapDistance: number;
  54042. /**
  54043. * Event that fires each time the gizmo snaps to a new location.
  54044. * * snapDistance is the the change in distance
  54045. */
  54046. onSnapObservable: Observable<{
  54047. snapDistance: number;
  54048. }>;
  54049. private _isEnabled;
  54050. private _parent;
  54051. /**
  54052. * Creates a PlaneRotationGizmo
  54053. * @param gizmoLayer The utility layer the gizmo will be added to
  54054. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54055. * @param color The color of the gizmo
  54056. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54057. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54058. * @param thickness display gizmo axis thickness
  54059. */
  54060. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  54061. protected _attachedNodeChanged(value: Nullable<Node>): void;
  54062. /**
  54063. * If the gizmo is enabled
  54064. */
  54065. set isEnabled(value: boolean);
  54066. get isEnabled(): boolean;
  54067. /**
  54068. * Disposes of the gizmo
  54069. */
  54070. dispose(): void;
  54071. }
  54072. }
  54073. declare module BABYLON {
  54074. /**
  54075. * Gizmo that enables rotating a mesh along 3 axis
  54076. */
  54077. export class RotationGizmo extends Gizmo {
  54078. /**
  54079. * Internal gizmo used for interactions on the x axis
  54080. */
  54081. xGizmo: PlaneRotationGizmo;
  54082. /**
  54083. * Internal gizmo used for interactions on the y axis
  54084. */
  54085. yGizmo: PlaneRotationGizmo;
  54086. /**
  54087. * Internal gizmo used for interactions on the z axis
  54088. */
  54089. zGizmo: PlaneRotationGizmo;
  54090. /** Fires an event when any of it's sub gizmos are dragged */
  54091. onDragStartObservable: Observable<unknown>;
  54092. /** Fires an event when any of it's sub gizmos are released from dragging */
  54093. onDragEndObservable: Observable<unknown>;
  54094. private _meshAttached;
  54095. private _nodeAttached;
  54096. get attachedMesh(): Nullable<AbstractMesh>;
  54097. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54098. get attachedNode(): Nullable<Node>;
  54099. set attachedNode(node: Nullable<Node>);
  54100. /**
  54101. * True when the mouse pointer is hovering a gizmo mesh
  54102. */
  54103. get isHovered(): boolean;
  54104. /**
  54105. * Creates a RotationGizmo
  54106. * @param gizmoLayer The utility layer the gizmo will be added to
  54107. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54108. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54109. * @param thickness display gizmo axis thickness
  54110. */
  54111. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  54112. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54113. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54114. /**
  54115. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54116. */
  54117. set snapDistance(value: number);
  54118. get snapDistance(): number;
  54119. /**
  54120. * Ratio for the scale of the gizmo (Default: 1)
  54121. */
  54122. set scaleRatio(value: number);
  54123. get scaleRatio(): number;
  54124. /**
  54125. * Disposes of the gizmo
  54126. */
  54127. dispose(): void;
  54128. /**
  54129. * CustomMeshes are not supported by this gizmo
  54130. * @param mesh The mesh to replace the default mesh of the gizmo
  54131. */
  54132. setCustomMesh(mesh: Mesh): void;
  54133. }
  54134. }
  54135. declare module BABYLON {
  54136. /**
  54137. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  54138. */
  54139. export class GizmoManager implements IDisposable {
  54140. private scene;
  54141. /**
  54142. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  54143. */
  54144. gizmos: {
  54145. positionGizmo: Nullable<PositionGizmo>;
  54146. rotationGizmo: Nullable<RotationGizmo>;
  54147. scaleGizmo: Nullable<ScaleGizmo>;
  54148. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  54149. };
  54150. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  54151. clearGizmoOnEmptyPointerEvent: boolean;
  54152. /** Fires an event when the manager is attached to a mesh */
  54153. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  54154. /** Fires an event when the manager is attached to a node */
  54155. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  54156. private _gizmosEnabled;
  54157. private _pointerObserver;
  54158. private _attachedMesh;
  54159. private _attachedNode;
  54160. private _boundingBoxColor;
  54161. private _defaultUtilityLayer;
  54162. private _defaultKeepDepthUtilityLayer;
  54163. private _thickness;
  54164. /**
  54165. * When bounding box gizmo is enabled, this can be used to track drag/end events
  54166. */
  54167. boundingBoxDragBehavior: SixDofDragBehavior;
  54168. /**
  54169. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  54170. */
  54171. attachableMeshes: Nullable<Array<AbstractMesh>>;
  54172. /**
  54173. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  54174. */
  54175. attachableNodes: Nullable<Array<Node>>;
  54176. /**
  54177. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  54178. */
  54179. usePointerToAttachGizmos: boolean;
  54180. /**
  54181. * Utility layer that the bounding box gizmo belongs to
  54182. */
  54183. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  54184. /**
  54185. * Utility layer that all gizmos besides bounding box belong to
  54186. */
  54187. get utilityLayer(): UtilityLayerRenderer;
  54188. /**
  54189. * True when the mouse pointer is hovering a gizmo mesh
  54190. */
  54191. get isHovered(): boolean;
  54192. /**
  54193. * Instatiates a gizmo manager
  54194. * @param scene the scene to overlay the gizmos on top of
  54195. * @param thickness display gizmo axis thickness
  54196. */
  54197. constructor(scene: Scene, thickness?: number);
  54198. /**
  54199. * Attaches a set of gizmos to the specified mesh
  54200. * @param mesh The mesh the gizmo's should be attached to
  54201. */
  54202. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54203. /**
  54204. * Attaches a set of gizmos to the specified node
  54205. * @param node The node the gizmo's should be attached to
  54206. */
  54207. attachToNode(node: Nullable<Node>): void;
  54208. /**
  54209. * If the position gizmo is enabled
  54210. */
  54211. set positionGizmoEnabled(value: boolean);
  54212. get positionGizmoEnabled(): boolean;
  54213. /**
  54214. * If the rotation gizmo is enabled
  54215. */
  54216. set rotationGizmoEnabled(value: boolean);
  54217. get rotationGizmoEnabled(): boolean;
  54218. /**
  54219. * If the scale gizmo is enabled
  54220. */
  54221. set scaleGizmoEnabled(value: boolean);
  54222. get scaleGizmoEnabled(): boolean;
  54223. /**
  54224. * If the boundingBox gizmo is enabled
  54225. */
  54226. set boundingBoxGizmoEnabled(value: boolean);
  54227. get boundingBoxGizmoEnabled(): boolean;
  54228. /**
  54229. * Disposes of the gizmo manager
  54230. */
  54231. dispose(): void;
  54232. }
  54233. }
  54234. declare module BABYLON {
  54235. /**
  54236. * A directional light is defined by a direction (what a surprise!).
  54237. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  54238. * 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.
  54239. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54240. */
  54241. export class DirectionalLight extends ShadowLight {
  54242. private _shadowFrustumSize;
  54243. /**
  54244. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  54245. */
  54246. get shadowFrustumSize(): number;
  54247. /**
  54248. * Specifies a fix frustum size for the shadow generation.
  54249. */
  54250. set shadowFrustumSize(value: number);
  54251. private _shadowOrthoScale;
  54252. /**
  54253. * Gets the shadow projection scale against the optimal computed one.
  54254. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54255. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54256. */
  54257. get shadowOrthoScale(): number;
  54258. /**
  54259. * Sets the shadow projection scale against the optimal computed one.
  54260. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  54261. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  54262. */
  54263. set shadowOrthoScale(value: number);
  54264. /**
  54265. * Automatically compute the projection matrix to best fit (including all the casters)
  54266. * on each frame.
  54267. */
  54268. autoUpdateExtends: boolean;
  54269. /**
  54270. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  54271. * on each frame. autoUpdateExtends must be set to true for this to work
  54272. */
  54273. autoCalcShadowZBounds: boolean;
  54274. private _orthoLeft;
  54275. private _orthoRight;
  54276. private _orthoTop;
  54277. private _orthoBottom;
  54278. /**
  54279. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  54280. * The directional light is emitted from everywhere in the given direction.
  54281. * It can cast shadows.
  54282. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54283. * @param name The friendly name of the light
  54284. * @param direction The direction of the light
  54285. * @param scene The scene the light belongs to
  54286. */
  54287. constructor(name: string, direction: Vector3, scene: Scene);
  54288. /**
  54289. * Returns the string "DirectionalLight".
  54290. * @return The class name
  54291. */
  54292. getClassName(): string;
  54293. /**
  54294. * Returns the integer 1.
  54295. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54296. */
  54297. getTypeID(): number;
  54298. /**
  54299. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  54300. * Returns the DirectionalLight Shadow projection matrix.
  54301. */
  54302. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54303. /**
  54304. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  54305. * Returns the DirectionalLight Shadow projection matrix.
  54306. */
  54307. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  54308. /**
  54309. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  54310. * Returns the DirectionalLight Shadow projection matrix.
  54311. */
  54312. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54313. protected _buildUniformLayout(): void;
  54314. /**
  54315. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  54316. * @param effect The effect to update
  54317. * @param lightIndex The index of the light in the effect to update
  54318. * @returns The directional light
  54319. */
  54320. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  54321. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  54322. /**
  54323. * Gets the minZ used for shadow according to both the scene and the light.
  54324. *
  54325. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54326. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54327. * @param activeCamera The camera we are returning the min for
  54328. * @returns the depth min z
  54329. */
  54330. getDepthMinZ(activeCamera: Camera): number;
  54331. /**
  54332. * Gets the maxZ used for shadow according to both the scene and the light.
  54333. *
  54334. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  54335. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  54336. * @param activeCamera The camera we are returning the max for
  54337. * @returns the depth max z
  54338. */
  54339. getDepthMaxZ(activeCamera: Camera): number;
  54340. /**
  54341. * Prepares the list of defines specific to the light type.
  54342. * @param defines the list of defines
  54343. * @param lightIndex defines the index of the light for the effect
  54344. */
  54345. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54346. }
  54347. }
  54348. declare module BABYLON {
  54349. /**
  54350. * Class containing static functions to help procedurally build meshes
  54351. */
  54352. export class HemisphereBuilder {
  54353. /**
  54354. * Creates a hemisphere mesh
  54355. * @param name defines the name of the mesh
  54356. * @param options defines the options used to create the mesh
  54357. * @param scene defines the hosting scene
  54358. * @returns the hemisphere mesh
  54359. */
  54360. static CreateHemisphere(name: string, options: {
  54361. segments?: number;
  54362. diameter?: number;
  54363. sideOrientation?: number;
  54364. }, scene: any): Mesh;
  54365. }
  54366. }
  54367. declare module BABYLON {
  54368. /**
  54369. * A spot light is defined by a position, a direction, an angle, and an exponent.
  54370. * These values define a cone of light starting from the position, emitting toward the direction.
  54371. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  54372. * and the exponent defines the speed of the decay of the light with distance (reach).
  54373. * Documentation: https://doc.babylonjs.com/babylon101/lights
  54374. */
  54375. export class SpotLight extends ShadowLight {
  54376. private _angle;
  54377. private _innerAngle;
  54378. private _cosHalfAngle;
  54379. private _lightAngleScale;
  54380. private _lightAngleOffset;
  54381. /**
  54382. * Gets the cone angle of the spot light in Radians.
  54383. */
  54384. get angle(): number;
  54385. /**
  54386. * Sets the cone angle of the spot light in Radians.
  54387. */
  54388. set angle(value: number);
  54389. /**
  54390. * Only used in gltf falloff mode, this defines the angle where
  54391. * the directional falloff will start before cutting at angle which could be seen
  54392. * as outer angle.
  54393. */
  54394. get innerAngle(): number;
  54395. /**
  54396. * Only used in gltf falloff mode, this defines the angle where
  54397. * the directional falloff will start before cutting at angle which could be seen
  54398. * as outer angle.
  54399. */
  54400. set innerAngle(value: number);
  54401. private _shadowAngleScale;
  54402. /**
  54403. * Allows scaling the angle of the light for shadow generation only.
  54404. */
  54405. get shadowAngleScale(): number;
  54406. /**
  54407. * Allows scaling the angle of the light for shadow generation only.
  54408. */
  54409. set shadowAngleScale(value: number);
  54410. /**
  54411. * The light decay speed with the distance from the emission spot.
  54412. */
  54413. exponent: number;
  54414. private _projectionTextureMatrix;
  54415. /**
  54416. * Allows reading the projecton texture
  54417. */
  54418. get projectionTextureMatrix(): Matrix;
  54419. protected _projectionTextureLightNear: number;
  54420. /**
  54421. * Gets the near clip of the Spotlight for texture projection.
  54422. */
  54423. get projectionTextureLightNear(): number;
  54424. /**
  54425. * Sets the near clip of the Spotlight for texture projection.
  54426. */
  54427. set projectionTextureLightNear(value: number);
  54428. protected _projectionTextureLightFar: number;
  54429. /**
  54430. * Gets the far clip of the Spotlight for texture projection.
  54431. */
  54432. get projectionTextureLightFar(): number;
  54433. /**
  54434. * Sets the far clip of the Spotlight for texture projection.
  54435. */
  54436. set projectionTextureLightFar(value: number);
  54437. protected _projectionTextureUpDirection: Vector3;
  54438. /**
  54439. * Gets the Up vector of the Spotlight for texture projection.
  54440. */
  54441. get projectionTextureUpDirection(): Vector3;
  54442. /**
  54443. * Sets the Up vector of the Spotlight for texture projection.
  54444. */
  54445. set projectionTextureUpDirection(value: Vector3);
  54446. private _projectionTexture;
  54447. /**
  54448. * Gets the projection texture of the light.
  54449. */
  54450. get projectionTexture(): Nullable<BaseTexture>;
  54451. /**
  54452. * Sets the projection texture of the light.
  54453. */
  54454. set projectionTexture(value: Nullable<BaseTexture>);
  54455. private _projectionTextureViewLightDirty;
  54456. private _projectionTextureProjectionLightDirty;
  54457. private _projectionTextureDirty;
  54458. private _projectionTextureViewTargetVector;
  54459. private _projectionTextureViewLightMatrix;
  54460. private _projectionTextureProjectionLightMatrix;
  54461. private _projectionTextureScalingMatrix;
  54462. /**
  54463. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  54464. * It can cast shadows.
  54465. * Documentation : https://doc.babylonjs.com/babylon101/lights
  54466. * @param name The light friendly name
  54467. * @param position The position of the spot light in the scene
  54468. * @param direction The direction of the light in the scene
  54469. * @param angle The cone angle of the light in Radians
  54470. * @param exponent The light decay speed with the distance from the emission spot
  54471. * @param scene The scene the lights belongs to
  54472. */
  54473. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  54474. /**
  54475. * Returns the string "SpotLight".
  54476. * @returns the class name
  54477. */
  54478. getClassName(): string;
  54479. /**
  54480. * Returns the integer 2.
  54481. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  54482. */
  54483. getTypeID(): number;
  54484. /**
  54485. * Overrides the direction setter to recompute the projection texture view light Matrix.
  54486. */
  54487. protected _setDirection(value: Vector3): void;
  54488. /**
  54489. * Overrides the position setter to recompute the projection texture view light Matrix.
  54490. */
  54491. protected _setPosition(value: Vector3): void;
  54492. /**
  54493. * 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.
  54494. * Returns the SpotLight.
  54495. */
  54496. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  54497. protected _computeProjectionTextureViewLightMatrix(): void;
  54498. protected _computeProjectionTextureProjectionLightMatrix(): void;
  54499. /**
  54500. * Main function for light texture projection matrix computing.
  54501. */
  54502. protected _computeProjectionTextureMatrix(): void;
  54503. protected _buildUniformLayout(): void;
  54504. private _computeAngleValues;
  54505. /**
  54506. * Sets the passed Effect "effect" with the Light textures.
  54507. * @param effect The effect to update
  54508. * @param lightIndex The index of the light in the effect to update
  54509. * @returns The light
  54510. */
  54511. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  54512. /**
  54513. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  54514. * @param effect The effect to update
  54515. * @param lightIndex The index of the light in the effect to update
  54516. * @returns The spot light
  54517. */
  54518. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  54519. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  54520. /**
  54521. * Disposes the light and the associated resources.
  54522. */
  54523. dispose(): void;
  54524. /**
  54525. * Prepares the list of defines specific to the light type.
  54526. * @param defines the list of defines
  54527. * @param lightIndex defines the index of the light for the effect
  54528. */
  54529. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  54530. }
  54531. }
  54532. declare module BABYLON {
  54533. /**
  54534. * Gizmo that enables viewing a light
  54535. */
  54536. export class LightGizmo extends Gizmo {
  54537. private _lightMesh;
  54538. private _material;
  54539. private _cachedPosition;
  54540. private _cachedForward;
  54541. private _attachedMeshParent;
  54542. private _pointerObserver;
  54543. /**
  54544. * Event that fires each time the gizmo is clicked
  54545. */
  54546. onClickedObservable: Observable<Light>;
  54547. /**
  54548. * Creates a LightGizmo
  54549. * @param gizmoLayer The utility layer the gizmo will be added to
  54550. */
  54551. constructor(gizmoLayer?: UtilityLayerRenderer);
  54552. private _light;
  54553. /**
  54554. * The light that the gizmo is attached to
  54555. */
  54556. set light(light: Nullable<Light>);
  54557. get light(): Nullable<Light>;
  54558. /**
  54559. * Gets the material used to render the light gizmo
  54560. */
  54561. get material(): StandardMaterial;
  54562. /**
  54563. * @hidden
  54564. * Updates the gizmo to match the attached mesh's position/rotation
  54565. */
  54566. protected _update(): void;
  54567. private static _Scale;
  54568. /**
  54569. * Creates the lines for a light mesh
  54570. */
  54571. private static _CreateLightLines;
  54572. /**
  54573. * Disposes of the light gizmo
  54574. */
  54575. dispose(): void;
  54576. private static _CreateHemisphericLightMesh;
  54577. private static _CreatePointLightMesh;
  54578. private static _CreateSpotLightMesh;
  54579. private static _CreateDirectionalLightMesh;
  54580. }
  54581. }
  54582. declare module BABYLON {
  54583. /**
  54584. * Gizmo that enables viewing a camera
  54585. */
  54586. export class CameraGizmo extends Gizmo {
  54587. private _cameraMesh;
  54588. private _cameraLinesMesh;
  54589. private _material;
  54590. private _pointerObserver;
  54591. /**
  54592. * Event that fires each time the gizmo is clicked
  54593. */
  54594. onClickedObservable: Observable<Camera>;
  54595. /**
  54596. * Creates a CameraGizmo
  54597. * @param gizmoLayer The utility layer the gizmo will be added to
  54598. */
  54599. constructor(gizmoLayer?: UtilityLayerRenderer);
  54600. private _camera;
  54601. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  54602. get displayFrustum(): boolean;
  54603. set displayFrustum(value: boolean);
  54604. /**
  54605. * The camera that the gizmo is attached to
  54606. */
  54607. set camera(camera: Nullable<Camera>);
  54608. get camera(): Nullable<Camera>;
  54609. /**
  54610. * Gets the material used to render the camera gizmo
  54611. */
  54612. get material(): StandardMaterial;
  54613. /**
  54614. * @hidden
  54615. * Updates the gizmo to match the attached mesh's position/rotation
  54616. */
  54617. protected _update(): void;
  54618. private static _Scale;
  54619. private _invProjection;
  54620. /**
  54621. * Disposes of the camera gizmo
  54622. */
  54623. dispose(): void;
  54624. private static _CreateCameraMesh;
  54625. private static _CreateCameraFrustum;
  54626. }
  54627. }
  54628. declare module BABYLON {
  54629. /** @hidden */
  54630. export var backgroundFragmentDeclaration: {
  54631. name: string;
  54632. shader: string;
  54633. };
  54634. }
  54635. declare module BABYLON {
  54636. /** @hidden */
  54637. export var backgroundUboDeclaration: {
  54638. name: string;
  54639. shader: string;
  54640. };
  54641. }
  54642. declare module BABYLON {
  54643. /** @hidden */
  54644. export var backgroundPixelShader: {
  54645. name: string;
  54646. shader: string;
  54647. };
  54648. }
  54649. declare module BABYLON {
  54650. /** @hidden */
  54651. export var backgroundVertexDeclaration: {
  54652. name: string;
  54653. shader: string;
  54654. };
  54655. }
  54656. declare module BABYLON {
  54657. /** @hidden */
  54658. export var backgroundVertexShader: {
  54659. name: string;
  54660. shader: string;
  54661. };
  54662. }
  54663. declare module BABYLON {
  54664. /**
  54665. * Background material used to create an efficient environement around your scene.
  54666. */
  54667. export class BackgroundMaterial extends PushMaterial {
  54668. /**
  54669. * Standard reflectance value at parallel view angle.
  54670. */
  54671. static StandardReflectance0: number;
  54672. /**
  54673. * Standard reflectance value at grazing angle.
  54674. */
  54675. static StandardReflectance90: number;
  54676. protected _primaryColor: Color3;
  54677. /**
  54678. * Key light Color (multiply against the environement texture)
  54679. */
  54680. primaryColor: Color3;
  54681. protected __perceptualColor: Nullable<Color3>;
  54682. /**
  54683. * Experimental Internal Use Only.
  54684. *
  54685. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  54686. * This acts as a helper to set the primary color to a more "human friendly" value.
  54687. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  54688. * output color as close as possible from the chosen value.
  54689. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  54690. * part of lighting setup.)
  54691. */
  54692. get _perceptualColor(): Nullable<Color3>;
  54693. set _perceptualColor(value: Nullable<Color3>);
  54694. protected _primaryColorShadowLevel: float;
  54695. /**
  54696. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  54697. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  54698. */
  54699. get primaryColorShadowLevel(): float;
  54700. set primaryColorShadowLevel(value: float);
  54701. protected _primaryColorHighlightLevel: float;
  54702. /**
  54703. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  54704. * The primary color is used at the level chosen to define what the white area would look.
  54705. */
  54706. get primaryColorHighlightLevel(): float;
  54707. set primaryColorHighlightLevel(value: float);
  54708. protected _reflectionTexture: Nullable<BaseTexture>;
  54709. /**
  54710. * Reflection Texture used in the material.
  54711. * Should be author in a specific way for the best result (refer to the documentation).
  54712. */
  54713. reflectionTexture: Nullable<BaseTexture>;
  54714. protected _reflectionBlur: float;
  54715. /**
  54716. * Reflection Texture level of blur.
  54717. *
  54718. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  54719. * texture twice.
  54720. */
  54721. reflectionBlur: float;
  54722. protected _diffuseTexture: Nullable<BaseTexture>;
  54723. /**
  54724. * Diffuse Texture used in the material.
  54725. * Should be author in a specific way for the best result (refer to the documentation).
  54726. */
  54727. diffuseTexture: Nullable<BaseTexture>;
  54728. protected _shadowLights: Nullable<IShadowLight[]>;
  54729. /**
  54730. * Specify the list of lights casting shadow on the material.
  54731. * All scene shadow lights will be included if null.
  54732. */
  54733. shadowLights: Nullable<IShadowLight[]>;
  54734. protected _shadowLevel: float;
  54735. /**
  54736. * Helps adjusting the shadow to a softer level if required.
  54737. * 0 means black shadows and 1 means no shadows.
  54738. */
  54739. shadowLevel: float;
  54740. protected _sceneCenter: Vector3;
  54741. /**
  54742. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  54743. * It is usually zero but might be interesting to modify according to your setup.
  54744. */
  54745. sceneCenter: Vector3;
  54746. protected _opacityFresnel: boolean;
  54747. /**
  54748. * This helps specifying that the material is falling off to the sky box at grazing angle.
  54749. * This helps ensuring a nice transition when the camera goes under the ground.
  54750. */
  54751. opacityFresnel: boolean;
  54752. protected _reflectionFresnel: boolean;
  54753. /**
  54754. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  54755. * This helps adding a mirror texture on the ground.
  54756. */
  54757. reflectionFresnel: boolean;
  54758. protected _reflectionFalloffDistance: number;
  54759. /**
  54760. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  54761. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  54762. */
  54763. reflectionFalloffDistance: number;
  54764. protected _reflectionAmount: number;
  54765. /**
  54766. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  54767. */
  54768. reflectionAmount: number;
  54769. protected _reflectionReflectance0: number;
  54770. /**
  54771. * This specifies the weight of the reflection at grazing angle.
  54772. */
  54773. reflectionReflectance0: number;
  54774. protected _reflectionReflectance90: number;
  54775. /**
  54776. * This specifies the weight of the reflection at a perpendicular point of view.
  54777. */
  54778. reflectionReflectance90: number;
  54779. /**
  54780. * Sets the reflection reflectance fresnel values according to the default standard
  54781. * empirically know to work well :-)
  54782. */
  54783. set reflectionStandardFresnelWeight(value: number);
  54784. protected _useRGBColor: boolean;
  54785. /**
  54786. * Helps to directly use the maps channels instead of their level.
  54787. */
  54788. useRGBColor: boolean;
  54789. protected _enableNoise: boolean;
  54790. /**
  54791. * This helps reducing the banding effect that could occur on the background.
  54792. */
  54793. enableNoise: boolean;
  54794. /**
  54795. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54796. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  54797. * Recommended to be keep at 1.0 except for special cases.
  54798. */
  54799. get fovMultiplier(): number;
  54800. set fovMultiplier(value: number);
  54801. private _fovMultiplier;
  54802. /**
  54803. * Enable the FOV adjustment feature controlled by fovMultiplier.
  54804. */
  54805. useEquirectangularFOV: boolean;
  54806. private _maxSimultaneousLights;
  54807. /**
  54808. * Number of Simultaneous lights allowed on the material.
  54809. */
  54810. maxSimultaneousLights: int;
  54811. private _shadowOnly;
  54812. /**
  54813. * Make the material only render shadows
  54814. */
  54815. shadowOnly: boolean;
  54816. /**
  54817. * Default configuration related to image processing available in the Background Material.
  54818. */
  54819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54820. /**
  54821. * Keep track of the image processing observer to allow dispose and replace.
  54822. */
  54823. private _imageProcessingObserver;
  54824. /**
  54825. * Attaches a new image processing configuration to the PBR Material.
  54826. * @param configuration (if null the scene configuration will be use)
  54827. */
  54828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54829. /**
  54830. * Gets the image processing configuration used either in this material.
  54831. */
  54832. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  54833. /**
  54834. * Sets the Default image processing configuration used either in the this material.
  54835. *
  54836. * If sets to null, the scene one is in use.
  54837. */
  54838. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  54839. /**
  54840. * Gets wether the color curves effect is enabled.
  54841. */
  54842. get cameraColorCurvesEnabled(): boolean;
  54843. /**
  54844. * Sets wether the color curves effect is enabled.
  54845. */
  54846. set cameraColorCurvesEnabled(value: boolean);
  54847. /**
  54848. * Gets wether the color grading effect is enabled.
  54849. */
  54850. get cameraColorGradingEnabled(): boolean;
  54851. /**
  54852. * Gets wether the color grading effect is enabled.
  54853. */
  54854. set cameraColorGradingEnabled(value: boolean);
  54855. /**
  54856. * Gets wether tonemapping is enabled or not.
  54857. */
  54858. get cameraToneMappingEnabled(): boolean;
  54859. /**
  54860. * Sets wether tonemapping is enabled or not
  54861. */
  54862. set cameraToneMappingEnabled(value: boolean);
  54863. /**
  54864. * The camera exposure used on this material.
  54865. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54866. * This corresponds to a photographic exposure.
  54867. */
  54868. get cameraExposure(): float;
  54869. /**
  54870. * The camera exposure used on this material.
  54871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54872. * This corresponds to a photographic exposure.
  54873. */
  54874. set cameraExposure(value: float);
  54875. /**
  54876. * Gets The camera contrast used on this material.
  54877. */
  54878. get cameraContrast(): float;
  54879. /**
  54880. * Sets The camera contrast used on this material.
  54881. */
  54882. set cameraContrast(value: float);
  54883. /**
  54884. * Gets the Color Grading 2D Lookup Texture.
  54885. */
  54886. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54887. /**
  54888. * Sets the Color Grading 2D Lookup Texture.
  54889. */
  54890. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54891. /**
  54892. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54893. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54894. * 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;
  54895. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54896. */
  54897. get cameraColorCurves(): Nullable<ColorCurves>;
  54898. /**
  54899. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54900. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54901. * 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;
  54902. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54903. */
  54904. set cameraColorCurves(value: Nullable<ColorCurves>);
  54905. /**
  54906. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  54907. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  54908. */
  54909. switchToBGR: boolean;
  54910. private _renderTargets;
  54911. private _reflectionControls;
  54912. private _white;
  54913. private _primaryShadowColor;
  54914. private _primaryHighlightColor;
  54915. /**
  54916. * Instantiates a Background Material in the given scene
  54917. * @param name The friendly name of the material
  54918. * @param scene The scene to add the material to
  54919. */
  54920. constructor(name: string, scene: Scene);
  54921. /**
  54922. * Gets a boolean indicating that current material needs to register RTT
  54923. */
  54924. get hasRenderTargetTextures(): boolean;
  54925. /**
  54926. * The entire material has been created in order to prevent overdraw.
  54927. * @returns false
  54928. */
  54929. needAlphaTesting(): boolean;
  54930. /**
  54931. * The entire material has been created in order to prevent overdraw.
  54932. * @returns true if blending is enable
  54933. */
  54934. needAlphaBlending(): boolean;
  54935. /**
  54936. * Checks wether the material is ready to be rendered for a given mesh.
  54937. * @param mesh The mesh to render
  54938. * @param subMesh The submesh to check against
  54939. * @param useInstances Specify wether or not the material is used with instances
  54940. * @returns true if all the dependencies are ready (Textures, Effects...)
  54941. */
  54942. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54943. /**
  54944. * Compute the primary color according to the chosen perceptual color.
  54945. */
  54946. private _computePrimaryColorFromPerceptualColor;
  54947. /**
  54948. * Compute the highlights and shadow colors according to their chosen levels.
  54949. */
  54950. private _computePrimaryColors;
  54951. /**
  54952. * Build the uniform buffer used in the material.
  54953. */
  54954. buildUniformLayout(): void;
  54955. /**
  54956. * Unbind the material.
  54957. */
  54958. unbind(): void;
  54959. /**
  54960. * Bind only the world matrix to the material.
  54961. * @param world The world matrix to bind.
  54962. */
  54963. bindOnlyWorldMatrix(world: Matrix): void;
  54964. /**
  54965. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  54966. * @param world The world matrix to bind.
  54967. * @param subMesh The submesh to bind for.
  54968. */
  54969. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54970. /**
  54971. * Checks to see if a texture is used in the material.
  54972. * @param texture - Base texture to use.
  54973. * @returns - Boolean specifying if a texture is used in the material.
  54974. */
  54975. hasTexture(texture: BaseTexture): boolean;
  54976. /**
  54977. * Dispose the material.
  54978. * @param forceDisposeEffect Force disposal of the associated effect.
  54979. * @param forceDisposeTextures Force disposal of the associated textures.
  54980. */
  54981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54982. /**
  54983. * Clones the material.
  54984. * @param name The cloned name.
  54985. * @returns The cloned material.
  54986. */
  54987. clone(name: string): BackgroundMaterial;
  54988. /**
  54989. * Serializes the current material to its JSON representation.
  54990. * @returns The JSON representation.
  54991. */
  54992. serialize(): any;
  54993. /**
  54994. * Gets the class name of the material
  54995. * @returns "BackgroundMaterial"
  54996. */
  54997. getClassName(): string;
  54998. /**
  54999. * Parse a JSON input to create back a background material.
  55000. * @param source The JSON data to parse
  55001. * @param scene The scene to create the parsed material in
  55002. * @param rootUrl The root url of the assets the material depends upon
  55003. * @returns the instantiated BackgroundMaterial.
  55004. */
  55005. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55006. }
  55007. }
  55008. declare module BABYLON {
  55009. /**
  55010. * Represents the different options available during the creation of
  55011. * a Environment helper.
  55012. *
  55013. * This can control the default ground, skybox and image processing setup of your scene.
  55014. */
  55015. export interface IEnvironmentHelperOptions {
  55016. /**
  55017. * Specifies whether or not to create a ground.
  55018. * True by default.
  55019. */
  55020. createGround: boolean;
  55021. /**
  55022. * Specifies the ground size.
  55023. * 15 by default.
  55024. */
  55025. groundSize: number;
  55026. /**
  55027. * The texture used on the ground for the main color.
  55028. * Comes from the BabylonJS CDN by default.
  55029. *
  55030. * Remarks: Can be either a texture or a url.
  55031. */
  55032. groundTexture: string | BaseTexture;
  55033. /**
  55034. * The color mixed in the ground texture by default.
  55035. * BabylonJS clearColor by default.
  55036. */
  55037. groundColor: Color3;
  55038. /**
  55039. * Specifies the ground opacity.
  55040. * 1 by default.
  55041. */
  55042. groundOpacity: number;
  55043. /**
  55044. * Enables the ground to receive shadows.
  55045. * True by default.
  55046. */
  55047. enableGroundShadow: boolean;
  55048. /**
  55049. * Helps preventing the shadow to be fully black on the ground.
  55050. * 0.5 by default.
  55051. */
  55052. groundShadowLevel: number;
  55053. /**
  55054. * Creates a mirror texture attach to the ground.
  55055. * false by default.
  55056. */
  55057. enableGroundMirror: boolean;
  55058. /**
  55059. * Specifies the ground mirror size ratio.
  55060. * 0.3 by default as the default kernel is 64.
  55061. */
  55062. groundMirrorSizeRatio: number;
  55063. /**
  55064. * Specifies the ground mirror blur kernel size.
  55065. * 64 by default.
  55066. */
  55067. groundMirrorBlurKernel: number;
  55068. /**
  55069. * Specifies the ground mirror visibility amount.
  55070. * 1 by default
  55071. */
  55072. groundMirrorAmount: number;
  55073. /**
  55074. * Specifies the ground mirror reflectance weight.
  55075. * This uses the standard weight of the background material to setup the fresnel effect
  55076. * of the mirror.
  55077. * 1 by default.
  55078. */
  55079. groundMirrorFresnelWeight: number;
  55080. /**
  55081. * Specifies the ground mirror Falloff distance.
  55082. * This can helps reducing the size of the reflection.
  55083. * 0 by Default.
  55084. */
  55085. groundMirrorFallOffDistance: number;
  55086. /**
  55087. * Specifies the ground mirror texture type.
  55088. * Unsigned Int by Default.
  55089. */
  55090. groundMirrorTextureType: number;
  55091. /**
  55092. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  55093. * the shown objects.
  55094. */
  55095. groundYBias: number;
  55096. /**
  55097. * Specifies whether or not to create a skybox.
  55098. * True by default.
  55099. */
  55100. createSkybox: boolean;
  55101. /**
  55102. * Specifies the skybox size.
  55103. * 20 by default.
  55104. */
  55105. skyboxSize: number;
  55106. /**
  55107. * The texture used on the skybox for the main color.
  55108. * Comes from the BabylonJS CDN by default.
  55109. *
  55110. * Remarks: Can be either a texture or a url.
  55111. */
  55112. skyboxTexture: string | BaseTexture;
  55113. /**
  55114. * The color mixed in the skybox texture by default.
  55115. * BabylonJS clearColor by default.
  55116. */
  55117. skyboxColor: Color3;
  55118. /**
  55119. * The background rotation around the Y axis of the scene.
  55120. * This helps aligning the key lights of your scene with the background.
  55121. * 0 by default.
  55122. */
  55123. backgroundYRotation: number;
  55124. /**
  55125. * Compute automatically the size of the elements to best fit with the scene.
  55126. */
  55127. sizeAuto: boolean;
  55128. /**
  55129. * Default position of the rootMesh if autoSize is not true.
  55130. */
  55131. rootPosition: Vector3;
  55132. /**
  55133. * Sets up the image processing in the scene.
  55134. * true by default.
  55135. */
  55136. setupImageProcessing: boolean;
  55137. /**
  55138. * The texture used as your environment texture in the scene.
  55139. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  55140. *
  55141. * Remarks: Can be either a texture or a url.
  55142. */
  55143. environmentTexture: string | BaseTexture;
  55144. /**
  55145. * The value of the exposure to apply to the scene.
  55146. * 0.6 by default if setupImageProcessing is true.
  55147. */
  55148. cameraExposure: number;
  55149. /**
  55150. * The value of the contrast to apply to the scene.
  55151. * 1.6 by default if setupImageProcessing is true.
  55152. */
  55153. cameraContrast: number;
  55154. /**
  55155. * Specifies whether or not tonemapping should be enabled in the scene.
  55156. * true by default if setupImageProcessing is true.
  55157. */
  55158. toneMappingEnabled: boolean;
  55159. }
  55160. /**
  55161. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  55162. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  55163. * It also helps with the default setup of your imageProcessing configuration.
  55164. */
  55165. export class EnvironmentHelper {
  55166. /**
  55167. * Default ground texture URL.
  55168. */
  55169. private static _groundTextureCDNUrl;
  55170. /**
  55171. * Default skybox texture URL.
  55172. */
  55173. private static _skyboxTextureCDNUrl;
  55174. /**
  55175. * Default environment texture URL.
  55176. */
  55177. private static _environmentTextureCDNUrl;
  55178. /**
  55179. * Creates the default options for the helper.
  55180. */
  55181. private static _getDefaultOptions;
  55182. private _rootMesh;
  55183. /**
  55184. * Gets the root mesh created by the helper.
  55185. */
  55186. get rootMesh(): Mesh;
  55187. private _skybox;
  55188. /**
  55189. * Gets the skybox created by the helper.
  55190. */
  55191. get skybox(): Nullable<Mesh>;
  55192. private _skyboxTexture;
  55193. /**
  55194. * Gets the skybox texture created by the helper.
  55195. */
  55196. get skyboxTexture(): Nullable<BaseTexture>;
  55197. private _skyboxMaterial;
  55198. /**
  55199. * Gets the skybox material created by the helper.
  55200. */
  55201. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  55202. private _ground;
  55203. /**
  55204. * Gets the ground mesh created by the helper.
  55205. */
  55206. get ground(): Nullable<Mesh>;
  55207. private _groundTexture;
  55208. /**
  55209. * Gets the ground texture created by the helper.
  55210. */
  55211. get groundTexture(): Nullable<BaseTexture>;
  55212. private _groundMirror;
  55213. /**
  55214. * Gets the ground mirror created by the helper.
  55215. */
  55216. get groundMirror(): Nullable<MirrorTexture>;
  55217. /**
  55218. * Gets the ground mirror render list to helps pushing the meshes
  55219. * you wish in the ground reflection.
  55220. */
  55221. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  55222. private _groundMaterial;
  55223. /**
  55224. * Gets the ground material created by the helper.
  55225. */
  55226. get groundMaterial(): Nullable<BackgroundMaterial>;
  55227. /**
  55228. * Stores the creation options.
  55229. */
  55230. private readonly _scene;
  55231. private _options;
  55232. /**
  55233. * This observable will be notified with any error during the creation of the environment,
  55234. * mainly texture creation errors.
  55235. */
  55236. onErrorObservable: Observable<{
  55237. message?: string;
  55238. exception?: any;
  55239. }>;
  55240. /**
  55241. * constructor
  55242. * @param options Defines the options we want to customize the helper
  55243. * @param scene The scene to add the material to
  55244. */
  55245. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  55246. /**
  55247. * Updates the background according to the new options
  55248. * @param options
  55249. */
  55250. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  55251. /**
  55252. * Sets the primary color of all the available elements.
  55253. * @param color the main color to affect to the ground and the background
  55254. */
  55255. setMainColor(color: Color3): void;
  55256. /**
  55257. * Setup the image processing according to the specified options.
  55258. */
  55259. private _setupImageProcessing;
  55260. /**
  55261. * Setup the environment texture according to the specified options.
  55262. */
  55263. private _setupEnvironmentTexture;
  55264. /**
  55265. * Setup the background according to the specified options.
  55266. */
  55267. private _setupBackground;
  55268. /**
  55269. * Get the scene sizes according to the setup.
  55270. */
  55271. private _getSceneSize;
  55272. /**
  55273. * Setup the ground according to the specified options.
  55274. */
  55275. private _setupGround;
  55276. /**
  55277. * Setup the ground material according to the specified options.
  55278. */
  55279. private _setupGroundMaterial;
  55280. /**
  55281. * Setup the ground diffuse texture according to the specified options.
  55282. */
  55283. private _setupGroundDiffuseTexture;
  55284. /**
  55285. * Setup the ground mirror texture according to the specified options.
  55286. */
  55287. private _setupGroundMirrorTexture;
  55288. /**
  55289. * Setup the ground to receive the mirror texture.
  55290. */
  55291. private _setupMirrorInGroundMaterial;
  55292. /**
  55293. * Setup the skybox according to the specified options.
  55294. */
  55295. private _setupSkybox;
  55296. /**
  55297. * Setup the skybox material according to the specified options.
  55298. */
  55299. private _setupSkyboxMaterial;
  55300. /**
  55301. * Setup the skybox reflection texture according to the specified options.
  55302. */
  55303. private _setupSkyboxReflectionTexture;
  55304. private _errorHandler;
  55305. /**
  55306. * Dispose all the elements created by the Helper.
  55307. */
  55308. dispose(): void;
  55309. }
  55310. }
  55311. declare module BABYLON {
  55312. /**
  55313. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  55314. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  55315. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55316. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55317. */
  55318. export abstract class TextureDome<T extends Texture> extends TransformNode {
  55319. protected onError: Nullable<(message?: string, exception?: any) => void>;
  55320. /**
  55321. * Define the source as a Monoscopic panoramic 360/180.
  55322. */
  55323. static readonly MODE_MONOSCOPIC: number;
  55324. /**
  55325. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  55326. */
  55327. static readonly MODE_TOPBOTTOM: number;
  55328. /**
  55329. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  55330. */
  55331. static readonly MODE_SIDEBYSIDE: number;
  55332. private _halfDome;
  55333. protected _useDirectMapping: boolean;
  55334. /**
  55335. * The texture being displayed on the sphere
  55336. */
  55337. protected _texture: T;
  55338. /**
  55339. * Gets the texture being displayed on the sphere
  55340. */
  55341. get texture(): T;
  55342. /**
  55343. * Sets the texture being displayed on the sphere
  55344. */
  55345. set texture(newTexture: T);
  55346. /**
  55347. * The skybox material
  55348. */
  55349. protected _material: BackgroundMaterial;
  55350. /**
  55351. * The surface used for the dome
  55352. */
  55353. protected _mesh: Mesh;
  55354. /**
  55355. * Gets the mesh used for the dome.
  55356. */
  55357. get mesh(): Mesh;
  55358. /**
  55359. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  55360. */
  55361. private _halfDomeMask;
  55362. /**
  55363. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55364. * Also see the options.resolution property.
  55365. */
  55366. get fovMultiplier(): number;
  55367. set fovMultiplier(value: number);
  55368. protected _textureMode: number;
  55369. /**
  55370. * Gets or set the current texture mode for the texture. It can be:
  55371. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55372. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55373. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55374. */
  55375. get textureMode(): number;
  55376. /**
  55377. * Sets the current texture mode for the texture. It can be:
  55378. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55379. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55380. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55381. */
  55382. set textureMode(value: number);
  55383. /**
  55384. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  55385. */
  55386. get halfDome(): boolean;
  55387. /**
  55388. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55389. */
  55390. set halfDome(enabled: boolean);
  55391. /**
  55392. * Oberserver used in Stereoscopic VR Mode.
  55393. */
  55394. private _onBeforeCameraRenderObserver;
  55395. /**
  55396. * Observable raised when an error occured while loading the 360 image
  55397. */
  55398. onLoadErrorObservable: Observable<string>;
  55399. /**
  55400. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  55401. * @param name Element's name, child elements will append suffixes for their own names.
  55402. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  55403. * @param options An object containing optional or exposed sub element properties
  55404. */
  55405. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  55406. resolution?: number;
  55407. clickToPlay?: boolean;
  55408. autoPlay?: boolean;
  55409. loop?: boolean;
  55410. size?: number;
  55411. poster?: string;
  55412. faceForward?: boolean;
  55413. useDirectMapping?: boolean;
  55414. halfDomeMode?: boolean;
  55415. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  55416. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  55417. protected _changeTextureMode(value: number): void;
  55418. /**
  55419. * Releases resources associated with this node.
  55420. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55421. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55422. */
  55423. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55424. }
  55425. }
  55426. declare module BABYLON {
  55427. /**
  55428. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  55429. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  55430. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  55431. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55432. */
  55433. export class PhotoDome extends TextureDome<Texture> {
  55434. /**
  55435. * Define the image as a Monoscopic panoramic 360 image.
  55436. */
  55437. static readonly MODE_MONOSCOPIC: number;
  55438. /**
  55439. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  55440. */
  55441. static readonly MODE_TOPBOTTOM: number;
  55442. /**
  55443. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  55444. */
  55445. static readonly MODE_SIDEBYSIDE: number;
  55446. /**
  55447. * Gets or sets the texture being displayed on the sphere
  55448. */
  55449. get photoTexture(): Texture;
  55450. /**
  55451. * sets the texture being displayed on the sphere
  55452. */
  55453. set photoTexture(value: Texture);
  55454. /**
  55455. * Gets the current video mode for the video. It can be:
  55456. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55457. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55458. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55459. */
  55460. get imageMode(): number;
  55461. /**
  55462. * Sets the current video mode for the video. It can be:
  55463. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  55464. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  55465. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  55466. */
  55467. set imageMode(value: number);
  55468. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  55469. }
  55470. }
  55471. declare module BABYLON {
  55472. /**
  55473. * Class used to host RGBD texture specific utilities
  55474. */
  55475. export class RGBDTextureTools {
  55476. /**
  55477. * Expand the RGBD Texture from RGBD to Half Float if possible.
  55478. * @param texture the texture to expand.
  55479. */
  55480. static ExpandRGBDTexture(texture: Texture): void;
  55481. }
  55482. }
  55483. declare module BABYLON {
  55484. /**
  55485. * Class used to host texture specific utilities
  55486. */
  55487. export class BRDFTextureTools {
  55488. /**
  55489. * Prevents texture cache collision
  55490. */
  55491. private static _instanceNumber;
  55492. /**
  55493. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  55494. * @param scene defines the hosting scene
  55495. * @returns the environment BRDF texture
  55496. */
  55497. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  55498. private static _environmentBRDFBase64Texture;
  55499. }
  55500. }
  55501. declare module BABYLON {
  55502. /**
  55503. * @hidden
  55504. */
  55505. export interface IMaterialClearCoatDefines {
  55506. CLEARCOAT: boolean;
  55507. CLEARCOAT_DEFAULTIOR: boolean;
  55508. CLEARCOAT_TEXTURE: boolean;
  55509. CLEARCOAT_TEXTUREDIRECTUV: number;
  55510. CLEARCOAT_BUMP: boolean;
  55511. CLEARCOAT_BUMPDIRECTUV: number;
  55512. CLEARCOAT_REMAP_F0: boolean;
  55513. CLEARCOAT_TINT: boolean;
  55514. CLEARCOAT_TINT_TEXTURE: boolean;
  55515. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  55516. /** @hidden */
  55517. _areTexturesDirty: boolean;
  55518. }
  55519. /**
  55520. * Define the code related to the clear coat parameters of the pbr material.
  55521. */
  55522. export class PBRClearCoatConfiguration {
  55523. /**
  55524. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55525. * The default fits with a polyurethane material.
  55526. */
  55527. private static readonly _DefaultIndexOfRefraction;
  55528. private _isEnabled;
  55529. /**
  55530. * Defines if the clear coat is enabled in the material.
  55531. */
  55532. isEnabled: boolean;
  55533. /**
  55534. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  55535. */
  55536. intensity: number;
  55537. /**
  55538. * Defines the clear coat layer roughness.
  55539. */
  55540. roughness: number;
  55541. private _indexOfRefraction;
  55542. /**
  55543. * Defines the index of refraction of the clear coat.
  55544. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  55545. * The default fits with a polyurethane material.
  55546. * Changing the default value is more performance intensive.
  55547. */
  55548. indexOfRefraction: number;
  55549. private _texture;
  55550. /**
  55551. * Stores the clear coat values in a texture.
  55552. */
  55553. texture: Nullable<BaseTexture>;
  55554. private _remapF0OnInterfaceChange;
  55555. /**
  55556. * Defines if the F0 value should be remapped to account for the interface change in the material.
  55557. */
  55558. remapF0OnInterfaceChange: boolean;
  55559. private _bumpTexture;
  55560. /**
  55561. * Define the clear coat specific bump texture.
  55562. */
  55563. bumpTexture: Nullable<BaseTexture>;
  55564. private _isTintEnabled;
  55565. /**
  55566. * Defines if the clear coat tint is enabled in the material.
  55567. */
  55568. isTintEnabled: boolean;
  55569. /**
  55570. * Defines the clear coat tint of the material.
  55571. * This is only use if tint is enabled
  55572. */
  55573. tintColor: Color3;
  55574. /**
  55575. * Defines the distance at which the tint color should be found in the
  55576. * clear coat media.
  55577. * This is only use if tint is enabled
  55578. */
  55579. tintColorAtDistance: number;
  55580. /**
  55581. * Defines the clear coat layer thickness.
  55582. * This is only use if tint is enabled
  55583. */
  55584. tintThickness: number;
  55585. private _tintTexture;
  55586. /**
  55587. * Stores the clear tint values in a texture.
  55588. * rgb is tint
  55589. * a is a thickness factor
  55590. */
  55591. tintTexture: Nullable<BaseTexture>;
  55592. /** @hidden */
  55593. private _internalMarkAllSubMeshesAsTexturesDirty;
  55594. /** @hidden */
  55595. _markAllSubMeshesAsTexturesDirty(): void;
  55596. /**
  55597. * Instantiate a new istance of clear coat configuration.
  55598. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55599. */
  55600. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55601. /**
  55602. * Gets wehter the submesh is ready to be used or not.
  55603. * @param defines the list of "defines" to update.
  55604. * @param scene defines the scene the material belongs to.
  55605. * @param engine defines the engine the material belongs to.
  55606. * @param disableBumpMap defines wether the material disables bump or not.
  55607. * @returns - boolean indicating that the submesh is ready or not.
  55608. */
  55609. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  55610. /**
  55611. * Checks to see if a texture is used in the material.
  55612. * @param defines the list of "defines" to update.
  55613. * @param scene defines the scene to the material belongs to.
  55614. */
  55615. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  55616. /**
  55617. * Binds the material data.
  55618. * @param uniformBuffer defines the Uniform buffer to fill in.
  55619. * @param scene defines the scene the material belongs to.
  55620. * @param engine defines the engine the material belongs to.
  55621. * @param disableBumpMap defines wether the material disables bump or not.
  55622. * @param isFrozen defines wether the material is frozen or not.
  55623. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  55624. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  55625. */
  55626. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  55627. /**
  55628. * Checks to see if a texture is used in the material.
  55629. * @param texture - Base texture to use.
  55630. * @returns - Boolean specifying if a texture is used in the material.
  55631. */
  55632. hasTexture(texture: BaseTexture): boolean;
  55633. /**
  55634. * Returns an array of the actively used textures.
  55635. * @param activeTextures Array of BaseTextures
  55636. */
  55637. getActiveTextures(activeTextures: BaseTexture[]): void;
  55638. /**
  55639. * Returns the animatable textures.
  55640. * @param animatables Array of animatable textures.
  55641. */
  55642. getAnimatables(animatables: IAnimatable[]): void;
  55643. /**
  55644. * Disposes the resources of the material.
  55645. * @param forceDisposeTextures - Forces the disposal of all textures.
  55646. */
  55647. dispose(forceDisposeTextures?: boolean): void;
  55648. /**
  55649. * Get the current class name of the texture useful for serialization or dynamic coding.
  55650. * @returns "PBRClearCoatConfiguration"
  55651. */
  55652. getClassName(): string;
  55653. /**
  55654. * Add fallbacks to the effect fallbacks list.
  55655. * @param defines defines the Base texture to use.
  55656. * @param fallbacks defines the current fallback list.
  55657. * @param currentRank defines the current fallback rank.
  55658. * @returns the new fallback rank.
  55659. */
  55660. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55661. /**
  55662. * Add the required uniforms to the current list.
  55663. * @param uniforms defines the current uniform list.
  55664. */
  55665. static AddUniforms(uniforms: string[]): void;
  55666. /**
  55667. * Add the required samplers to the current list.
  55668. * @param samplers defines the current sampler list.
  55669. */
  55670. static AddSamplers(samplers: string[]): void;
  55671. /**
  55672. * Add the required uniforms to the current buffer.
  55673. * @param uniformBuffer defines the current uniform buffer.
  55674. */
  55675. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55676. /**
  55677. * Makes a duplicate of the current configuration into another one.
  55678. * @param clearCoatConfiguration define the config where to copy the info
  55679. */
  55680. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  55681. /**
  55682. * Serializes this clear coat configuration.
  55683. * @returns - An object with the serialized config.
  55684. */
  55685. serialize(): any;
  55686. /**
  55687. * Parses a anisotropy Configuration from a serialized object.
  55688. * @param source - Serialized object.
  55689. * @param scene Defines the scene we are parsing for
  55690. * @param rootUrl Defines the rootUrl to load from
  55691. */
  55692. parse(source: any, scene: Scene, rootUrl: string): void;
  55693. }
  55694. }
  55695. declare module BABYLON {
  55696. /**
  55697. * @hidden
  55698. */
  55699. export interface IMaterialAnisotropicDefines {
  55700. ANISOTROPIC: boolean;
  55701. ANISOTROPIC_TEXTURE: boolean;
  55702. ANISOTROPIC_TEXTUREDIRECTUV: number;
  55703. MAINUV1: boolean;
  55704. _areTexturesDirty: boolean;
  55705. _needUVs: boolean;
  55706. }
  55707. /**
  55708. * Define the code related to the anisotropic parameters of the pbr material.
  55709. */
  55710. export class PBRAnisotropicConfiguration {
  55711. private _isEnabled;
  55712. /**
  55713. * Defines if the anisotropy is enabled in the material.
  55714. */
  55715. isEnabled: boolean;
  55716. /**
  55717. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  55718. */
  55719. intensity: number;
  55720. /**
  55721. * Defines if the effect is along the tangents, bitangents or in between.
  55722. * By default, the effect is "strectching" the highlights along the tangents.
  55723. */
  55724. direction: Vector2;
  55725. private _texture;
  55726. /**
  55727. * Stores the anisotropy values in a texture.
  55728. * rg is direction (like normal from -1 to 1)
  55729. * b is a intensity
  55730. */
  55731. texture: Nullable<BaseTexture>;
  55732. /** @hidden */
  55733. private _internalMarkAllSubMeshesAsTexturesDirty;
  55734. /** @hidden */
  55735. _markAllSubMeshesAsTexturesDirty(): void;
  55736. /**
  55737. * Instantiate a new istance of anisotropy configuration.
  55738. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  55739. */
  55740. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  55741. /**
  55742. * Specifies that the submesh is ready to be used.
  55743. * @param defines the list of "defines" to update.
  55744. * @param scene defines the scene the material belongs to.
  55745. * @returns - boolean indicating that the submesh is ready or not.
  55746. */
  55747. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  55748. /**
  55749. * Checks to see if a texture is used in the material.
  55750. * @param defines the list of "defines" to update.
  55751. * @param mesh the mesh we are preparing the defines for.
  55752. * @param scene defines the scene the material belongs to.
  55753. */
  55754. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  55755. /**
  55756. * Binds the material data.
  55757. * @param uniformBuffer defines the Uniform buffer to fill in.
  55758. * @param scene defines the scene the material belongs to.
  55759. * @param isFrozen defines wether the material is frozen or not.
  55760. */
  55761. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  55762. /**
  55763. * Checks to see if a texture is used in the material.
  55764. * @param texture - Base texture to use.
  55765. * @returns - Boolean specifying if a texture is used in the material.
  55766. */
  55767. hasTexture(texture: BaseTexture): boolean;
  55768. /**
  55769. * Returns an array of the actively used textures.
  55770. * @param activeTextures Array of BaseTextures
  55771. */
  55772. getActiveTextures(activeTextures: BaseTexture[]): void;
  55773. /**
  55774. * Returns the animatable textures.
  55775. * @param animatables Array of animatable textures.
  55776. */
  55777. getAnimatables(animatables: IAnimatable[]): void;
  55778. /**
  55779. * Disposes the resources of the material.
  55780. * @param forceDisposeTextures - Forces the disposal of all textures.
  55781. */
  55782. dispose(forceDisposeTextures?: boolean): void;
  55783. /**
  55784. * Get the current class name of the texture useful for serialization or dynamic coding.
  55785. * @returns "PBRAnisotropicConfiguration"
  55786. */
  55787. getClassName(): string;
  55788. /**
  55789. * Add fallbacks to the effect fallbacks list.
  55790. * @param defines defines the Base texture to use.
  55791. * @param fallbacks defines the current fallback list.
  55792. * @param currentRank defines the current fallback rank.
  55793. * @returns the new fallback rank.
  55794. */
  55795. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  55796. /**
  55797. * Add the required uniforms to the current list.
  55798. * @param uniforms defines the current uniform list.
  55799. */
  55800. static AddUniforms(uniforms: string[]): void;
  55801. /**
  55802. * Add the required uniforms to the current buffer.
  55803. * @param uniformBuffer defines the current uniform buffer.
  55804. */
  55805. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  55806. /**
  55807. * Add the required samplers to the current list.
  55808. * @param samplers defines the current sampler list.
  55809. */
  55810. static AddSamplers(samplers: string[]): void;
  55811. /**
  55812. * Makes a duplicate of the current configuration into another one.
  55813. * @param anisotropicConfiguration define the config where to copy the info
  55814. */
  55815. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  55816. /**
  55817. * Serializes this anisotropy configuration.
  55818. * @returns - An object with the serialized config.
  55819. */
  55820. serialize(): any;
  55821. /**
  55822. * Parses a anisotropy Configuration from a serialized object.
  55823. * @param source - Serialized object.
  55824. * @param scene Defines the scene we are parsing for
  55825. * @param rootUrl Defines the rootUrl to load from
  55826. */
  55827. parse(source: any, scene: Scene, rootUrl: string): void;
  55828. }
  55829. }
  55830. declare module BABYLON {
  55831. /**
  55832. * @hidden
  55833. */
  55834. export interface IMaterialBRDFDefines {
  55835. BRDF_V_HEIGHT_CORRELATED: boolean;
  55836. MS_BRDF_ENERGY_CONSERVATION: boolean;
  55837. SPHERICAL_HARMONICS: boolean;
  55838. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  55839. /** @hidden */
  55840. _areMiscDirty: boolean;
  55841. }
  55842. /**
  55843. * Define the code related to the BRDF parameters of the pbr material.
  55844. */
  55845. export class PBRBRDFConfiguration {
  55846. /**
  55847. * Default value used for the energy conservation.
  55848. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55849. */
  55850. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  55851. /**
  55852. * Default value used for the Smith Visibility Height Correlated mode.
  55853. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  55854. */
  55855. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  55856. /**
  55857. * Default value used for the IBL diffuse part.
  55858. * This can help switching back to the polynomials mode globally which is a tiny bit
  55859. * less GPU intensive at the drawback of a lower quality.
  55860. */
  55861. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  55862. /**
  55863. * Default value used for activating energy conservation for the specular workflow.
  55864. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55865. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55866. */
  55867. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  55868. private _useEnergyConservation;
  55869. /**
  55870. * Defines if the material uses energy conservation.
  55871. */
  55872. useEnergyConservation: boolean;
  55873. private _useSmithVisibilityHeightCorrelated;
  55874. /**
  55875. * LEGACY Mode set to false
  55876. * Defines if the material uses height smith correlated visibility term.
  55877. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  55878. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  55879. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  55880. * Not relying on height correlated will also disable energy conservation.
  55881. */
  55882. useSmithVisibilityHeightCorrelated: boolean;
  55883. private _useSphericalHarmonics;
  55884. /**
  55885. * LEGACY Mode set to false
  55886. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  55887. * diffuse part of the IBL.
  55888. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  55889. * to the ground truth.
  55890. */
  55891. useSphericalHarmonics: boolean;
  55892. private _useSpecularGlossinessInputEnergyConservation;
  55893. /**
  55894. * Defines if the material uses energy conservation, when the specular workflow is active.
  55895. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  55896. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  55897. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  55898. */
  55899. useSpecularGlossinessInputEnergyConservation: boolean;
  55900. /** @hidden */
  55901. private _internalMarkAllSubMeshesAsMiscDirty;
  55902. /** @hidden */
  55903. _markAllSubMeshesAsMiscDirty(): void;
  55904. /**
  55905. * Instantiate a new istance of clear coat configuration.
  55906. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  55907. */
  55908. constructor(markAllSubMeshesAsMiscDirty: () => void);
  55909. /**
  55910. * Checks to see if a texture is used in the material.
  55911. * @param defines the list of "defines" to update.
  55912. */
  55913. prepareDefines(defines: IMaterialBRDFDefines): void;
  55914. /**
  55915. * Get the current class name of the texture useful for serialization or dynamic coding.
  55916. * @returns "PBRClearCoatConfiguration"
  55917. */
  55918. getClassName(): string;
  55919. /**
  55920. * Makes a duplicate of the current configuration into another one.
  55921. * @param brdfConfiguration define the config where to copy the info
  55922. */
  55923. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  55924. /**
  55925. * Serializes this BRDF configuration.
  55926. * @returns - An object with the serialized config.
  55927. */
  55928. serialize(): any;
  55929. /**
  55930. * Parses a anisotropy Configuration from a serialized object.
  55931. * @param source - Serialized object.
  55932. * @param scene Defines the scene we are parsing for
  55933. * @param rootUrl Defines the rootUrl to load from
  55934. */
  55935. parse(source: any, scene: Scene, rootUrl: string): void;
  55936. }
  55937. }
  55938. declare module BABYLON {
  55939. /**
  55940. * @hidden
  55941. */
  55942. export interface IMaterialSheenDefines {
  55943. SHEEN: boolean;
  55944. SHEEN_TEXTURE: boolean;
  55945. SHEEN_TEXTUREDIRECTUV: number;
  55946. SHEEN_LINKWITHALBEDO: boolean;
  55947. SHEEN_ROUGHNESS: boolean;
  55948. SHEEN_ALBEDOSCALING: boolean;
  55949. /** @hidden */
  55950. _areTexturesDirty: boolean;
  55951. }
  55952. /**
  55953. * Define the code related to the Sheen parameters of the pbr material.
  55954. */
  55955. export class PBRSheenConfiguration {
  55956. private _isEnabled;
  55957. /**
  55958. * Defines if the material uses sheen.
  55959. */
  55960. isEnabled: boolean;
  55961. private _linkSheenWithAlbedo;
  55962. /**
  55963. * Defines if the sheen is linked to the sheen color.
  55964. */
  55965. linkSheenWithAlbedo: boolean;
  55966. /**
  55967. * Defines the sheen intensity.
  55968. */
  55969. intensity: number;
  55970. /**
  55971. * Defines the sheen color.
  55972. */
  55973. color: Color3;
  55974. private _texture;
  55975. /**
  55976. * Stores the sheen tint values in a texture.
  55977. * rgb is tint
  55978. * a is a intensity or roughness if roughness has been defined
  55979. */
  55980. texture: Nullable<BaseTexture>;
  55981. private _roughness;
  55982. /**
  55983. * Defines the sheen roughness.
  55984. * It is not taken into account if linkSheenWithAlbedo is true.
  55985. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  55986. */
  55987. roughness: Nullable<number>;
  55988. private _albedoScaling;
  55989. /**
  55990. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  55991. * It allows the strength of the sheen effect to not depend on the base color of the material,
  55992. * making it easier to setup and tweak the effect
  55993. */
  55994. albedoScaling: boolean;
  55995. /** @hidden */
  55996. private _internalMarkAllSubMeshesAsTexturesDirty;
  55997. /** @hidden */
  55998. _markAllSubMeshesAsTexturesDirty(): void;
  55999. /**
  56000. * Instantiate a new istance of clear coat configuration.
  56001. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56002. */
  56003. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56004. /**
  56005. * Specifies that the submesh is ready to be used.
  56006. * @param defines the list of "defines" to update.
  56007. * @param scene defines the scene the material belongs to.
  56008. * @returns - boolean indicating that the submesh is ready or not.
  56009. */
  56010. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56011. /**
  56012. * Checks to see if a texture is used in the material.
  56013. * @param defines the list of "defines" to update.
  56014. * @param scene defines the scene the material belongs to.
  56015. */
  56016. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56017. /**
  56018. * Binds the material data.
  56019. * @param uniformBuffer defines the Uniform buffer to fill in.
  56020. * @param scene defines the scene the material belongs to.
  56021. * @param isFrozen defines wether the material is frozen or not.
  56022. */
  56023. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56024. /**
  56025. * Checks to see if a texture is used in the material.
  56026. * @param texture - Base texture to use.
  56027. * @returns - Boolean specifying if a texture is used in the material.
  56028. */
  56029. hasTexture(texture: BaseTexture): boolean;
  56030. /**
  56031. * Returns an array of the actively used textures.
  56032. * @param activeTextures Array of BaseTextures
  56033. */
  56034. getActiveTextures(activeTextures: BaseTexture[]): void;
  56035. /**
  56036. * Returns the animatable textures.
  56037. * @param animatables Array of animatable textures.
  56038. */
  56039. getAnimatables(animatables: IAnimatable[]): void;
  56040. /**
  56041. * Disposes the resources of the material.
  56042. * @param forceDisposeTextures - Forces the disposal of all textures.
  56043. */
  56044. dispose(forceDisposeTextures?: boolean): void;
  56045. /**
  56046. * Get the current class name of the texture useful for serialization or dynamic coding.
  56047. * @returns "PBRSheenConfiguration"
  56048. */
  56049. getClassName(): string;
  56050. /**
  56051. * Add fallbacks to the effect fallbacks list.
  56052. * @param defines defines the Base texture to use.
  56053. * @param fallbacks defines the current fallback list.
  56054. * @param currentRank defines the current fallback rank.
  56055. * @returns the new fallback rank.
  56056. */
  56057. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56058. /**
  56059. * Add the required uniforms to the current list.
  56060. * @param uniforms defines the current uniform list.
  56061. */
  56062. static AddUniforms(uniforms: string[]): void;
  56063. /**
  56064. * Add the required uniforms to the current buffer.
  56065. * @param uniformBuffer defines the current uniform buffer.
  56066. */
  56067. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56068. /**
  56069. * Add the required samplers to the current list.
  56070. * @param samplers defines the current sampler list.
  56071. */
  56072. static AddSamplers(samplers: string[]): void;
  56073. /**
  56074. * Makes a duplicate of the current configuration into another one.
  56075. * @param sheenConfiguration define the config where to copy the info
  56076. */
  56077. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  56078. /**
  56079. * Serializes this BRDF configuration.
  56080. * @returns - An object with the serialized config.
  56081. */
  56082. serialize(): any;
  56083. /**
  56084. * Parses a anisotropy Configuration from a serialized object.
  56085. * @param source - Serialized object.
  56086. * @param scene Defines the scene we are parsing for
  56087. * @param rootUrl Defines the rootUrl to load from
  56088. */
  56089. parse(source: any, scene: Scene, rootUrl: string): void;
  56090. }
  56091. }
  56092. declare module BABYLON {
  56093. /**
  56094. * @hidden
  56095. */
  56096. export interface IMaterialSubSurfaceDefines {
  56097. SUBSURFACE: boolean;
  56098. SS_REFRACTION: boolean;
  56099. SS_TRANSLUCENCY: boolean;
  56100. SS_SCATTERING: boolean;
  56101. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56102. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56103. SS_REFRACTIONMAP_3D: boolean;
  56104. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56105. SS_LODINREFRACTIONALPHA: boolean;
  56106. SS_GAMMAREFRACTION: boolean;
  56107. SS_RGBDREFRACTION: boolean;
  56108. SS_LINEARSPECULARREFRACTION: boolean;
  56109. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56110. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56111. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56112. /** @hidden */
  56113. _areTexturesDirty: boolean;
  56114. }
  56115. /**
  56116. * Define the code related to the sub surface parameters of the pbr material.
  56117. */
  56118. export class PBRSubSurfaceConfiguration {
  56119. private _isRefractionEnabled;
  56120. /**
  56121. * Defines if the refraction is enabled in the material.
  56122. */
  56123. isRefractionEnabled: boolean;
  56124. private _isTranslucencyEnabled;
  56125. /**
  56126. * Defines if the translucency is enabled in the material.
  56127. */
  56128. isTranslucencyEnabled: boolean;
  56129. private _isScatteringEnabled;
  56130. /**
  56131. * Defines if the sub surface scattering is enabled in the material.
  56132. */
  56133. isScatteringEnabled: boolean;
  56134. private _scatteringDiffusionProfileIndex;
  56135. /**
  56136. * Diffusion profile for subsurface scattering.
  56137. * Useful for better scattering in the skins or foliages.
  56138. */
  56139. get scatteringDiffusionProfile(): Nullable<Color3>;
  56140. set scatteringDiffusionProfile(c: Nullable<Color3>);
  56141. /**
  56142. * Defines the refraction intensity of the material.
  56143. * The refraction when enabled replaces the Diffuse part of the material.
  56144. * The intensity helps transitionning between diffuse and refraction.
  56145. */
  56146. refractionIntensity: number;
  56147. /**
  56148. * Defines the translucency intensity of the material.
  56149. * When translucency has been enabled, this defines how much of the "translucency"
  56150. * is addded to the diffuse part of the material.
  56151. */
  56152. translucencyIntensity: number;
  56153. /**
  56154. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  56155. */
  56156. useAlbedoToTintRefraction: boolean;
  56157. private _thicknessTexture;
  56158. /**
  56159. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  56160. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  56161. * 0 would mean minimumThickness
  56162. * 1 would mean maximumThickness
  56163. * The other channels might be use as a mask to vary the different effects intensity.
  56164. */
  56165. thicknessTexture: Nullable<BaseTexture>;
  56166. private _refractionTexture;
  56167. /**
  56168. * Defines the texture to use for refraction.
  56169. */
  56170. refractionTexture: Nullable<BaseTexture>;
  56171. private _indexOfRefraction;
  56172. /**
  56173. * Index of refraction of the material base layer.
  56174. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56175. *
  56176. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  56177. *
  56178. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  56179. */
  56180. indexOfRefraction: number;
  56181. private _volumeIndexOfRefraction;
  56182. /**
  56183. * Index of refraction of the material's volume.
  56184. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  56185. *
  56186. * This ONLY impacts refraction. If not provided or given a non-valid value,
  56187. * the volume will use the same IOR as the surface.
  56188. */
  56189. get volumeIndexOfRefraction(): number;
  56190. set volumeIndexOfRefraction(value: number);
  56191. private _invertRefractionY;
  56192. /**
  56193. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  56194. */
  56195. invertRefractionY: boolean;
  56196. private _linkRefractionWithTransparency;
  56197. /**
  56198. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  56199. * Materials half opaque for instance using refraction could benefit from this control.
  56200. */
  56201. linkRefractionWithTransparency: boolean;
  56202. /**
  56203. * Defines the minimum thickness stored in the thickness map.
  56204. * If no thickness map is defined, this value will be used to simulate thickness.
  56205. */
  56206. minimumThickness: number;
  56207. /**
  56208. * Defines the maximum thickness stored in the thickness map.
  56209. */
  56210. maximumThickness: number;
  56211. /**
  56212. * Defines the volume tint of the material.
  56213. * This is used for both translucency and scattering.
  56214. */
  56215. tintColor: Color3;
  56216. /**
  56217. * Defines the distance at which the tint color should be found in the media.
  56218. * This is used for refraction only.
  56219. */
  56220. tintColorAtDistance: number;
  56221. /**
  56222. * Defines how far each channel transmit through the media.
  56223. * It is defined as a color to simplify it selection.
  56224. */
  56225. diffusionDistance: Color3;
  56226. private _useMaskFromThicknessTexture;
  56227. /**
  56228. * Stores the intensity of the different subsurface effects in the thickness texture.
  56229. * * the green channel is the translucency intensity.
  56230. * * the blue channel is the scattering intensity.
  56231. * * the alpha channel is the refraction intensity.
  56232. */
  56233. useMaskFromThicknessTexture: boolean;
  56234. private _scene;
  56235. /** @hidden */
  56236. private _internalMarkAllSubMeshesAsTexturesDirty;
  56237. private _internalMarkScenePrePassDirty;
  56238. /** @hidden */
  56239. _markAllSubMeshesAsTexturesDirty(): void;
  56240. /** @hidden */
  56241. _markScenePrePassDirty(): void;
  56242. /**
  56243. * Instantiate a new istance of sub surface configuration.
  56244. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56245. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  56246. * @param scene The scene
  56247. */
  56248. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  56249. /**
  56250. * Gets wehter the submesh is ready to be used or not.
  56251. * @param defines the list of "defines" to update.
  56252. * @param scene defines the scene the material belongs to.
  56253. * @returns - boolean indicating that the submesh is ready or not.
  56254. */
  56255. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  56256. /**
  56257. * Checks to see if a texture is used in the material.
  56258. * @param defines the list of "defines" to update.
  56259. * @param scene defines the scene to the material belongs to.
  56260. */
  56261. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  56262. /**
  56263. * Binds the material data.
  56264. * @param uniformBuffer defines the Uniform buffer to fill in.
  56265. * @param scene defines the scene the material belongs to.
  56266. * @param engine defines the engine the material belongs to.
  56267. * @param isFrozen defines whether the material is frozen or not.
  56268. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  56269. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  56270. */
  56271. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  56272. /**
  56273. * Unbinds the material from the mesh.
  56274. * @param activeEffect defines the effect that should be unbound from.
  56275. * @returns true if unbound, otherwise false
  56276. */
  56277. unbind(activeEffect: Effect): boolean;
  56278. /**
  56279. * Returns the texture used for refraction or null if none is used.
  56280. * @param scene defines the scene the material belongs to.
  56281. * @returns - Refraction texture if present. If no refraction texture and refraction
  56282. * is linked with transparency, returns environment texture. Otherwise, returns null.
  56283. */
  56284. private _getRefractionTexture;
  56285. /**
  56286. * Returns true if alpha blending should be disabled.
  56287. */
  56288. get disableAlphaBlending(): boolean;
  56289. /**
  56290. * Fills the list of render target textures.
  56291. * @param renderTargets the list of render targets to update
  56292. */
  56293. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  56294. /**
  56295. * Checks to see if a texture is used in the material.
  56296. * @param texture - Base texture to use.
  56297. * @returns - Boolean specifying if a texture is used in the material.
  56298. */
  56299. hasTexture(texture: BaseTexture): boolean;
  56300. /**
  56301. * Gets a boolean indicating that current material needs to register RTT
  56302. * @returns true if this uses a render target otherwise false.
  56303. */
  56304. hasRenderTargetTextures(): boolean;
  56305. /**
  56306. * Returns an array of the actively used textures.
  56307. * @param activeTextures Array of BaseTextures
  56308. */
  56309. getActiveTextures(activeTextures: BaseTexture[]): void;
  56310. /**
  56311. * Returns the animatable textures.
  56312. * @param animatables Array of animatable textures.
  56313. */
  56314. getAnimatables(animatables: IAnimatable[]): void;
  56315. /**
  56316. * Disposes the resources of the material.
  56317. * @param forceDisposeTextures - Forces the disposal of all textures.
  56318. */
  56319. dispose(forceDisposeTextures?: boolean): void;
  56320. /**
  56321. * Get the current class name of the texture useful for serialization or dynamic coding.
  56322. * @returns "PBRSubSurfaceConfiguration"
  56323. */
  56324. getClassName(): string;
  56325. /**
  56326. * Add fallbacks to the effect fallbacks list.
  56327. * @param defines defines the Base texture to use.
  56328. * @param fallbacks defines the current fallback list.
  56329. * @param currentRank defines the current fallback rank.
  56330. * @returns the new fallback rank.
  56331. */
  56332. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56333. /**
  56334. * Add the required uniforms to the current list.
  56335. * @param uniforms defines the current uniform list.
  56336. */
  56337. static AddUniforms(uniforms: string[]): void;
  56338. /**
  56339. * Add the required samplers to the current list.
  56340. * @param samplers defines the current sampler list.
  56341. */
  56342. static AddSamplers(samplers: string[]): void;
  56343. /**
  56344. * Add the required uniforms to the current buffer.
  56345. * @param uniformBuffer defines the current uniform buffer.
  56346. */
  56347. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56348. /**
  56349. * Makes a duplicate of the current configuration into another one.
  56350. * @param configuration define the config where to copy the info
  56351. */
  56352. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  56353. /**
  56354. * Serializes this Sub Surface configuration.
  56355. * @returns - An object with the serialized config.
  56356. */
  56357. serialize(): any;
  56358. /**
  56359. * Parses a anisotropy Configuration from a serialized object.
  56360. * @param source - Serialized object.
  56361. * @param scene Defines the scene we are parsing for
  56362. * @param rootUrl Defines the rootUrl to load from
  56363. */
  56364. parse(source: any, scene: Scene, rootUrl: string): void;
  56365. }
  56366. }
  56367. declare module BABYLON {
  56368. /** @hidden */
  56369. export var pbrFragmentDeclaration: {
  56370. name: string;
  56371. shader: string;
  56372. };
  56373. }
  56374. declare module BABYLON {
  56375. /** @hidden */
  56376. export var pbrUboDeclaration: {
  56377. name: string;
  56378. shader: string;
  56379. };
  56380. }
  56381. declare module BABYLON {
  56382. /** @hidden */
  56383. export var pbrFragmentExtraDeclaration: {
  56384. name: string;
  56385. shader: string;
  56386. };
  56387. }
  56388. declare module BABYLON {
  56389. /** @hidden */
  56390. export var pbrFragmentSamplersDeclaration: {
  56391. name: string;
  56392. shader: string;
  56393. };
  56394. }
  56395. declare module BABYLON {
  56396. /** @hidden */
  56397. export var subSurfaceScatteringFunctions: {
  56398. name: string;
  56399. shader: string;
  56400. };
  56401. }
  56402. declare module BABYLON {
  56403. /** @hidden */
  56404. export var importanceSampling: {
  56405. name: string;
  56406. shader: string;
  56407. };
  56408. }
  56409. declare module BABYLON {
  56410. /** @hidden */
  56411. export var pbrHelperFunctions: {
  56412. name: string;
  56413. shader: string;
  56414. };
  56415. }
  56416. declare module BABYLON {
  56417. /** @hidden */
  56418. export var harmonicsFunctions: {
  56419. name: string;
  56420. shader: string;
  56421. };
  56422. }
  56423. declare module BABYLON {
  56424. /** @hidden */
  56425. export var pbrDirectLightingSetupFunctions: {
  56426. name: string;
  56427. shader: string;
  56428. };
  56429. }
  56430. declare module BABYLON {
  56431. /** @hidden */
  56432. export var pbrDirectLightingFalloffFunctions: {
  56433. name: string;
  56434. shader: string;
  56435. };
  56436. }
  56437. declare module BABYLON {
  56438. /** @hidden */
  56439. export var pbrBRDFFunctions: {
  56440. name: string;
  56441. shader: string;
  56442. };
  56443. }
  56444. declare module BABYLON {
  56445. /** @hidden */
  56446. export var hdrFilteringFunctions: {
  56447. name: string;
  56448. shader: string;
  56449. };
  56450. }
  56451. declare module BABYLON {
  56452. /** @hidden */
  56453. export var pbrDirectLightingFunctions: {
  56454. name: string;
  56455. shader: string;
  56456. };
  56457. }
  56458. declare module BABYLON {
  56459. /** @hidden */
  56460. export var pbrIBLFunctions: {
  56461. name: string;
  56462. shader: string;
  56463. };
  56464. }
  56465. declare module BABYLON {
  56466. /** @hidden */
  56467. export var pbrBlockAlbedoOpacity: {
  56468. name: string;
  56469. shader: string;
  56470. };
  56471. }
  56472. declare module BABYLON {
  56473. /** @hidden */
  56474. export var pbrBlockReflectivity: {
  56475. name: string;
  56476. shader: string;
  56477. };
  56478. }
  56479. declare module BABYLON {
  56480. /** @hidden */
  56481. export var pbrBlockAmbientOcclusion: {
  56482. name: string;
  56483. shader: string;
  56484. };
  56485. }
  56486. declare module BABYLON {
  56487. /** @hidden */
  56488. export var pbrBlockAlphaFresnel: {
  56489. name: string;
  56490. shader: string;
  56491. };
  56492. }
  56493. declare module BABYLON {
  56494. /** @hidden */
  56495. export var pbrBlockAnisotropic: {
  56496. name: string;
  56497. shader: string;
  56498. };
  56499. }
  56500. declare module BABYLON {
  56501. /** @hidden */
  56502. export var pbrBlockReflection: {
  56503. name: string;
  56504. shader: string;
  56505. };
  56506. }
  56507. declare module BABYLON {
  56508. /** @hidden */
  56509. export var pbrBlockSheen: {
  56510. name: string;
  56511. shader: string;
  56512. };
  56513. }
  56514. declare module BABYLON {
  56515. /** @hidden */
  56516. export var pbrBlockClearcoat: {
  56517. name: string;
  56518. shader: string;
  56519. };
  56520. }
  56521. declare module BABYLON {
  56522. /** @hidden */
  56523. export var pbrBlockSubSurface: {
  56524. name: string;
  56525. shader: string;
  56526. };
  56527. }
  56528. declare module BABYLON {
  56529. /** @hidden */
  56530. export var pbrBlockNormalGeometric: {
  56531. name: string;
  56532. shader: string;
  56533. };
  56534. }
  56535. declare module BABYLON {
  56536. /** @hidden */
  56537. export var pbrBlockNormalFinal: {
  56538. name: string;
  56539. shader: string;
  56540. };
  56541. }
  56542. declare module BABYLON {
  56543. /** @hidden */
  56544. export var pbrBlockLightmapInit: {
  56545. name: string;
  56546. shader: string;
  56547. };
  56548. }
  56549. declare module BABYLON {
  56550. /** @hidden */
  56551. export var pbrBlockGeometryInfo: {
  56552. name: string;
  56553. shader: string;
  56554. };
  56555. }
  56556. declare module BABYLON {
  56557. /** @hidden */
  56558. export var pbrBlockReflectance0: {
  56559. name: string;
  56560. shader: string;
  56561. };
  56562. }
  56563. declare module BABYLON {
  56564. /** @hidden */
  56565. export var pbrBlockReflectance: {
  56566. name: string;
  56567. shader: string;
  56568. };
  56569. }
  56570. declare module BABYLON {
  56571. /** @hidden */
  56572. export var pbrBlockDirectLighting: {
  56573. name: string;
  56574. shader: string;
  56575. };
  56576. }
  56577. declare module BABYLON {
  56578. /** @hidden */
  56579. export var pbrBlockFinalLitComponents: {
  56580. name: string;
  56581. shader: string;
  56582. };
  56583. }
  56584. declare module BABYLON {
  56585. /** @hidden */
  56586. export var pbrBlockFinalUnlitComponents: {
  56587. name: string;
  56588. shader: string;
  56589. };
  56590. }
  56591. declare module BABYLON {
  56592. /** @hidden */
  56593. export var pbrBlockFinalColorComposition: {
  56594. name: string;
  56595. shader: string;
  56596. };
  56597. }
  56598. declare module BABYLON {
  56599. /** @hidden */
  56600. export var pbrBlockImageProcessing: {
  56601. name: string;
  56602. shader: string;
  56603. };
  56604. }
  56605. declare module BABYLON {
  56606. /** @hidden */
  56607. export var pbrDebug: {
  56608. name: string;
  56609. shader: string;
  56610. };
  56611. }
  56612. declare module BABYLON {
  56613. /** @hidden */
  56614. export var pbrPixelShader: {
  56615. name: string;
  56616. shader: string;
  56617. };
  56618. }
  56619. declare module BABYLON {
  56620. /** @hidden */
  56621. export var pbrVertexDeclaration: {
  56622. name: string;
  56623. shader: string;
  56624. };
  56625. }
  56626. declare module BABYLON {
  56627. /** @hidden */
  56628. export var pbrVertexShader: {
  56629. name: string;
  56630. shader: string;
  56631. };
  56632. }
  56633. declare module BABYLON {
  56634. /**
  56635. * Manages the defines for the PBR Material.
  56636. * @hidden
  56637. */
  56638. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  56639. PBR: boolean;
  56640. NUM_SAMPLES: string;
  56641. REALTIME_FILTERING: boolean;
  56642. MAINUV1: boolean;
  56643. MAINUV2: boolean;
  56644. UV1: boolean;
  56645. UV2: boolean;
  56646. ALBEDO: boolean;
  56647. GAMMAALBEDO: boolean;
  56648. ALBEDODIRECTUV: number;
  56649. VERTEXCOLOR: boolean;
  56650. DETAIL: boolean;
  56651. DETAILDIRECTUV: number;
  56652. DETAIL_NORMALBLENDMETHOD: number;
  56653. AMBIENT: boolean;
  56654. AMBIENTDIRECTUV: number;
  56655. AMBIENTINGRAYSCALE: boolean;
  56656. OPACITY: boolean;
  56657. VERTEXALPHA: boolean;
  56658. OPACITYDIRECTUV: number;
  56659. OPACITYRGB: boolean;
  56660. ALPHATEST: boolean;
  56661. DEPTHPREPASS: boolean;
  56662. ALPHABLEND: boolean;
  56663. ALPHAFROMALBEDO: boolean;
  56664. ALPHATESTVALUE: string;
  56665. SPECULAROVERALPHA: boolean;
  56666. RADIANCEOVERALPHA: boolean;
  56667. ALPHAFRESNEL: boolean;
  56668. LINEARALPHAFRESNEL: boolean;
  56669. PREMULTIPLYALPHA: boolean;
  56670. EMISSIVE: boolean;
  56671. EMISSIVEDIRECTUV: number;
  56672. REFLECTIVITY: boolean;
  56673. REFLECTIVITYDIRECTUV: number;
  56674. SPECULARTERM: boolean;
  56675. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  56676. MICROSURFACEAUTOMATIC: boolean;
  56677. LODBASEDMICROSFURACE: boolean;
  56678. MICROSURFACEMAP: boolean;
  56679. MICROSURFACEMAPDIRECTUV: number;
  56680. METALLICWORKFLOW: boolean;
  56681. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  56682. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  56683. METALLNESSSTOREINMETALMAPBLUE: boolean;
  56684. AOSTOREINMETALMAPRED: boolean;
  56685. METALLIC_REFLECTANCE: boolean;
  56686. METALLIC_REFLECTANCEDIRECTUV: number;
  56687. ENVIRONMENTBRDF: boolean;
  56688. ENVIRONMENTBRDF_RGBD: boolean;
  56689. NORMAL: boolean;
  56690. TANGENT: boolean;
  56691. BUMP: boolean;
  56692. BUMPDIRECTUV: number;
  56693. OBJECTSPACE_NORMALMAP: boolean;
  56694. PARALLAX: boolean;
  56695. PARALLAXOCCLUSION: boolean;
  56696. NORMALXYSCALE: boolean;
  56697. LIGHTMAP: boolean;
  56698. LIGHTMAPDIRECTUV: number;
  56699. USELIGHTMAPASSHADOWMAP: boolean;
  56700. GAMMALIGHTMAP: boolean;
  56701. RGBDLIGHTMAP: boolean;
  56702. REFLECTION: boolean;
  56703. REFLECTIONMAP_3D: boolean;
  56704. REFLECTIONMAP_SPHERICAL: boolean;
  56705. REFLECTIONMAP_PLANAR: boolean;
  56706. REFLECTIONMAP_CUBIC: boolean;
  56707. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  56708. REFLECTIONMAP_PROJECTION: boolean;
  56709. REFLECTIONMAP_SKYBOX: boolean;
  56710. REFLECTIONMAP_EXPLICIT: boolean;
  56711. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  56712. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  56713. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  56714. INVERTCUBICMAP: boolean;
  56715. USESPHERICALFROMREFLECTIONMAP: boolean;
  56716. USEIRRADIANCEMAP: boolean;
  56717. SPHERICAL_HARMONICS: boolean;
  56718. USESPHERICALINVERTEX: boolean;
  56719. REFLECTIONMAP_OPPOSITEZ: boolean;
  56720. LODINREFLECTIONALPHA: boolean;
  56721. GAMMAREFLECTION: boolean;
  56722. RGBDREFLECTION: boolean;
  56723. LINEARSPECULARREFLECTION: boolean;
  56724. RADIANCEOCCLUSION: boolean;
  56725. HORIZONOCCLUSION: boolean;
  56726. INSTANCES: boolean;
  56727. THIN_INSTANCES: boolean;
  56728. PREPASS: boolean;
  56729. PREPASS_IRRADIANCE: boolean;
  56730. PREPASS_IRRADIANCE_INDEX: number;
  56731. PREPASS_ALBEDO: boolean;
  56732. PREPASS_ALBEDO_INDEX: number;
  56733. PREPASS_DEPTHNORMAL: boolean;
  56734. PREPASS_DEPTHNORMAL_INDEX: number;
  56735. PREPASS_POSITION: boolean;
  56736. PREPASS_POSITION_INDEX: number;
  56737. PREPASS_VELOCITY: boolean;
  56738. PREPASS_VELOCITY_INDEX: number;
  56739. PREPASS_REFLECTIVITY: boolean;
  56740. PREPASS_REFLECTIVITY_INDEX: number;
  56741. SCENE_MRT_COUNT: number;
  56742. NUM_BONE_INFLUENCERS: number;
  56743. BonesPerMesh: number;
  56744. BONETEXTURE: boolean;
  56745. BONES_VELOCITY_ENABLED: boolean;
  56746. NONUNIFORMSCALING: boolean;
  56747. MORPHTARGETS: boolean;
  56748. MORPHTARGETS_NORMAL: boolean;
  56749. MORPHTARGETS_TANGENT: boolean;
  56750. MORPHTARGETS_UV: boolean;
  56751. NUM_MORPH_INFLUENCERS: number;
  56752. IMAGEPROCESSING: boolean;
  56753. VIGNETTE: boolean;
  56754. VIGNETTEBLENDMODEMULTIPLY: boolean;
  56755. VIGNETTEBLENDMODEOPAQUE: boolean;
  56756. TONEMAPPING: boolean;
  56757. TONEMAPPING_ACES: boolean;
  56758. CONTRAST: boolean;
  56759. COLORCURVES: boolean;
  56760. COLORGRADING: boolean;
  56761. COLORGRADING3D: boolean;
  56762. SAMPLER3DGREENDEPTH: boolean;
  56763. SAMPLER3DBGRMAP: boolean;
  56764. IMAGEPROCESSINGPOSTPROCESS: boolean;
  56765. EXPOSURE: boolean;
  56766. MULTIVIEW: boolean;
  56767. USEPHYSICALLIGHTFALLOFF: boolean;
  56768. USEGLTFLIGHTFALLOFF: boolean;
  56769. TWOSIDEDLIGHTING: boolean;
  56770. SHADOWFLOAT: boolean;
  56771. CLIPPLANE: boolean;
  56772. CLIPPLANE2: boolean;
  56773. CLIPPLANE3: boolean;
  56774. CLIPPLANE4: boolean;
  56775. CLIPPLANE5: boolean;
  56776. CLIPPLANE6: boolean;
  56777. POINTSIZE: boolean;
  56778. FOG: boolean;
  56779. LOGARITHMICDEPTH: boolean;
  56780. FORCENORMALFORWARD: boolean;
  56781. SPECULARAA: boolean;
  56782. CLEARCOAT: boolean;
  56783. CLEARCOAT_DEFAULTIOR: boolean;
  56784. CLEARCOAT_TEXTURE: boolean;
  56785. CLEARCOAT_TEXTUREDIRECTUV: number;
  56786. CLEARCOAT_BUMP: boolean;
  56787. CLEARCOAT_BUMPDIRECTUV: number;
  56788. CLEARCOAT_REMAP_F0: boolean;
  56789. CLEARCOAT_TINT: boolean;
  56790. CLEARCOAT_TINT_TEXTURE: boolean;
  56791. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56792. ANISOTROPIC: boolean;
  56793. ANISOTROPIC_TEXTURE: boolean;
  56794. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56795. BRDF_V_HEIGHT_CORRELATED: boolean;
  56796. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56797. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56798. SHEEN: boolean;
  56799. SHEEN_TEXTURE: boolean;
  56800. SHEEN_TEXTUREDIRECTUV: number;
  56801. SHEEN_LINKWITHALBEDO: boolean;
  56802. SHEEN_ROUGHNESS: boolean;
  56803. SHEEN_ALBEDOSCALING: boolean;
  56804. SUBSURFACE: boolean;
  56805. SS_REFRACTION: boolean;
  56806. SS_TRANSLUCENCY: boolean;
  56807. SS_SCATTERING: boolean;
  56808. SS_THICKNESSANDMASK_TEXTURE: boolean;
  56809. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  56810. SS_REFRACTIONMAP_3D: boolean;
  56811. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  56812. SS_LODINREFRACTIONALPHA: boolean;
  56813. SS_GAMMAREFRACTION: boolean;
  56814. SS_RGBDREFRACTION: boolean;
  56815. SS_LINEARSPECULARREFRACTION: boolean;
  56816. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  56817. SS_ALBEDOFORREFRACTIONTINT: boolean;
  56818. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  56819. UNLIT: boolean;
  56820. DEBUGMODE: number;
  56821. /**
  56822. * Initializes the PBR Material defines.
  56823. */
  56824. constructor();
  56825. /**
  56826. * Resets the PBR Material defines.
  56827. */
  56828. reset(): void;
  56829. }
  56830. /**
  56831. * The Physically based material base class of BJS.
  56832. *
  56833. * This offers the main features of a standard PBR material.
  56834. * For more information, please refer to the documentation :
  56835. * https://doc.babylonjs.com/how_to/physically_based_rendering
  56836. */
  56837. export abstract class PBRBaseMaterial extends PushMaterial {
  56838. /**
  56839. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  56840. */
  56841. static readonly PBRMATERIAL_OPAQUE: number;
  56842. /**
  56843. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  56844. */
  56845. static readonly PBRMATERIAL_ALPHATEST: number;
  56846. /**
  56847. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56848. */
  56849. static readonly PBRMATERIAL_ALPHABLEND: number;
  56850. /**
  56851. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  56852. * They are also discarded below the alpha cutoff threshold to improve performances.
  56853. */
  56854. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  56855. /**
  56856. * Defines the default value of how much AO map is occluding the analytical lights
  56857. * (point spot...).
  56858. */
  56859. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  56860. /**
  56861. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  56862. */
  56863. static readonly LIGHTFALLOFF_PHYSICAL: number;
  56864. /**
  56865. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  56866. * to enhance interoperability with other engines.
  56867. */
  56868. static readonly LIGHTFALLOFF_GLTF: number;
  56869. /**
  56870. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  56871. * to enhance interoperability with other materials.
  56872. */
  56873. static readonly LIGHTFALLOFF_STANDARD: number;
  56874. /**
  56875. * Intensity of the direct lights e.g. the four lights available in your scene.
  56876. * This impacts both the direct diffuse and specular highlights.
  56877. */
  56878. protected _directIntensity: number;
  56879. /**
  56880. * Intensity of the emissive part of the material.
  56881. * This helps controlling the emissive effect without modifying the emissive color.
  56882. */
  56883. protected _emissiveIntensity: number;
  56884. /**
  56885. * Intensity of the environment e.g. how much the environment will light the object
  56886. * either through harmonics for rough material or through the refelction for shiny ones.
  56887. */
  56888. protected _environmentIntensity: number;
  56889. /**
  56890. * This is a special control allowing the reduction of the specular highlights coming from the
  56891. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  56892. */
  56893. protected _specularIntensity: number;
  56894. /**
  56895. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  56896. */
  56897. private _lightingInfos;
  56898. /**
  56899. * Debug Control allowing disabling the bump map on this material.
  56900. */
  56901. protected _disableBumpMap: boolean;
  56902. /**
  56903. * AKA Diffuse Texture in standard nomenclature.
  56904. */
  56905. protected _albedoTexture: Nullable<BaseTexture>;
  56906. /**
  56907. * AKA Occlusion Texture in other nomenclature.
  56908. */
  56909. protected _ambientTexture: Nullable<BaseTexture>;
  56910. /**
  56911. * AKA Occlusion Texture Intensity in other nomenclature.
  56912. */
  56913. protected _ambientTextureStrength: number;
  56914. /**
  56915. * Defines how much the AO map is occluding the analytical lights (point spot...).
  56916. * 1 means it completely occludes it
  56917. * 0 mean it has no impact
  56918. */
  56919. protected _ambientTextureImpactOnAnalyticalLights: number;
  56920. /**
  56921. * Stores the alpha values in a texture.
  56922. */
  56923. protected _opacityTexture: Nullable<BaseTexture>;
  56924. /**
  56925. * Stores the reflection values in a texture.
  56926. */
  56927. protected _reflectionTexture: Nullable<BaseTexture>;
  56928. /**
  56929. * Stores the emissive values in a texture.
  56930. */
  56931. protected _emissiveTexture: Nullable<BaseTexture>;
  56932. /**
  56933. * AKA Specular texture in other nomenclature.
  56934. */
  56935. protected _reflectivityTexture: Nullable<BaseTexture>;
  56936. /**
  56937. * Used to switch from specular/glossiness to metallic/roughness workflow.
  56938. */
  56939. protected _metallicTexture: Nullable<BaseTexture>;
  56940. /**
  56941. * Specifies the metallic scalar of the metallic/roughness workflow.
  56942. * Can also be used to scale the metalness values of the metallic texture.
  56943. */
  56944. protected _metallic: Nullable<number>;
  56945. /**
  56946. * Specifies the roughness scalar of the metallic/roughness workflow.
  56947. * Can also be used to scale the roughness values of the metallic texture.
  56948. */
  56949. protected _roughness: Nullable<number>;
  56950. /**
  56951. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  56952. * By default the indexOfrefraction is used to compute F0;
  56953. *
  56954. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  56955. *
  56956. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  56957. * F90 = metallicReflectanceColor;
  56958. */
  56959. protected _metallicF0Factor: number;
  56960. /**
  56961. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  56962. * By default the F90 is always 1;
  56963. *
  56964. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  56965. *
  56966. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  56967. * F90 = metallicReflectanceColor;
  56968. */
  56969. protected _metallicReflectanceColor: Color3;
  56970. /**
  56971. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  56972. * This is multiply against the scalar values defined in the material.
  56973. */
  56974. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  56975. /**
  56976. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  56977. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  56978. */
  56979. protected _microSurfaceTexture: Nullable<BaseTexture>;
  56980. /**
  56981. * Stores surface normal data used to displace a mesh in a texture.
  56982. */
  56983. protected _bumpTexture: Nullable<BaseTexture>;
  56984. /**
  56985. * Stores the pre-calculated light information of a mesh in a texture.
  56986. */
  56987. protected _lightmapTexture: Nullable<BaseTexture>;
  56988. /**
  56989. * The color of a material in ambient lighting.
  56990. */
  56991. protected _ambientColor: Color3;
  56992. /**
  56993. * AKA Diffuse Color in other nomenclature.
  56994. */
  56995. protected _albedoColor: Color3;
  56996. /**
  56997. * AKA Specular Color in other nomenclature.
  56998. */
  56999. protected _reflectivityColor: Color3;
  57000. /**
  57001. * The color applied when light is reflected from a material.
  57002. */
  57003. protected _reflectionColor: Color3;
  57004. /**
  57005. * The color applied when light is emitted from a material.
  57006. */
  57007. protected _emissiveColor: Color3;
  57008. /**
  57009. * AKA Glossiness in other nomenclature.
  57010. */
  57011. protected _microSurface: number;
  57012. /**
  57013. * Specifies that the material will use the light map as a show map.
  57014. */
  57015. protected _useLightmapAsShadowmap: boolean;
  57016. /**
  57017. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57018. * makes the reflect vector face the model (under horizon).
  57019. */
  57020. protected _useHorizonOcclusion: boolean;
  57021. /**
  57022. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57023. * too much the area relying on ambient texture to define their ambient occlusion.
  57024. */
  57025. protected _useRadianceOcclusion: boolean;
  57026. /**
  57027. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57028. */
  57029. protected _useAlphaFromAlbedoTexture: boolean;
  57030. /**
  57031. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  57032. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57033. */
  57034. protected _useSpecularOverAlpha: boolean;
  57035. /**
  57036. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57037. */
  57038. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57039. /**
  57040. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57041. */
  57042. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  57043. /**
  57044. * Specifies if the metallic texture contains the roughness information in its green channel.
  57045. */
  57046. protected _useRoughnessFromMetallicTextureGreen: boolean;
  57047. /**
  57048. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57049. */
  57050. protected _useMetallnessFromMetallicTextureBlue: boolean;
  57051. /**
  57052. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57053. */
  57054. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  57055. /**
  57056. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57057. */
  57058. protected _useAmbientInGrayScale: boolean;
  57059. /**
  57060. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57061. * The material will try to infer what glossiness each pixel should be.
  57062. */
  57063. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  57064. /**
  57065. * Defines the falloff type used in this material.
  57066. * It by default is Physical.
  57067. */
  57068. protected _lightFalloff: number;
  57069. /**
  57070. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57071. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57072. */
  57073. protected _useRadianceOverAlpha: boolean;
  57074. /**
  57075. * Allows using an object space normal map (instead of tangent space).
  57076. */
  57077. protected _useObjectSpaceNormalMap: boolean;
  57078. /**
  57079. * Allows using the bump map in parallax mode.
  57080. */
  57081. protected _useParallax: boolean;
  57082. /**
  57083. * Allows using the bump map in parallax occlusion mode.
  57084. */
  57085. protected _useParallaxOcclusion: boolean;
  57086. /**
  57087. * Controls the scale bias of the parallax mode.
  57088. */
  57089. protected _parallaxScaleBias: number;
  57090. /**
  57091. * If sets to true, disables all the lights affecting the material.
  57092. */
  57093. protected _disableLighting: boolean;
  57094. /**
  57095. * Number of Simultaneous lights allowed on the material.
  57096. */
  57097. protected _maxSimultaneousLights: number;
  57098. /**
  57099. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57100. */
  57101. protected _invertNormalMapX: boolean;
  57102. /**
  57103. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57104. */
  57105. protected _invertNormalMapY: boolean;
  57106. /**
  57107. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57108. */
  57109. protected _twoSidedLighting: boolean;
  57110. /**
  57111. * Defines the alpha limits in alpha test mode.
  57112. */
  57113. protected _alphaCutOff: number;
  57114. /**
  57115. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57116. */
  57117. protected _forceAlphaTest: boolean;
  57118. /**
  57119. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57120. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57121. */
  57122. protected _useAlphaFresnel: boolean;
  57123. /**
  57124. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57125. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57126. */
  57127. protected _useLinearAlphaFresnel: boolean;
  57128. /**
  57129. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  57130. * from cos thetav and roughness:
  57131. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  57132. */
  57133. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  57134. /**
  57135. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57136. */
  57137. protected _forceIrradianceInFragment: boolean;
  57138. private _realTimeFiltering;
  57139. /**
  57140. * Enables realtime filtering on the texture.
  57141. */
  57142. get realTimeFiltering(): boolean;
  57143. set realTimeFiltering(b: boolean);
  57144. private _realTimeFilteringQuality;
  57145. /**
  57146. * Quality switch for realtime filtering
  57147. */
  57148. get realTimeFilteringQuality(): number;
  57149. set realTimeFilteringQuality(n: number);
  57150. /**
  57151. * Can this material render to several textures at once
  57152. */
  57153. get canRenderToMRT(): boolean;
  57154. /**
  57155. * Force normal to face away from face.
  57156. */
  57157. protected _forceNormalForward: boolean;
  57158. /**
  57159. * Enables specular anti aliasing in the PBR shader.
  57160. * It will both interacts on the Geometry for analytical and IBL lighting.
  57161. * It also prefilter the roughness map based on the bump values.
  57162. */
  57163. protected _enableSpecularAntiAliasing: boolean;
  57164. /**
  57165. * Default configuration related to image processing available in the PBR Material.
  57166. */
  57167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57168. /**
  57169. * Keep track of the image processing observer to allow dispose and replace.
  57170. */
  57171. private _imageProcessingObserver;
  57172. /**
  57173. * Attaches a new image processing configuration to the PBR Material.
  57174. * @param configuration
  57175. */
  57176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57177. /**
  57178. * Stores the available render targets.
  57179. */
  57180. private _renderTargets;
  57181. /**
  57182. * Sets the global ambient color for the material used in lighting calculations.
  57183. */
  57184. private _globalAmbientColor;
  57185. /**
  57186. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  57187. */
  57188. private _useLogarithmicDepth;
  57189. /**
  57190. * If set to true, no lighting calculations will be applied.
  57191. */
  57192. private _unlit;
  57193. private _debugMode;
  57194. /**
  57195. * @hidden
  57196. * This is reserved for the inspector.
  57197. * Defines the material debug mode.
  57198. * It helps seeing only some components of the material while troubleshooting.
  57199. */
  57200. debugMode: number;
  57201. /**
  57202. * @hidden
  57203. * This is reserved for the inspector.
  57204. * Specify from where on screen the debug mode should start.
  57205. * The value goes from -1 (full screen) to 1 (not visible)
  57206. * It helps with side by side comparison against the final render
  57207. * This defaults to -1
  57208. */
  57209. private debugLimit;
  57210. /**
  57211. * @hidden
  57212. * This is reserved for the inspector.
  57213. * As the default viewing range might not be enough (if the ambient is really small for instance)
  57214. * You can use the factor to better multiply the final value.
  57215. */
  57216. private debugFactor;
  57217. /**
  57218. * Defines the clear coat layer parameters for the material.
  57219. */
  57220. readonly clearCoat: PBRClearCoatConfiguration;
  57221. /**
  57222. * Defines the anisotropic parameters for the material.
  57223. */
  57224. readonly anisotropy: PBRAnisotropicConfiguration;
  57225. /**
  57226. * Defines the BRDF parameters for the material.
  57227. */
  57228. readonly brdf: PBRBRDFConfiguration;
  57229. /**
  57230. * Defines the Sheen parameters for the material.
  57231. */
  57232. readonly sheen: PBRSheenConfiguration;
  57233. /**
  57234. * Defines the SubSurface parameters for the material.
  57235. */
  57236. readonly subSurface: PBRSubSurfaceConfiguration;
  57237. /**
  57238. * Defines additionnal PrePass parameters for the material.
  57239. */
  57240. readonly prePassConfiguration: PrePassConfiguration;
  57241. /**
  57242. * Defines the detail map parameters for the material.
  57243. */
  57244. readonly detailMap: DetailMapConfiguration;
  57245. protected _rebuildInParallel: boolean;
  57246. /**
  57247. * Instantiates a new PBRMaterial instance.
  57248. *
  57249. * @param name The material name
  57250. * @param scene The scene the material will be use in.
  57251. */
  57252. constructor(name: string, scene: Scene);
  57253. /**
  57254. * Gets a boolean indicating that current material needs to register RTT
  57255. */
  57256. get hasRenderTargetTextures(): boolean;
  57257. /**
  57258. * Gets the name of the material class.
  57259. */
  57260. getClassName(): string;
  57261. /**
  57262. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57263. */
  57264. get useLogarithmicDepth(): boolean;
  57265. /**
  57266. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  57267. */
  57268. set useLogarithmicDepth(value: boolean);
  57269. /**
  57270. * Returns true if alpha blending should be disabled.
  57271. */
  57272. protected get _disableAlphaBlending(): boolean;
  57273. /**
  57274. * Specifies whether or not this material should be rendered in alpha blend mode.
  57275. */
  57276. needAlphaBlending(): boolean;
  57277. /**
  57278. * Specifies whether or not this material should be rendered in alpha test mode.
  57279. */
  57280. needAlphaTesting(): boolean;
  57281. /**
  57282. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  57283. */
  57284. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  57285. /**
  57286. * Gets the texture used for the alpha test.
  57287. */
  57288. getAlphaTestTexture(): Nullable<BaseTexture>;
  57289. /**
  57290. * Specifies that the submesh is ready to be used.
  57291. * @param mesh - BJS mesh.
  57292. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  57293. * @param useInstances - Specifies that instances should be used.
  57294. * @returns - boolean indicating that the submesh is ready or not.
  57295. */
  57296. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57297. /**
  57298. * Specifies if the material uses metallic roughness workflow.
  57299. * @returns boolean specifiying if the material uses metallic roughness workflow.
  57300. */
  57301. isMetallicWorkflow(): boolean;
  57302. private _prepareEffect;
  57303. private _prepareDefines;
  57304. /**
  57305. * Force shader compilation
  57306. */
  57307. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  57308. /**
  57309. * Initializes the uniform buffer layout for the shader.
  57310. */
  57311. buildUniformLayout(): void;
  57312. /**
  57313. * Unbinds the material from the mesh
  57314. */
  57315. unbind(): void;
  57316. /**
  57317. * Binds the submesh data.
  57318. * @param world - The world matrix.
  57319. * @param mesh - The BJS mesh.
  57320. * @param subMesh - A submesh of the BJS mesh.
  57321. */
  57322. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57323. /**
  57324. * Returns the animatable textures.
  57325. * @returns - Array of animatable textures.
  57326. */
  57327. getAnimatables(): IAnimatable[];
  57328. /**
  57329. * Returns the texture used for reflections.
  57330. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  57331. */
  57332. private _getReflectionTexture;
  57333. /**
  57334. * Returns an array of the actively used textures.
  57335. * @returns - Array of BaseTextures
  57336. */
  57337. getActiveTextures(): BaseTexture[];
  57338. /**
  57339. * Checks to see if a texture is used in the material.
  57340. * @param texture - Base texture to use.
  57341. * @returns - Boolean specifying if a texture is used in the material.
  57342. */
  57343. hasTexture(texture: BaseTexture): boolean;
  57344. /**
  57345. * Sets the required values to the prepass renderer.
  57346. * @param prePassRenderer defines the prepass renderer to setup
  57347. */
  57348. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  57349. /**
  57350. * Disposes the resources of the material.
  57351. * @param forceDisposeEffect - Forces the disposal of effects.
  57352. * @param forceDisposeTextures - Forces the disposal of all textures.
  57353. */
  57354. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57355. }
  57356. }
  57357. declare module BABYLON {
  57358. /**
  57359. * The Physically based material of BJS.
  57360. *
  57361. * This offers the main features of a standard PBR material.
  57362. * For more information, please refer to the documentation :
  57363. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57364. */
  57365. export class PBRMaterial extends PBRBaseMaterial {
  57366. /**
  57367. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57368. */
  57369. static readonly PBRMATERIAL_OPAQUE: number;
  57370. /**
  57371. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57372. */
  57373. static readonly PBRMATERIAL_ALPHATEST: number;
  57374. /**
  57375. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57376. */
  57377. static readonly PBRMATERIAL_ALPHABLEND: number;
  57378. /**
  57379. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57380. * They are also discarded below the alpha cutoff threshold to improve performances.
  57381. */
  57382. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57383. /**
  57384. * Defines the default value of how much AO map is occluding the analytical lights
  57385. * (point spot...).
  57386. */
  57387. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57388. /**
  57389. * Intensity of the direct lights e.g. the four lights available in your scene.
  57390. * This impacts both the direct diffuse and specular highlights.
  57391. */
  57392. directIntensity: number;
  57393. /**
  57394. * Intensity of the emissive part of the material.
  57395. * This helps controlling the emissive effect without modifying the emissive color.
  57396. */
  57397. emissiveIntensity: number;
  57398. /**
  57399. * Intensity of the environment e.g. how much the environment will light the object
  57400. * either through harmonics for rough material or through the refelction for shiny ones.
  57401. */
  57402. environmentIntensity: number;
  57403. /**
  57404. * This is a special control allowing the reduction of the specular highlights coming from the
  57405. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57406. */
  57407. specularIntensity: number;
  57408. /**
  57409. * Debug Control allowing disabling the bump map on this material.
  57410. */
  57411. disableBumpMap: boolean;
  57412. /**
  57413. * AKA Diffuse Texture in standard nomenclature.
  57414. */
  57415. albedoTexture: BaseTexture;
  57416. /**
  57417. * AKA Occlusion Texture in other nomenclature.
  57418. */
  57419. ambientTexture: BaseTexture;
  57420. /**
  57421. * AKA Occlusion Texture Intensity in other nomenclature.
  57422. */
  57423. ambientTextureStrength: number;
  57424. /**
  57425. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57426. * 1 means it completely occludes it
  57427. * 0 mean it has no impact
  57428. */
  57429. ambientTextureImpactOnAnalyticalLights: number;
  57430. /**
  57431. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  57432. */
  57433. opacityTexture: BaseTexture;
  57434. /**
  57435. * Stores the reflection values in a texture.
  57436. */
  57437. reflectionTexture: Nullable<BaseTexture>;
  57438. /**
  57439. * Stores the emissive values in a texture.
  57440. */
  57441. emissiveTexture: BaseTexture;
  57442. /**
  57443. * AKA Specular texture in other nomenclature.
  57444. */
  57445. reflectivityTexture: BaseTexture;
  57446. /**
  57447. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57448. */
  57449. metallicTexture: BaseTexture;
  57450. /**
  57451. * Specifies the metallic scalar of the metallic/roughness workflow.
  57452. * Can also be used to scale the metalness values of the metallic texture.
  57453. */
  57454. metallic: Nullable<number>;
  57455. /**
  57456. * Specifies the roughness scalar of the metallic/roughness workflow.
  57457. * Can also be used to scale the roughness values of the metallic texture.
  57458. */
  57459. roughness: Nullable<number>;
  57460. /**
  57461. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57462. * By default the indexOfrefraction is used to compute F0;
  57463. *
  57464. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57465. *
  57466. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57467. * F90 = metallicReflectanceColor;
  57468. */
  57469. metallicF0Factor: number;
  57470. /**
  57471. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57472. * By default the F90 is always 1;
  57473. *
  57474. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57475. *
  57476. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57477. * F90 = metallicReflectanceColor;
  57478. */
  57479. metallicReflectanceColor: Color3;
  57480. /**
  57481. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57482. * This is multiply against the scalar values defined in the material.
  57483. */
  57484. metallicReflectanceTexture: Nullable<BaseTexture>;
  57485. /**
  57486. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57487. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57488. */
  57489. microSurfaceTexture: BaseTexture;
  57490. /**
  57491. * Stores surface normal data used to displace a mesh in a texture.
  57492. */
  57493. bumpTexture: BaseTexture;
  57494. /**
  57495. * Stores the pre-calculated light information of a mesh in a texture.
  57496. */
  57497. lightmapTexture: BaseTexture;
  57498. /**
  57499. * Stores the refracted light information in a texture.
  57500. */
  57501. get refractionTexture(): Nullable<BaseTexture>;
  57502. set refractionTexture(value: Nullable<BaseTexture>);
  57503. /**
  57504. * The color of a material in ambient lighting.
  57505. */
  57506. ambientColor: Color3;
  57507. /**
  57508. * AKA Diffuse Color in other nomenclature.
  57509. */
  57510. albedoColor: Color3;
  57511. /**
  57512. * AKA Specular Color in other nomenclature.
  57513. */
  57514. reflectivityColor: Color3;
  57515. /**
  57516. * The color reflected from the material.
  57517. */
  57518. reflectionColor: Color3;
  57519. /**
  57520. * The color emitted from the material.
  57521. */
  57522. emissiveColor: Color3;
  57523. /**
  57524. * AKA Glossiness in other nomenclature.
  57525. */
  57526. microSurface: number;
  57527. /**
  57528. * Index of refraction of the material base layer.
  57529. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57530. *
  57531. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57532. *
  57533. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57534. */
  57535. get indexOfRefraction(): number;
  57536. set indexOfRefraction(value: number);
  57537. /**
  57538. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57539. */
  57540. get invertRefractionY(): boolean;
  57541. set invertRefractionY(value: boolean);
  57542. /**
  57543. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57544. * Materials half opaque for instance using refraction could benefit from this control.
  57545. */
  57546. get linkRefractionWithTransparency(): boolean;
  57547. set linkRefractionWithTransparency(value: boolean);
  57548. /**
  57549. * If true, the light map contains occlusion information instead of lighting info.
  57550. */
  57551. useLightmapAsShadowmap: boolean;
  57552. /**
  57553. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  57554. */
  57555. useAlphaFromAlbedoTexture: boolean;
  57556. /**
  57557. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  57558. */
  57559. forceAlphaTest: boolean;
  57560. /**
  57561. * Defines the alpha limits in alpha test mode.
  57562. */
  57563. alphaCutOff: number;
  57564. /**
  57565. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  57566. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  57567. */
  57568. useSpecularOverAlpha: boolean;
  57569. /**
  57570. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  57571. */
  57572. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  57573. /**
  57574. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  57575. */
  57576. useRoughnessFromMetallicTextureAlpha: boolean;
  57577. /**
  57578. * Specifies if the metallic texture contains the roughness information in its green channel.
  57579. */
  57580. useRoughnessFromMetallicTextureGreen: boolean;
  57581. /**
  57582. * Specifies if the metallic texture contains the metallness information in its blue channel.
  57583. */
  57584. useMetallnessFromMetallicTextureBlue: boolean;
  57585. /**
  57586. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  57587. */
  57588. useAmbientOcclusionFromMetallicTextureRed: boolean;
  57589. /**
  57590. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  57591. */
  57592. useAmbientInGrayScale: boolean;
  57593. /**
  57594. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  57595. * The material will try to infer what glossiness each pixel should be.
  57596. */
  57597. useAutoMicroSurfaceFromReflectivityMap: boolean;
  57598. /**
  57599. * BJS is using an harcoded light falloff based on a manually sets up range.
  57600. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57601. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57602. */
  57603. get usePhysicalLightFalloff(): boolean;
  57604. /**
  57605. * BJS is using an harcoded light falloff based on a manually sets up range.
  57606. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  57607. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  57608. */
  57609. set usePhysicalLightFalloff(value: boolean);
  57610. /**
  57611. * In order to support the falloff compatibility with gltf, a special mode has been added
  57612. * to reproduce the gltf light falloff.
  57613. */
  57614. get useGLTFLightFalloff(): boolean;
  57615. /**
  57616. * In order to support the falloff compatibility with gltf, a special mode has been added
  57617. * to reproduce the gltf light falloff.
  57618. */
  57619. set useGLTFLightFalloff(value: boolean);
  57620. /**
  57621. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  57622. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  57623. */
  57624. useRadianceOverAlpha: boolean;
  57625. /**
  57626. * Allows using an object space normal map (instead of tangent space).
  57627. */
  57628. useObjectSpaceNormalMap: boolean;
  57629. /**
  57630. * Allows using the bump map in parallax mode.
  57631. */
  57632. useParallax: boolean;
  57633. /**
  57634. * Allows using the bump map in parallax occlusion mode.
  57635. */
  57636. useParallaxOcclusion: boolean;
  57637. /**
  57638. * Controls the scale bias of the parallax mode.
  57639. */
  57640. parallaxScaleBias: number;
  57641. /**
  57642. * If sets to true, disables all the lights affecting the material.
  57643. */
  57644. disableLighting: boolean;
  57645. /**
  57646. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  57647. */
  57648. forceIrradianceInFragment: boolean;
  57649. /**
  57650. * Number of Simultaneous lights allowed on the material.
  57651. */
  57652. maxSimultaneousLights: number;
  57653. /**
  57654. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  57655. */
  57656. invertNormalMapX: boolean;
  57657. /**
  57658. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  57659. */
  57660. invertNormalMapY: boolean;
  57661. /**
  57662. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  57663. */
  57664. twoSidedLighting: boolean;
  57665. /**
  57666. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57667. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  57668. */
  57669. useAlphaFresnel: boolean;
  57670. /**
  57671. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  57672. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  57673. */
  57674. useLinearAlphaFresnel: boolean;
  57675. /**
  57676. * Let user defines the brdf lookup texture used for IBL.
  57677. * A default 8bit version is embedded but you could point at :
  57678. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  57679. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  57680. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  57681. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  57682. */
  57683. environmentBRDFTexture: Nullable<BaseTexture>;
  57684. /**
  57685. * Force normal to face away from face.
  57686. */
  57687. forceNormalForward: boolean;
  57688. /**
  57689. * Enables specular anti aliasing in the PBR shader.
  57690. * It will both interacts on the Geometry for analytical and IBL lighting.
  57691. * It also prefilter the roughness map based on the bump values.
  57692. */
  57693. enableSpecularAntiAliasing: boolean;
  57694. /**
  57695. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  57696. * makes the reflect vector face the model (under horizon).
  57697. */
  57698. useHorizonOcclusion: boolean;
  57699. /**
  57700. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  57701. * too much the area relying on ambient texture to define their ambient occlusion.
  57702. */
  57703. useRadianceOcclusion: boolean;
  57704. /**
  57705. * If set to true, no lighting calculations will be applied.
  57706. */
  57707. unlit: boolean;
  57708. /**
  57709. * Gets the image processing configuration used either in this material.
  57710. */
  57711. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  57712. /**
  57713. * Sets the Default image processing configuration used either in the this material.
  57714. *
  57715. * If sets to null, the scene one is in use.
  57716. */
  57717. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  57718. /**
  57719. * Gets wether the color curves effect is enabled.
  57720. */
  57721. get cameraColorCurvesEnabled(): boolean;
  57722. /**
  57723. * Sets wether the color curves effect is enabled.
  57724. */
  57725. set cameraColorCurvesEnabled(value: boolean);
  57726. /**
  57727. * Gets wether the color grading effect is enabled.
  57728. */
  57729. get cameraColorGradingEnabled(): boolean;
  57730. /**
  57731. * Gets wether the color grading effect is enabled.
  57732. */
  57733. set cameraColorGradingEnabled(value: boolean);
  57734. /**
  57735. * Gets wether tonemapping is enabled or not.
  57736. */
  57737. get cameraToneMappingEnabled(): boolean;
  57738. /**
  57739. * Sets wether tonemapping is enabled or not
  57740. */
  57741. set cameraToneMappingEnabled(value: boolean);
  57742. /**
  57743. * The camera exposure used on this material.
  57744. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57745. * This corresponds to a photographic exposure.
  57746. */
  57747. get cameraExposure(): number;
  57748. /**
  57749. * The camera exposure used on this material.
  57750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57751. * This corresponds to a photographic exposure.
  57752. */
  57753. set cameraExposure(value: number);
  57754. /**
  57755. * Gets The camera contrast used on this material.
  57756. */
  57757. get cameraContrast(): number;
  57758. /**
  57759. * Sets The camera contrast used on this material.
  57760. */
  57761. set cameraContrast(value: number);
  57762. /**
  57763. * Gets the Color Grading 2D Lookup Texture.
  57764. */
  57765. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57766. /**
  57767. * Sets the Color Grading 2D Lookup Texture.
  57768. */
  57769. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57770. /**
  57771. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57772. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57773. * 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;
  57774. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57775. */
  57776. get cameraColorCurves(): Nullable<ColorCurves>;
  57777. /**
  57778. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57779. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57780. * 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;
  57781. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57782. */
  57783. set cameraColorCurves(value: Nullable<ColorCurves>);
  57784. /**
  57785. * Instantiates a new PBRMaterial instance.
  57786. *
  57787. * @param name The material name
  57788. * @param scene The scene the material will be use in.
  57789. */
  57790. constructor(name: string, scene: Scene);
  57791. /**
  57792. * Returns the name of this material class.
  57793. */
  57794. getClassName(): string;
  57795. /**
  57796. * Makes a duplicate of the current material.
  57797. * @param name - name to use for the new material.
  57798. */
  57799. clone(name: string): PBRMaterial;
  57800. /**
  57801. * Serializes this PBR Material.
  57802. * @returns - An object with the serialized material.
  57803. */
  57804. serialize(): any;
  57805. /**
  57806. * Parses a PBR Material from a serialized object.
  57807. * @param source - Serialized object.
  57808. * @param scene - BJS scene instance.
  57809. * @param rootUrl - url for the scene object
  57810. * @returns - PBRMaterial
  57811. */
  57812. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  57813. }
  57814. }
  57815. declare module BABYLON {
  57816. /**
  57817. * Direct draw surface info
  57818. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  57819. */
  57820. export interface DDSInfo {
  57821. /**
  57822. * Width of the texture
  57823. */
  57824. width: number;
  57825. /**
  57826. * Width of the texture
  57827. */
  57828. height: number;
  57829. /**
  57830. * Number of Mipmaps for the texture
  57831. * @see https://en.wikipedia.org/wiki/Mipmap
  57832. */
  57833. mipmapCount: number;
  57834. /**
  57835. * If the textures format is a known fourCC format
  57836. * @see https://www.fourcc.org/
  57837. */
  57838. isFourCC: boolean;
  57839. /**
  57840. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  57841. */
  57842. isRGB: boolean;
  57843. /**
  57844. * If the texture is a lumincance format
  57845. */
  57846. isLuminance: boolean;
  57847. /**
  57848. * If this is a cube texture
  57849. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  57850. */
  57851. isCube: boolean;
  57852. /**
  57853. * If the texture is a compressed format eg. FOURCC_DXT1
  57854. */
  57855. isCompressed: boolean;
  57856. /**
  57857. * The dxgiFormat of the texture
  57858. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  57859. */
  57860. dxgiFormat: number;
  57861. /**
  57862. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  57863. */
  57864. textureType: number;
  57865. /**
  57866. * Sphericle polynomial created for the dds texture
  57867. */
  57868. sphericalPolynomial?: SphericalPolynomial;
  57869. }
  57870. /**
  57871. * Class used to provide DDS decompression tools
  57872. */
  57873. export class DDSTools {
  57874. /**
  57875. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  57876. */
  57877. static StoreLODInAlphaChannel: boolean;
  57878. /**
  57879. * Gets DDS information from an array buffer
  57880. * @param data defines the array buffer view to read data from
  57881. * @returns the DDS information
  57882. */
  57883. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  57884. private static _FloatView;
  57885. private static _Int32View;
  57886. private static _ToHalfFloat;
  57887. private static _FromHalfFloat;
  57888. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  57889. private static _GetHalfFloatRGBAArrayBuffer;
  57890. private static _GetFloatRGBAArrayBuffer;
  57891. private static _GetFloatAsUIntRGBAArrayBuffer;
  57892. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  57893. private static _GetRGBAArrayBuffer;
  57894. private static _ExtractLongWordOrder;
  57895. private static _GetRGBArrayBuffer;
  57896. private static _GetLuminanceArrayBuffer;
  57897. /**
  57898. * Uploads DDS Levels to a Babylon Texture
  57899. * @hidden
  57900. */
  57901. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  57902. }
  57903. interface ThinEngine {
  57904. /**
  57905. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  57906. * @param rootUrl defines the url where the file to load is located
  57907. * @param scene defines the current scene
  57908. * @param lodScale defines scale to apply to the mip map selection
  57909. * @param lodOffset defines offset to apply to the mip map selection
  57910. * @param onLoad defines an optional callback raised when the texture is loaded
  57911. * @param onError defines an optional callback raised if there is an issue to load the texture
  57912. * @param format defines the format of the data
  57913. * @param forcedExtension defines the extension to use to pick the right loader
  57914. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  57915. * @returns the cube texture as an InternalTexture
  57916. */
  57917. 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;
  57918. }
  57919. }
  57920. declare module BABYLON {
  57921. /**
  57922. * Implementation of the DDS Texture Loader.
  57923. * @hidden
  57924. */
  57925. export class _DDSTextureLoader implements IInternalTextureLoader {
  57926. /**
  57927. * Defines wether the loader supports cascade loading the different faces.
  57928. */
  57929. readonly supportCascades: boolean;
  57930. /**
  57931. * This returns if the loader support the current file information.
  57932. * @param extension defines the file extension of the file being loaded
  57933. * @returns true if the loader can load the specified file
  57934. */
  57935. canLoad(extension: string): boolean;
  57936. /**
  57937. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57938. * @param data contains the texture data
  57939. * @param texture defines the BabylonJS internal texture
  57940. * @param createPolynomials will be true if polynomials have been requested
  57941. * @param onLoad defines the callback to trigger once the texture is ready
  57942. * @param onError defines the callback to trigger in case of error
  57943. */
  57944. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57945. /**
  57946. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57947. * @param data contains the texture data
  57948. * @param texture defines the BabylonJS internal texture
  57949. * @param callback defines the method to call once ready to upload
  57950. */
  57951. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57952. }
  57953. }
  57954. declare module BABYLON {
  57955. /**
  57956. * Implementation of the ENV Texture Loader.
  57957. * @hidden
  57958. */
  57959. export class _ENVTextureLoader implements IInternalTextureLoader {
  57960. /**
  57961. * Defines wether the loader supports cascade loading the different faces.
  57962. */
  57963. readonly supportCascades: boolean;
  57964. /**
  57965. * This returns if the loader support the current file information.
  57966. * @param extension defines the file extension of the file being loaded
  57967. * @returns true if the loader can load the specified file
  57968. */
  57969. canLoad(extension: string): boolean;
  57970. /**
  57971. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  57972. * @param data contains the texture data
  57973. * @param texture defines the BabylonJS internal texture
  57974. * @param createPolynomials will be true if polynomials have been requested
  57975. * @param onLoad defines the callback to trigger once the texture is ready
  57976. * @param onError defines the callback to trigger in case of error
  57977. */
  57978. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  57979. /**
  57980. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  57981. * @param data contains the texture data
  57982. * @param texture defines the BabylonJS internal texture
  57983. * @param callback defines the method to call once ready to upload
  57984. */
  57985. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  57986. }
  57987. }
  57988. declare module BABYLON {
  57989. /**
  57990. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  57991. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  57992. */
  57993. export class KhronosTextureContainer {
  57994. /** contents of the KTX container file */
  57995. data: ArrayBufferView;
  57996. private static HEADER_LEN;
  57997. private static COMPRESSED_2D;
  57998. private static COMPRESSED_3D;
  57999. private static TEX_2D;
  58000. private static TEX_3D;
  58001. /**
  58002. * Gets the openGL type
  58003. */
  58004. glType: number;
  58005. /**
  58006. * Gets the openGL type size
  58007. */
  58008. glTypeSize: number;
  58009. /**
  58010. * Gets the openGL format
  58011. */
  58012. glFormat: number;
  58013. /**
  58014. * Gets the openGL internal format
  58015. */
  58016. glInternalFormat: number;
  58017. /**
  58018. * Gets the base internal format
  58019. */
  58020. glBaseInternalFormat: number;
  58021. /**
  58022. * Gets image width in pixel
  58023. */
  58024. pixelWidth: number;
  58025. /**
  58026. * Gets image height in pixel
  58027. */
  58028. pixelHeight: number;
  58029. /**
  58030. * Gets image depth in pixels
  58031. */
  58032. pixelDepth: number;
  58033. /**
  58034. * Gets the number of array elements
  58035. */
  58036. numberOfArrayElements: number;
  58037. /**
  58038. * Gets the number of faces
  58039. */
  58040. numberOfFaces: number;
  58041. /**
  58042. * Gets the number of mipmap levels
  58043. */
  58044. numberOfMipmapLevels: number;
  58045. /**
  58046. * Gets the bytes of key value data
  58047. */
  58048. bytesOfKeyValueData: number;
  58049. /**
  58050. * Gets the load type
  58051. */
  58052. loadType: number;
  58053. /**
  58054. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58055. */
  58056. isInvalid: boolean;
  58057. /**
  58058. * Creates a new KhronosTextureContainer
  58059. * @param data contents of the KTX container file
  58060. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58061. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58062. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58063. */
  58064. constructor(
  58065. /** contents of the KTX container file */
  58066. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58067. /**
  58068. * Uploads KTX content to a Babylon Texture.
  58069. * It is assumed that the texture has already been created & is currently bound
  58070. * @hidden
  58071. */
  58072. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58073. private _upload2DCompressedLevels;
  58074. /**
  58075. * Checks if the given data starts with a KTX file identifier.
  58076. * @param data the data to check
  58077. * @returns true if the data is a KTX file or false otherwise
  58078. */
  58079. static IsValid(data: ArrayBufferView): boolean;
  58080. }
  58081. }
  58082. declare module BABYLON {
  58083. /**
  58084. * Helper class to push actions to a pool of workers.
  58085. */
  58086. export class WorkerPool implements IDisposable {
  58087. private _workerInfos;
  58088. private _pendingActions;
  58089. /**
  58090. * Constructor
  58091. * @param workers Array of workers to use for actions
  58092. */
  58093. constructor(workers: Array<Worker>);
  58094. /**
  58095. * Terminates all workers and clears any pending actions.
  58096. */
  58097. dispose(): void;
  58098. /**
  58099. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58100. * pended until a worker has completed its action.
  58101. * @param action The action to perform. Call onComplete when the action is complete.
  58102. */
  58103. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58104. private _execute;
  58105. }
  58106. }
  58107. declare module BABYLON {
  58108. /**
  58109. * Class for loading KTX2 files
  58110. */
  58111. export class KhronosTextureContainer2 {
  58112. private static _WorkerPoolPromise?;
  58113. private static _Initialized;
  58114. private static _Ktx2Decoder;
  58115. /**
  58116. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58117. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58118. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58119. * Urls you can change:
  58120. * URLConfig.jsDecoderModule
  58121. * URLConfig.wasmUASTCToASTC
  58122. * URLConfig.wasmUASTCToBC7
  58123. * URLConfig.jsMSCTranscoder
  58124. * URLConfig.wasmMSCTranscoder
  58125. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58126. */
  58127. static URLConfig: {
  58128. jsDecoderModule: string;
  58129. wasmUASTCToASTC: null;
  58130. wasmUASTCToBC7: null;
  58131. jsMSCTranscoder: null;
  58132. wasmMSCTranscoder: null;
  58133. };
  58134. /**
  58135. * Default number of workers used to handle data decoding
  58136. */
  58137. static DefaultNumWorkers: number;
  58138. private static GetDefaultNumWorkers;
  58139. private _engine;
  58140. private static _CreateWorkerPool;
  58141. /**
  58142. * Constructor
  58143. * @param engine The engine to use
  58144. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58145. */
  58146. constructor(engine: ThinEngine, numWorkers?: number);
  58147. /** @hidden */
  58148. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58149. /**
  58150. * Stop all async operations and release resources.
  58151. */
  58152. dispose(): void;
  58153. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58154. /**
  58155. * Checks if the given data starts with a KTX2 file identifier.
  58156. * @param data the data to check
  58157. * @returns true if the data is a KTX2 file or false otherwise
  58158. */
  58159. static IsValid(data: ArrayBufferView): boolean;
  58160. }
  58161. }
  58162. declare module BABYLON {
  58163. /**
  58164. * Implementation of the KTX Texture Loader.
  58165. * @hidden
  58166. */
  58167. export class _KTXTextureLoader implements IInternalTextureLoader {
  58168. /**
  58169. * Defines wether the loader supports cascade loading the different faces.
  58170. */
  58171. readonly supportCascades: boolean;
  58172. /**
  58173. * This returns if the loader support the current file information.
  58174. * @param extension defines the file extension of the file being loaded
  58175. * @param mimeType defines the optional mime type of the file being loaded
  58176. * @returns true if the loader can load the specified file
  58177. */
  58178. canLoad(extension: string, mimeType?: string): boolean;
  58179. /**
  58180. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58181. * @param data contains the texture data
  58182. * @param texture defines the BabylonJS internal texture
  58183. * @param createPolynomials will be true if polynomials have been requested
  58184. * @param onLoad defines the callback to trigger once the texture is ready
  58185. * @param onError defines the callback to trigger in case of error
  58186. */
  58187. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58188. /**
  58189. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58190. * @param data contains the texture data
  58191. * @param texture defines the BabylonJS internal texture
  58192. * @param callback defines the method to call once ready to upload
  58193. */
  58194. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58195. }
  58196. }
  58197. declare module BABYLON {
  58198. /** @hidden */
  58199. export var _forceSceneHelpersToBundle: boolean;
  58200. interface Scene {
  58201. /**
  58202. * Creates a default light for the scene.
  58203. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58204. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58205. */
  58206. createDefaultLight(replace?: boolean): void;
  58207. /**
  58208. * Creates a default camera for the scene.
  58209. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58210. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58211. * @param replace has default false, when true replaces the active camera in the scene
  58212. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58213. */
  58214. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58215. /**
  58216. * Creates a default camera and a default light.
  58217. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58218. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58219. * @param replace has the default false, when true replaces the active camera/light in the scene
  58220. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58221. */
  58222. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58223. /**
  58224. * Creates a new sky box
  58225. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58226. * @param environmentTexture defines the texture to use as environment texture
  58227. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58228. * @param scale defines the overall scale of the skybox
  58229. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58230. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58231. * @returns a new mesh holding the sky box
  58232. */
  58233. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58234. /**
  58235. * Creates a new environment
  58236. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58237. * @param options defines the options you can use to configure the environment
  58238. * @returns the new EnvironmentHelper
  58239. */
  58240. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58241. /**
  58242. * Creates a new VREXperienceHelper
  58243. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58244. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58245. * @returns a new VREXperienceHelper
  58246. */
  58247. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58248. /**
  58249. * Creates a new WebXRDefaultExperience
  58250. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58251. * @param options experience options
  58252. * @returns a promise for a new WebXRDefaultExperience
  58253. */
  58254. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58255. }
  58256. }
  58257. declare module BABYLON {
  58258. /**
  58259. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58260. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58261. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58262. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58263. */
  58264. export class VideoDome extends TextureDome<VideoTexture> {
  58265. /**
  58266. * Define the video source as a Monoscopic panoramic 360 video.
  58267. */
  58268. static readonly MODE_MONOSCOPIC: number;
  58269. /**
  58270. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58271. */
  58272. static readonly MODE_TOPBOTTOM: number;
  58273. /**
  58274. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58275. */
  58276. static readonly MODE_SIDEBYSIDE: number;
  58277. /**
  58278. * Get the video texture associated with this video dome
  58279. */
  58280. get videoTexture(): VideoTexture;
  58281. /**
  58282. * Get the video mode of this dome
  58283. */
  58284. get videoMode(): number;
  58285. /**
  58286. * Set the video mode of this dome.
  58287. * @see textureMode
  58288. */
  58289. set videoMode(value: number);
  58290. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58291. }
  58292. }
  58293. declare module BABYLON {
  58294. /**
  58295. * This class can be used to get instrumentation data from a Babylon engine
  58296. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58297. */
  58298. export class EngineInstrumentation implements IDisposable {
  58299. /**
  58300. * Define the instrumented engine.
  58301. */
  58302. engine: Engine;
  58303. private _captureGPUFrameTime;
  58304. private _gpuFrameTimeToken;
  58305. private _gpuFrameTime;
  58306. private _captureShaderCompilationTime;
  58307. private _shaderCompilationTime;
  58308. private _onBeginFrameObserver;
  58309. private _onEndFrameObserver;
  58310. private _onBeforeShaderCompilationObserver;
  58311. private _onAfterShaderCompilationObserver;
  58312. /**
  58313. * Gets the perf counter used for GPU frame time
  58314. */
  58315. get gpuFrameTimeCounter(): PerfCounter;
  58316. /**
  58317. * Gets the GPU frame time capture status
  58318. */
  58319. get captureGPUFrameTime(): boolean;
  58320. /**
  58321. * Enable or disable the GPU frame time capture
  58322. */
  58323. set captureGPUFrameTime(value: boolean);
  58324. /**
  58325. * Gets the perf counter used for shader compilation time
  58326. */
  58327. get shaderCompilationTimeCounter(): PerfCounter;
  58328. /**
  58329. * Gets the shader compilation time capture status
  58330. */
  58331. get captureShaderCompilationTime(): boolean;
  58332. /**
  58333. * Enable or disable the shader compilation time capture
  58334. */
  58335. set captureShaderCompilationTime(value: boolean);
  58336. /**
  58337. * Instantiates a new engine instrumentation.
  58338. * This class can be used to get instrumentation data from a Babylon engine
  58339. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58340. * @param engine Defines the engine to instrument
  58341. */
  58342. constructor(
  58343. /**
  58344. * Define the instrumented engine.
  58345. */
  58346. engine: Engine);
  58347. /**
  58348. * Dispose and release associated resources.
  58349. */
  58350. dispose(): void;
  58351. }
  58352. }
  58353. declare module BABYLON {
  58354. /**
  58355. * This class can be used to get instrumentation data from a Babylon engine
  58356. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58357. */
  58358. export class SceneInstrumentation implements IDisposable {
  58359. /**
  58360. * Defines the scene to instrument
  58361. */
  58362. scene: Scene;
  58363. private _captureActiveMeshesEvaluationTime;
  58364. private _activeMeshesEvaluationTime;
  58365. private _captureRenderTargetsRenderTime;
  58366. private _renderTargetsRenderTime;
  58367. private _captureFrameTime;
  58368. private _frameTime;
  58369. private _captureRenderTime;
  58370. private _renderTime;
  58371. private _captureInterFrameTime;
  58372. private _interFrameTime;
  58373. private _captureParticlesRenderTime;
  58374. private _particlesRenderTime;
  58375. private _captureSpritesRenderTime;
  58376. private _spritesRenderTime;
  58377. private _capturePhysicsTime;
  58378. private _physicsTime;
  58379. private _captureAnimationsTime;
  58380. private _animationsTime;
  58381. private _captureCameraRenderTime;
  58382. private _cameraRenderTime;
  58383. private _onBeforeActiveMeshesEvaluationObserver;
  58384. private _onAfterActiveMeshesEvaluationObserver;
  58385. private _onBeforeRenderTargetsRenderObserver;
  58386. private _onAfterRenderTargetsRenderObserver;
  58387. private _onAfterRenderObserver;
  58388. private _onBeforeDrawPhaseObserver;
  58389. private _onAfterDrawPhaseObserver;
  58390. private _onBeforeAnimationsObserver;
  58391. private _onBeforeParticlesRenderingObserver;
  58392. private _onAfterParticlesRenderingObserver;
  58393. private _onBeforeSpritesRenderingObserver;
  58394. private _onAfterSpritesRenderingObserver;
  58395. private _onBeforePhysicsObserver;
  58396. private _onAfterPhysicsObserver;
  58397. private _onAfterAnimationsObserver;
  58398. private _onBeforeCameraRenderObserver;
  58399. private _onAfterCameraRenderObserver;
  58400. /**
  58401. * Gets the perf counter used for active meshes evaluation time
  58402. */
  58403. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58404. /**
  58405. * Gets the active meshes evaluation time capture status
  58406. */
  58407. get captureActiveMeshesEvaluationTime(): boolean;
  58408. /**
  58409. * Enable or disable the active meshes evaluation time capture
  58410. */
  58411. set captureActiveMeshesEvaluationTime(value: boolean);
  58412. /**
  58413. * Gets the perf counter used for render targets render time
  58414. */
  58415. get renderTargetsRenderTimeCounter(): PerfCounter;
  58416. /**
  58417. * Gets the render targets render time capture status
  58418. */
  58419. get captureRenderTargetsRenderTime(): boolean;
  58420. /**
  58421. * Enable or disable the render targets render time capture
  58422. */
  58423. set captureRenderTargetsRenderTime(value: boolean);
  58424. /**
  58425. * Gets the perf counter used for particles render time
  58426. */
  58427. get particlesRenderTimeCounter(): PerfCounter;
  58428. /**
  58429. * Gets the particles render time capture status
  58430. */
  58431. get captureParticlesRenderTime(): boolean;
  58432. /**
  58433. * Enable or disable the particles render time capture
  58434. */
  58435. set captureParticlesRenderTime(value: boolean);
  58436. /**
  58437. * Gets the perf counter used for sprites render time
  58438. */
  58439. get spritesRenderTimeCounter(): PerfCounter;
  58440. /**
  58441. * Gets the sprites render time capture status
  58442. */
  58443. get captureSpritesRenderTime(): boolean;
  58444. /**
  58445. * Enable or disable the sprites render time capture
  58446. */
  58447. set captureSpritesRenderTime(value: boolean);
  58448. /**
  58449. * Gets the perf counter used for physics time
  58450. */
  58451. get physicsTimeCounter(): PerfCounter;
  58452. /**
  58453. * Gets the physics time capture status
  58454. */
  58455. get capturePhysicsTime(): boolean;
  58456. /**
  58457. * Enable or disable the physics time capture
  58458. */
  58459. set capturePhysicsTime(value: boolean);
  58460. /**
  58461. * Gets the perf counter used for animations time
  58462. */
  58463. get animationsTimeCounter(): PerfCounter;
  58464. /**
  58465. * Gets the animations time capture status
  58466. */
  58467. get captureAnimationsTime(): boolean;
  58468. /**
  58469. * Enable or disable the animations time capture
  58470. */
  58471. set captureAnimationsTime(value: boolean);
  58472. /**
  58473. * Gets the perf counter used for frame time capture
  58474. */
  58475. get frameTimeCounter(): PerfCounter;
  58476. /**
  58477. * Gets the frame time capture status
  58478. */
  58479. get captureFrameTime(): boolean;
  58480. /**
  58481. * Enable or disable the frame time capture
  58482. */
  58483. set captureFrameTime(value: boolean);
  58484. /**
  58485. * Gets the perf counter used for inter-frames time capture
  58486. */
  58487. get interFrameTimeCounter(): PerfCounter;
  58488. /**
  58489. * Gets the inter-frames time capture status
  58490. */
  58491. get captureInterFrameTime(): boolean;
  58492. /**
  58493. * Enable or disable the inter-frames time capture
  58494. */
  58495. set captureInterFrameTime(value: boolean);
  58496. /**
  58497. * Gets the perf counter used for render time capture
  58498. */
  58499. get renderTimeCounter(): PerfCounter;
  58500. /**
  58501. * Gets the render time capture status
  58502. */
  58503. get captureRenderTime(): boolean;
  58504. /**
  58505. * Enable or disable the render time capture
  58506. */
  58507. set captureRenderTime(value: boolean);
  58508. /**
  58509. * Gets the perf counter used for camera render time capture
  58510. */
  58511. get cameraRenderTimeCounter(): PerfCounter;
  58512. /**
  58513. * Gets the camera render time capture status
  58514. */
  58515. get captureCameraRenderTime(): boolean;
  58516. /**
  58517. * Enable or disable the camera render time capture
  58518. */
  58519. set captureCameraRenderTime(value: boolean);
  58520. /**
  58521. * Gets the perf counter used for draw calls
  58522. */
  58523. get drawCallsCounter(): PerfCounter;
  58524. /**
  58525. * Instantiates a new scene instrumentation.
  58526. * This class can be used to get instrumentation data from a Babylon engine
  58527. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58528. * @param scene Defines the scene to instrument
  58529. */
  58530. constructor(
  58531. /**
  58532. * Defines the scene to instrument
  58533. */
  58534. scene: Scene);
  58535. /**
  58536. * Dispose and release associated resources.
  58537. */
  58538. dispose(): void;
  58539. }
  58540. }
  58541. declare module BABYLON {
  58542. /** @hidden */
  58543. export var glowMapGenerationPixelShader: {
  58544. name: string;
  58545. shader: string;
  58546. };
  58547. }
  58548. declare module BABYLON {
  58549. /** @hidden */
  58550. export var glowMapGenerationVertexShader: {
  58551. name: string;
  58552. shader: string;
  58553. };
  58554. }
  58555. declare module BABYLON {
  58556. /**
  58557. * Effect layer options. This helps customizing the behaviour
  58558. * of the effect layer.
  58559. */
  58560. export interface IEffectLayerOptions {
  58561. /**
  58562. * Multiplication factor apply to the canvas size to compute the render target size
  58563. * used to generated the objects (the smaller the faster).
  58564. */
  58565. mainTextureRatio: number;
  58566. /**
  58567. * Enforces a fixed size texture to ensure effect stability across devices.
  58568. */
  58569. mainTextureFixedSize?: number;
  58570. /**
  58571. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58572. */
  58573. alphaBlendingMode: number;
  58574. /**
  58575. * The camera attached to the layer.
  58576. */
  58577. camera: Nullable<Camera>;
  58578. /**
  58579. * The rendering group to draw the layer in.
  58580. */
  58581. renderingGroupId: number;
  58582. }
  58583. /**
  58584. * The effect layer Helps adding post process effect blended with the main pass.
  58585. *
  58586. * This can be for instance use to generate glow or higlight effects on the scene.
  58587. *
  58588. * The effect layer class can not be used directly and is intented to inherited from to be
  58589. * customized per effects.
  58590. */
  58591. export abstract class EffectLayer {
  58592. private _vertexBuffers;
  58593. private _indexBuffer;
  58594. private _cachedDefines;
  58595. private _effectLayerMapGenerationEffect;
  58596. private _effectLayerOptions;
  58597. private _mergeEffect;
  58598. protected _scene: Scene;
  58599. protected _engine: Engine;
  58600. protected _maxSize: number;
  58601. protected _mainTextureDesiredSize: ISize;
  58602. protected _mainTexture: RenderTargetTexture;
  58603. protected _shouldRender: boolean;
  58604. protected _postProcesses: PostProcess[];
  58605. protected _textures: BaseTexture[];
  58606. protected _emissiveTextureAndColor: {
  58607. texture: Nullable<BaseTexture>;
  58608. color: Color4;
  58609. };
  58610. /**
  58611. * The name of the layer
  58612. */
  58613. name: string;
  58614. /**
  58615. * The clear color of the texture used to generate the glow map.
  58616. */
  58617. neutralColor: Color4;
  58618. /**
  58619. * Specifies whether the highlight layer is enabled or not.
  58620. */
  58621. isEnabled: boolean;
  58622. /**
  58623. * Gets the camera attached to the layer.
  58624. */
  58625. get camera(): Nullable<Camera>;
  58626. /**
  58627. * Gets the rendering group id the layer should render in.
  58628. */
  58629. get renderingGroupId(): number;
  58630. set renderingGroupId(renderingGroupId: number);
  58631. /**
  58632. * An event triggered when the effect layer has been disposed.
  58633. */
  58634. onDisposeObservable: Observable<EffectLayer>;
  58635. /**
  58636. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58637. */
  58638. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58639. /**
  58640. * An event triggered when the generated texture is being merged in the scene.
  58641. */
  58642. onBeforeComposeObservable: Observable<EffectLayer>;
  58643. /**
  58644. * An event triggered when the mesh is rendered into the effect render target.
  58645. */
  58646. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58647. /**
  58648. * An event triggered after the mesh has been rendered into the effect render target.
  58649. */
  58650. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58651. /**
  58652. * An event triggered when the generated texture has been merged in the scene.
  58653. */
  58654. onAfterComposeObservable: Observable<EffectLayer>;
  58655. /**
  58656. * An event triggered when the efffect layer changes its size.
  58657. */
  58658. onSizeChangedObservable: Observable<EffectLayer>;
  58659. /** @hidden */
  58660. static _SceneComponentInitialization: (scene: Scene) => void;
  58661. /**
  58662. * Instantiates a new effect Layer and references it in the scene.
  58663. * @param name The name of the layer
  58664. * @param scene The scene to use the layer in
  58665. */
  58666. constructor(
  58667. /** The Friendly of the effect in the scene */
  58668. name: string, scene: Scene);
  58669. /**
  58670. * Get the effect name of the layer.
  58671. * @return The effect name
  58672. */
  58673. abstract getEffectName(): string;
  58674. /**
  58675. * Checks for the readiness of the element composing the layer.
  58676. * @param subMesh the mesh to check for
  58677. * @param useInstances specify whether or not to use instances to render the mesh
  58678. * @return true if ready otherwise, false
  58679. */
  58680. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58681. /**
  58682. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58683. * @returns true if the effect requires stencil during the main canvas render pass.
  58684. */
  58685. abstract needStencil(): boolean;
  58686. /**
  58687. * Create the merge effect. This is the shader use to blit the information back
  58688. * to the main canvas at the end of the scene rendering.
  58689. * @returns The effect containing the shader used to merge the effect on the main canvas
  58690. */
  58691. protected abstract _createMergeEffect(): Effect;
  58692. /**
  58693. * Creates the render target textures and post processes used in the effect layer.
  58694. */
  58695. protected abstract _createTextureAndPostProcesses(): void;
  58696. /**
  58697. * Implementation specific of rendering the generating effect on the main canvas.
  58698. * @param effect The effect used to render through
  58699. */
  58700. protected abstract _internalRender(effect: Effect): void;
  58701. /**
  58702. * Sets the required values for both the emissive texture and and the main color.
  58703. */
  58704. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  58705. /**
  58706. * Free any resources and references associated to a mesh.
  58707. * Internal use
  58708. * @param mesh The mesh to free.
  58709. */
  58710. abstract _disposeMesh(mesh: Mesh): void;
  58711. /**
  58712. * Serializes this layer (Glow or Highlight for example)
  58713. * @returns a serialized layer object
  58714. */
  58715. abstract serialize?(): any;
  58716. /**
  58717. * Initializes the effect layer with the required options.
  58718. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  58719. */
  58720. protected _init(options: Partial<IEffectLayerOptions>): void;
  58721. /**
  58722. * Generates the index buffer of the full screen quad blending to the main canvas.
  58723. */
  58724. private _generateIndexBuffer;
  58725. /**
  58726. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  58727. */
  58728. private _generateVertexBuffer;
  58729. /**
  58730. * Sets the main texture desired size which is the closest power of two
  58731. * of the engine canvas size.
  58732. */
  58733. private _setMainTextureSize;
  58734. /**
  58735. * Creates the main texture for the effect layer.
  58736. */
  58737. protected _createMainTexture(): void;
  58738. /**
  58739. * Adds specific effects defines.
  58740. * @param defines The defines to add specifics to.
  58741. */
  58742. protected _addCustomEffectDefines(defines: string[]): void;
  58743. /**
  58744. * Checks for the readiness of the element composing the layer.
  58745. * @param subMesh the mesh to check for
  58746. * @param useInstances specify whether or not to use instances to render the mesh
  58747. * @param emissiveTexture the associated emissive texture used to generate the glow
  58748. * @return true if ready otherwise, false
  58749. */
  58750. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  58751. /**
  58752. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  58753. */
  58754. render(): void;
  58755. /**
  58756. * Determine if a given mesh will be used in the current effect.
  58757. * @param mesh mesh to test
  58758. * @returns true if the mesh will be used
  58759. */
  58760. hasMesh(mesh: AbstractMesh): boolean;
  58761. /**
  58762. * Returns true if the layer contains information to display, otherwise false.
  58763. * @returns true if the glow layer should be rendered
  58764. */
  58765. shouldRender(): boolean;
  58766. /**
  58767. * Returns true if the mesh should render, otherwise false.
  58768. * @param mesh The mesh to render
  58769. * @returns true if it should render otherwise false
  58770. */
  58771. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  58772. /**
  58773. * Returns true if the mesh can be rendered, otherwise false.
  58774. * @param mesh The mesh to render
  58775. * @param material The material used on the mesh
  58776. * @returns true if it can be rendered otherwise false
  58777. */
  58778. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  58779. /**
  58780. * Returns true if the mesh should render, otherwise false.
  58781. * @param mesh The mesh to render
  58782. * @returns true if it should render otherwise false
  58783. */
  58784. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  58785. /**
  58786. * Renders the submesh passed in parameter to the generation map.
  58787. */
  58788. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  58789. /**
  58790. * Defines whether the current material of the mesh should be use to render the effect.
  58791. * @param mesh defines the current mesh to render
  58792. */
  58793. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  58794. /**
  58795. * Rebuild the required buffers.
  58796. * @hidden Internal use only.
  58797. */
  58798. _rebuild(): void;
  58799. /**
  58800. * Dispose only the render target textures and post process.
  58801. */
  58802. private _disposeTextureAndPostProcesses;
  58803. /**
  58804. * Dispose the highlight layer and free resources.
  58805. */
  58806. dispose(): void;
  58807. /**
  58808. * Gets the class name of the effect layer
  58809. * @returns the string with the class name of the effect layer
  58810. */
  58811. getClassName(): string;
  58812. /**
  58813. * Creates an effect layer from parsed effect layer data
  58814. * @param parsedEffectLayer defines effect layer data
  58815. * @param scene defines the current scene
  58816. * @param rootUrl defines the root URL containing the effect layer information
  58817. * @returns a parsed effect Layer
  58818. */
  58819. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  58820. }
  58821. }
  58822. declare module BABYLON {
  58823. interface AbstractScene {
  58824. /**
  58825. * The list of effect layers (highlights/glow) added to the scene
  58826. * @see https://doc.babylonjs.com/how_to/highlight_layer
  58827. * @see https://doc.babylonjs.com/how_to/glow_layer
  58828. */
  58829. effectLayers: Array<EffectLayer>;
  58830. /**
  58831. * Removes the given effect layer from this scene.
  58832. * @param toRemove defines the effect layer to remove
  58833. * @returns the index of the removed effect layer
  58834. */
  58835. removeEffectLayer(toRemove: EffectLayer): number;
  58836. /**
  58837. * Adds the given effect layer to this scene
  58838. * @param newEffectLayer defines the effect layer to add
  58839. */
  58840. addEffectLayer(newEffectLayer: EffectLayer): void;
  58841. }
  58842. /**
  58843. * Defines the layer scene component responsible to manage any effect layers
  58844. * in a given scene.
  58845. */
  58846. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  58847. /**
  58848. * The component name helpfull to identify the component in the list of scene components.
  58849. */
  58850. readonly name: string;
  58851. /**
  58852. * The scene the component belongs to.
  58853. */
  58854. scene: Scene;
  58855. private _engine;
  58856. private _renderEffects;
  58857. private _needStencil;
  58858. private _previousStencilState;
  58859. /**
  58860. * Creates a new instance of the component for the given scene
  58861. * @param scene Defines the scene to register the component in
  58862. */
  58863. constructor(scene: Scene);
  58864. /**
  58865. * Registers the component in a given scene
  58866. */
  58867. register(): void;
  58868. /**
  58869. * Rebuilds the elements related to this component in case of
  58870. * context lost for instance.
  58871. */
  58872. rebuild(): void;
  58873. /**
  58874. * Serializes the component data to the specified json object
  58875. * @param serializationObject The object to serialize to
  58876. */
  58877. serialize(serializationObject: any): void;
  58878. /**
  58879. * Adds all the elements from the container to the scene
  58880. * @param container the container holding the elements
  58881. */
  58882. addFromContainer(container: AbstractScene): void;
  58883. /**
  58884. * Removes all the elements in the container from the scene
  58885. * @param container contains the elements to remove
  58886. * @param dispose if the removed element should be disposed (default: false)
  58887. */
  58888. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  58889. /**
  58890. * Disposes the component and the associated ressources.
  58891. */
  58892. dispose(): void;
  58893. private _isReadyForMesh;
  58894. private _renderMainTexture;
  58895. private _setStencil;
  58896. private _setStencilBack;
  58897. private _draw;
  58898. private _drawCamera;
  58899. private _drawRenderingGroup;
  58900. }
  58901. }
  58902. declare module BABYLON {
  58903. /** @hidden */
  58904. export var glowMapMergePixelShader: {
  58905. name: string;
  58906. shader: string;
  58907. };
  58908. }
  58909. declare module BABYLON {
  58910. /** @hidden */
  58911. export var glowMapMergeVertexShader: {
  58912. name: string;
  58913. shader: string;
  58914. };
  58915. }
  58916. declare module BABYLON {
  58917. interface AbstractScene {
  58918. /**
  58919. * Return a the first highlight layer of the scene with a given name.
  58920. * @param name The name of the highlight layer to look for.
  58921. * @return The highlight layer if found otherwise null.
  58922. */
  58923. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  58924. }
  58925. /**
  58926. * Glow layer options. This helps customizing the behaviour
  58927. * of the glow layer.
  58928. */
  58929. export interface IGlowLayerOptions {
  58930. /**
  58931. * Multiplication factor apply to the canvas size to compute the render target size
  58932. * used to generated the glowing objects (the smaller the faster).
  58933. */
  58934. mainTextureRatio: number;
  58935. /**
  58936. * Enforces a fixed size texture to ensure resize independant blur.
  58937. */
  58938. mainTextureFixedSize?: number;
  58939. /**
  58940. * How big is the kernel of the blur texture.
  58941. */
  58942. blurKernelSize: number;
  58943. /**
  58944. * The camera attached to the layer.
  58945. */
  58946. camera: Nullable<Camera>;
  58947. /**
  58948. * Enable MSAA by chosing the number of samples.
  58949. */
  58950. mainTextureSamples?: number;
  58951. /**
  58952. * The rendering group to draw the layer in.
  58953. */
  58954. renderingGroupId: number;
  58955. }
  58956. /**
  58957. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  58958. *
  58959. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  58960. *
  58961. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  58962. */
  58963. export class GlowLayer extends EffectLayer {
  58964. /**
  58965. * Effect Name of the layer.
  58966. */
  58967. static readonly EffectName: string;
  58968. /**
  58969. * The default blur kernel size used for the glow.
  58970. */
  58971. static DefaultBlurKernelSize: number;
  58972. /**
  58973. * The default texture size ratio used for the glow.
  58974. */
  58975. static DefaultTextureRatio: number;
  58976. /**
  58977. * Sets the kernel size of the blur.
  58978. */
  58979. set blurKernelSize(value: number);
  58980. /**
  58981. * Gets the kernel size of the blur.
  58982. */
  58983. get blurKernelSize(): number;
  58984. /**
  58985. * Sets the glow intensity.
  58986. */
  58987. set intensity(value: number);
  58988. /**
  58989. * Gets the glow intensity.
  58990. */
  58991. get intensity(): number;
  58992. private _options;
  58993. private _intensity;
  58994. private _horizontalBlurPostprocess1;
  58995. private _verticalBlurPostprocess1;
  58996. private _horizontalBlurPostprocess2;
  58997. private _verticalBlurPostprocess2;
  58998. private _blurTexture1;
  58999. private _blurTexture2;
  59000. private _postProcesses1;
  59001. private _postProcesses2;
  59002. private _includedOnlyMeshes;
  59003. private _excludedMeshes;
  59004. private _meshesUsingTheirOwnMaterials;
  59005. /**
  59006. * Callback used to let the user override the color selection on a per mesh basis
  59007. */
  59008. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59009. /**
  59010. * Callback used to let the user override the texture selection on a per mesh basis
  59011. */
  59012. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59013. /**
  59014. * Instantiates a new glow Layer and references it to the scene.
  59015. * @param name The name of the layer
  59016. * @param scene The scene to use the layer in
  59017. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59018. */
  59019. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59020. /**
  59021. * Get the effect name of the layer.
  59022. * @return The effect name
  59023. */
  59024. getEffectName(): string;
  59025. /**
  59026. * Create the merge effect. This is the shader use to blit the information back
  59027. * to the main canvas at the end of the scene rendering.
  59028. */
  59029. protected _createMergeEffect(): Effect;
  59030. /**
  59031. * Creates the render target textures and post processes used in the glow layer.
  59032. */
  59033. protected _createTextureAndPostProcesses(): void;
  59034. /**
  59035. * Checks for the readiness of the element composing the layer.
  59036. * @param subMesh the mesh to check for
  59037. * @param useInstances specify wether or not to use instances to render the mesh
  59038. * @param emissiveTexture the associated emissive texture used to generate the glow
  59039. * @return true if ready otherwise, false
  59040. */
  59041. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59042. /**
  59043. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59044. */
  59045. needStencil(): boolean;
  59046. /**
  59047. * Returns true if the mesh can be rendered, otherwise false.
  59048. * @param mesh The mesh to render
  59049. * @param material The material used on the mesh
  59050. * @returns true if it can be rendered otherwise false
  59051. */
  59052. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59053. /**
  59054. * Implementation specific of rendering the generating effect on the main canvas.
  59055. * @param effect The effect used to render through
  59056. */
  59057. protected _internalRender(effect: Effect): void;
  59058. /**
  59059. * Sets the required values for both the emissive texture and and the main color.
  59060. */
  59061. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59062. /**
  59063. * Returns true if the mesh should render, otherwise false.
  59064. * @param mesh The mesh to render
  59065. * @returns true if it should render otherwise false
  59066. */
  59067. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59068. /**
  59069. * Adds specific effects defines.
  59070. * @param defines The defines to add specifics to.
  59071. */
  59072. protected _addCustomEffectDefines(defines: string[]): void;
  59073. /**
  59074. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59075. * @param mesh The mesh to exclude from the glow layer
  59076. */
  59077. addExcludedMesh(mesh: Mesh): void;
  59078. /**
  59079. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59080. * @param mesh The mesh to remove
  59081. */
  59082. removeExcludedMesh(mesh: Mesh): void;
  59083. /**
  59084. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59085. * @param mesh The mesh to include in the glow layer
  59086. */
  59087. addIncludedOnlyMesh(mesh: Mesh): void;
  59088. /**
  59089. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59090. * @param mesh The mesh to remove
  59091. */
  59092. removeIncludedOnlyMesh(mesh: Mesh): void;
  59093. /**
  59094. * Determine if a given mesh will be used in the glow layer
  59095. * @param mesh The mesh to test
  59096. * @returns true if the mesh will be highlighted by the current glow layer
  59097. */
  59098. hasMesh(mesh: AbstractMesh): boolean;
  59099. /**
  59100. * Defines whether the current material of the mesh should be use to render the effect.
  59101. * @param mesh defines the current mesh to render
  59102. */
  59103. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59104. /**
  59105. * Add a mesh to be rendered through its own material and not with emissive only.
  59106. * @param mesh The mesh for which we need to use its material
  59107. */
  59108. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59109. /**
  59110. * Remove a mesh from being rendered through its own material and not with emissive only.
  59111. * @param mesh The mesh for which we need to not use its material
  59112. */
  59113. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59114. /**
  59115. * Free any resources and references associated to a mesh.
  59116. * Internal use
  59117. * @param mesh The mesh to free.
  59118. * @hidden
  59119. */
  59120. _disposeMesh(mesh: Mesh): void;
  59121. /**
  59122. * Gets the class name of the effect layer
  59123. * @returns the string with the class name of the effect layer
  59124. */
  59125. getClassName(): string;
  59126. /**
  59127. * Serializes this glow layer
  59128. * @returns a serialized glow layer object
  59129. */
  59130. serialize(): any;
  59131. /**
  59132. * Creates a Glow Layer from parsed glow layer data
  59133. * @param parsedGlowLayer defines glow layer data
  59134. * @param scene defines the current scene
  59135. * @param rootUrl defines the root URL containing the glow layer information
  59136. * @returns a parsed Glow Layer
  59137. */
  59138. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59139. }
  59140. }
  59141. declare module BABYLON {
  59142. /** @hidden */
  59143. export var glowBlurPostProcessPixelShader: {
  59144. name: string;
  59145. shader: string;
  59146. };
  59147. }
  59148. declare module BABYLON {
  59149. interface AbstractScene {
  59150. /**
  59151. * Return a the first highlight layer of the scene with a given name.
  59152. * @param name The name of the highlight layer to look for.
  59153. * @return The highlight layer if found otherwise null.
  59154. */
  59155. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59156. }
  59157. /**
  59158. * Highlight layer options. This helps customizing the behaviour
  59159. * of the highlight layer.
  59160. */
  59161. export interface IHighlightLayerOptions {
  59162. /**
  59163. * Multiplication factor apply to the canvas size to compute the render target size
  59164. * used to generated the glowing objects (the smaller the faster).
  59165. */
  59166. mainTextureRatio: number;
  59167. /**
  59168. * Enforces a fixed size texture to ensure resize independant blur.
  59169. */
  59170. mainTextureFixedSize?: number;
  59171. /**
  59172. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59173. * of the picture to blur (the smaller the faster).
  59174. */
  59175. blurTextureSizeRatio: number;
  59176. /**
  59177. * How big in texel of the blur texture is the vertical blur.
  59178. */
  59179. blurVerticalSize: number;
  59180. /**
  59181. * How big in texel of the blur texture is the horizontal blur.
  59182. */
  59183. blurHorizontalSize: number;
  59184. /**
  59185. * Alpha blending mode used to apply the blur. Default is combine.
  59186. */
  59187. alphaBlendingMode: number;
  59188. /**
  59189. * The camera attached to the layer.
  59190. */
  59191. camera: Nullable<Camera>;
  59192. /**
  59193. * Should we display highlight as a solid stroke?
  59194. */
  59195. isStroke?: boolean;
  59196. /**
  59197. * The rendering group to draw the layer in.
  59198. */
  59199. renderingGroupId: number;
  59200. }
  59201. /**
  59202. * The highlight layer Helps adding a glow effect around a mesh.
  59203. *
  59204. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59205. * glowy meshes to your scene.
  59206. *
  59207. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59208. */
  59209. export class HighlightLayer extends EffectLayer {
  59210. name: string;
  59211. /**
  59212. * Effect Name of the highlight layer.
  59213. */
  59214. static readonly EffectName: string;
  59215. /**
  59216. * The neutral color used during the preparation of the glow effect.
  59217. * This is black by default as the blend operation is a blend operation.
  59218. */
  59219. static NeutralColor: Color4;
  59220. /**
  59221. * Stencil value used for glowing meshes.
  59222. */
  59223. static GlowingMeshStencilReference: number;
  59224. /**
  59225. * Stencil value used for the other meshes in the scene.
  59226. */
  59227. static NormalMeshStencilReference: number;
  59228. /**
  59229. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59230. */
  59231. innerGlow: boolean;
  59232. /**
  59233. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59234. */
  59235. outerGlow: boolean;
  59236. /**
  59237. * Specifies the horizontal size of the blur.
  59238. */
  59239. set blurHorizontalSize(value: number);
  59240. /**
  59241. * Specifies the vertical size of the blur.
  59242. */
  59243. set blurVerticalSize(value: number);
  59244. /**
  59245. * Gets the horizontal size of the blur.
  59246. */
  59247. get blurHorizontalSize(): number;
  59248. /**
  59249. * Gets the vertical size of the blur.
  59250. */
  59251. get blurVerticalSize(): number;
  59252. /**
  59253. * An event triggered when the highlight layer is being blurred.
  59254. */
  59255. onBeforeBlurObservable: Observable<HighlightLayer>;
  59256. /**
  59257. * An event triggered when the highlight layer has been blurred.
  59258. */
  59259. onAfterBlurObservable: Observable<HighlightLayer>;
  59260. private _instanceGlowingMeshStencilReference;
  59261. private _options;
  59262. private _downSamplePostprocess;
  59263. private _horizontalBlurPostprocess;
  59264. private _verticalBlurPostprocess;
  59265. private _blurTexture;
  59266. private _meshes;
  59267. private _excludedMeshes;
  59268. /**
  59269. * Instantiates a new highlight Layer and references it to the scene..
  59270. * @param name The name of the layer
  59271. * @param scene The scene to use the layer in
  59272. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59273. */
  59274. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59275. /**
  59276. * Get the effect name of the layer.
  59277. * @return The effect name
  59278. */
  59279. getEffectName(): string;
  59280. /**
  59281. * Create the merge effect. This is the shader use to blit the information back
  59282. * to the main canvas at the end of the scene rendering.
  59283. */
  59284. protected _createMergeEffect(): Effect;
  59285. /**
  59286. * Creates the render target textures and post processes used in the highlight layer.
  59287. */
  59288. protected _createTextureAndPostProcesses(): void;
  59289. /**
  59290. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59291. */
  59292. needStencil(): boolean;
  59293. /**
  59294. * Checks for the readiness of the element composing the layer.
  59295. * @param subMesh the mesh to check for
  59296. * @param useInstances specify wether or not to use instances to render the mesh
  59297. * @param emissiveTexture the associated emissive texture used to generate the glow
  59298. * @return true if ready otherwise, false
  59299. */
  59300. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59301. /**
  59302. * Implementation specific of rendering the generating effect on the main canvas.
  59303. * @param effect The effect used to render through
  59304. */
  59305. protected _internalRender(effect: Effect): void;
  59306. /**
  59307. * Returns true if the layer contains information to display, otherwise false.
  59308. */
  59309. shouldRender(): boolean;
  59310. /**
  59311. * Returns true if the mesh should render, otherwise false.
  59312. * @param mesh The mesh to render
  59313. * @returns true if it should render otherwise false
  59314. */
  59315. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59316. /**
  59317. * Returns true if the mesh can be rendered, otherwise false.
  59318. * @param mesh The mesh to render
  59319. * @param material The material used on the mesh
  59320. * @returns true if it can be rendered otherwise false
  59321. */
  59322. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59323. /**
  59324. * Adds specific effects defines.
  59325. * @param defines The defines to add specifics to.
  59326. */
  59327. protected _addCustomEffectDefines(defines: string[]): void;
  59328. /**
  59329. * Sets the required values for both the emissive texture and and the main color.
  59330. */
  59331. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59332. /**
  59333. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59334. * @param mesh The mesh to exclude from the highlight layer
  59335. */
  59336. addExcludedMesh(mesh: Mesh): void;
  59337. /**
  59338. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59339. * @param mesh The mesh to highlight
  59340. */
  59341. removeExcludedMesh(mesh: Mesh): void;
  59342. /**
  59343. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59344. * @param mesh mesh to test
  59345. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59346. */
  59347. hasMesh(mesh: AbstractMesh): boolean;
  59348. /**
  59349. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59350. * @param mesh The mesh to highlight
  59351. * @param color The color of the highlight
  59352. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59353. */
  59354. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59355. /**
  59356. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59357. * @param mesh The mesh to highlight
  59358. */
  59359. removeMesh(mesh: Mesh): void;
  59360. /**
  59361. * Remove all the meshes currently referenced in the highlight layer
  59362. */
  59363. removeAllMeshes(): void;
  59364. /**
  59365. * Force the stencil to the normal expected value for none glowing parts
  59366. */
  59367. private _defaultStencilReference;
  59368. /**
  59369. * Free any resources and references associated to a mesh.
  59370. * Internal use
  59371. * @param mesh The mesh to free.
  59372. * @hidden
  59373. */
  59374. _disposeMesh(mesh: Mesh): void;
  59375. /**
  59376. * Dispose the highlight layer and free resources.
  59377. */
  59378. dispose(): void;
  59379. /**
  59380. * Gets the class name of the effect layer
  59381. * @returns the string with the class name of the effect layer
  59382. */
  59383. getClassName(): string;
  59384. /**
  59385. * Serializes this Highlight layer
  59386. * @returns a serialized Highlight layer object
  59387. */
  59388. serialize(): any;
  59389. /**
  59390. * Creates a Highlight layer from parsed Highlight layer data
  59391. * @param parsedHightlightLayer defines the Highlight layer data
  59392. * @param scene defines the current scene
  59393. * @param rootUrl defines the root URL containing the Highlight layer information
  59394. * @returns a parsed Highlight layer
  59395. */
  59396. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59397. }
  59398. }
  59399. declare module BABYLON {
  59400. interface AbstractScene {
  59401. /**
  59402. * The list of layers (background and foreground) of the scene
  59403. */
  59404. layers: Array<Layer>;
  59405. }
  59406. /**
  59407. * Defines the layer scene component responsible to manage any layers
  59408. * in a given scene.
  59409. */
  59410. export class LayerSceneComponent implements ISceneComponent {
  59411. /**
  59412. * The component name helpfull to identify the component in the list of scene components.
  59413. */
  59414. readonly name: string;
  59415. /**
  59416. * The scene the component belongs to.
  59417. */
  59418. scene: Scene;
  59419. private _engine;
  59420. /**
  59421. * Creates a new instance of the component for the given scene
  59422. * @param scene Defines the scene to register the component in
  59423. */
  59424. constructor(scene: Scene);
  59425. /**
  59426. * Registers the component in a given scene
  59427. */
  59428. register(): void;
  59429. /**
  59430. * Rebuilds the elements related to this component in case of
  59431. * context lost for instance.
  59432. */
  59433. rebuild(): void;
  59434. /**
  59435. * Disposes the component and the associated ressources.
  59436. */
  59437. dispose(): void;
  59438. private _draw;
  59439. private _drawCameraPredicate;
  59440. private _drawCameraBackground;
  59441. private _drawCameraForeground;
  59442. private _drawRenderTargetPredicate;
  59443. private _drawRenderTargetBackground;
  59444. private _drawRenderTargetForeground;
  59445. /**
  59446. * Adds all the elements from the container to the scene
  59447. * @param container the container holding the elements
  59448. */
  59449. addFromContainer(container: AbstractScene): void;
  59450. /**
  59451. * Removes all the elements in the container from the scene
  59452. * @param container contains the elements to remove
  59453. * @param dispose if the removed element should be disposed (default: false)
  59454. */
  59455. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59456. }
  59457. }
  59458. declare module BABYLON {
  59459. /** @hidden */
  59460. export var layerPixelShader: {
  59461. name: string;
  59462. shader: string;
  59463. };
  59464. }
  59465. declare module BABYLON {
  59466. /** @hidden */
  59467. export var layerVertexShader: {
  59468. name: string;
  59469. shader: string;
  59470. };
  59471. }
  59472. declare module BABYLON {
  59473. /**
  59474. * This represents a full screen 2d layer.
  59475. * This can be useful to display a picture in the background of your scene for instance.
  59476. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59477. */
  59478. export class Layer {
  59479. /**
  59480. * Define the name of the layer.
  59481. */
  59482. name: string;
  59483. /**
  59484. * Define the texture the layer should display.
  59485. */
  59486. texture: Nullable<Texture>;
  59487. /**
  59488. * Is the layer in background or foreground.
  59489. */
  59490. isBackground: boolean;
  59491. /**
  59492. * Define the color of the layer (instead of texture).
  59493. */
  59494. color: Color4;
  59495. /**
  59496. * Define the scale of the layer in order to zoom in out of the texture.
  59497. */
  59498. scale: Vector2;
  59499. /**
  59500. * Define an offset for the layer in order to shift the texture.
  59501. */
  59502. offset: Vector2;
  59503. /**
  59504. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59505. */
  59506. alphaBlendingMode: number;
  59507. /**
  59508. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59509. * Alpha test will not mix with the background color in case of transparency.
  59510. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59511. */
  59512. alphaTest: boolean;
  59513. /**
  59514. * Define a mask to restrict the layer to only some of the scene cameras.
  59515. */
  59516. layerMask: number;
  59517. /**
  59518. * Define the list of render target the layer is visible into.
  59519. */
  59520. renderTargetTextures: RenderTargetTexture[];
  59521. /**
  59522. * Define if the layer is only used in renderTarget or if it also
  59523. * renders in the main frame buffer of the canvas.
  59524. */
  59525. renderOnlyInRenderTargetTextures: boolean;
  59526. private _scene;
  59527. private _vertexBuffers;
  59528. private _indexBuffer;
  59529. private _effect;
  59530. private _previousDefines;
  59531. /**
  59532. * An event triggered when the layer is disposed.
  59533. */
  59534. onDisposeObservable: Observable<Layer>;
  59535. private _onDisposeObserver;
  59536. /**
  59537. * Back compatibility with callback before the onDisposeObservable existed.
  59538. * The set callback will be triggered when the layer has been disposed.
  59539. */
  59540. set onDispose(callback: () => void);
  59541. /**
  59542. * An event triggered before rendering the scene
  59543. */
  59544. onBeforeRenderObservable: Observable<Layer>;
  59545. private _onBeforeRenderObserver;
  59546. /**
  59547. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59548. * The set callback will be triggered just before rendering the layer.
  59549. */
  59550. set onBeforeRender(callback: () => void);
  59551. /**
  59552. * An event triggered after rendering the scene
  59553. */
  59554. onAfterRenderObservable: Observable<Layer>;
  59555. private _onAfterRenderObserver;
  59556. /**
  59557. * Back compatibility with callback before the onAfterRenderObservable existed.
  59558. * The set callback will be triggered just after rendering the layer.
  59559. */
  59560. set onAfterRender(callback: () => void);
  59561. /**
  59562. * Instantiates a new layer.
  59563. * This represents a full screen 2d layer.
  59564. * This can be useful to display a picture in the background of your scene for instance.
  59565. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59566. * @param name Define the name of the layer in the scene
  59567. * @param imgUrl Define the url of the texture to display in the layer
  59568. * @param scene Define the scene the layer belongs to
  59569. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59570. * @param color Defines a color for the layer
  59571. */
  59572. constructor(
  59573. /**
  59574. * Define the name of the layer.
  59575. */
  59576. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59577. private _createIndexBuffer;
  59578. /** @hidden */
  59579. _rebuild(): void;
  59580. /**
  59581. * Renders the layer in the scene.
  59582. */
  59583. render(): void;
  59584. /**
  59585. * Disposes and releases the associated ressources.
  59586. */
  59587. dispose(): void;
  59588. }
  59589. }
  59590. declare module BABYLON {
  59591. /** @hidden */
  59592. export var lensFlarePixelShader: {
  59593. name: string;
  59594. shader: string;
  59595. };
  59596. }
  59597. declare module BABYLON {
  59598. /** @hidden */
  59599. export var lensFlareVertexShader: {
  59600. name: string;
  59601. shader: string;
  59602. };
  59603. }
  59604. declare module BABYLON {
  59605. /**
  59606. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59607. * It is usually composed of several `lensFlare`.
  59608. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59609. */
  59610. export class LensFlareSystem {
  59611. /**
  59612. * Define the name of the lens flare system
  59613. */
  59614. name: string;
  59615. /**
  59616. * List of lens flares used in this system.
  59617. */
  59618. lensFlares: LensFlare[];
  59619. /**
  59620. * Define a limit from the border the lens flare can be visible.
  59621. */
  59622. borderLimit: number;
  59623. /**
  59624. * Define a viewport border we do not want to see the lens flare in.
  59625. */
  59626. viewportBorder: number;
  59627. /**
  59628. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59629. */
  59630. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59631. /**
  59632. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59633. */
  59634. layerMask: number;
  59635. /**
  59636. * Define the id of the lens flare system in the scene.
  59637. * (equal to name by default)
  59638. */
  59639. id: string;
  59640. private _scene;
  59641. private _emitter;
  59642. private _vertexBuffers;
  59643. private _indexBuffer;
  59644. private _effect;
  59645. private _positionX;
  59646. private _positionY;
  59647. private _isEnabled;
  59648. /** @hidden */
  59649. static _SceneComponentInitialization: (scene: Scene) => void;
  59650. /**
  59651. * Instantiates a lens flare system.
  59652. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59653. * It is usually composed of several `lensFlare`.
  59654. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59655. * @param name Define the name of the lens flare system in the scene
  59656. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59657. * @param scene Define the scene the lens flare system belongs to
  59658. */
  59659. constructor(
  59660. /**
  59661. * Define the name of the lens flare system
  59662. */
  59663. name: string, emitter: any, scene: Scene);
  59664. /**
  59665. * Define if the lens flare system is enabled.
  59666. */
  59667. get isEnabled(): boolean;
  59668. set isEnabled(value: boolean);
  59669. /**
  59670. * Get the scene the effects belongs to.
  59671. * @returns the scene holding the lens flare system
  59672. */
  59673. getScene(): Scene;
  59674. /**
  59675. * Get the emitter of the lens flare system.
  59676. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59677. * @returns the emitter of the lens flare system
  59678. */
  59679. getEmitter(): any;
  59680. /**
  59681. * Set the emitter of the lens flare system.
  59682. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59683. * @param newEmitter Define the new emitter of the system
  59684. */
  59685. setEmitter(newEmitter: any): void;
  59686. /**
  59687. * Get the lens flare system emitter position.
  59688. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59689. * @returns the position
  59690. */
  59691. getEmitterPosition(): Vector3;
  59692. /**
  59693. * @hidden
  59694. */
  59695. computeEffectivePosition(globalViewport: Viewport): boolean;
  59696. /** @hidden */
  59697. _isVisible(): boolean;
  59698. /**
  59699. * @hidden
  59700. */
  59701. render(): boolean;
  59702. /**
  59703. * Dispose and release the lens flare with its associated resources.
  59704. */
  59705. dispose(): void;
  59706. /**
  59707. * Parse a lens flare system from a JSON repressentation
  59708. * @param parsedLensFlareSystem Define the JSON to parse
  59709. * @param scene Define the scene the parsed system should be instantiated in
  59710. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  59711. * @returns the parsed system
  59712. */
  59713. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  59714. /**
  59715. * Serialize the current Lens Flare System into a JSON representation.
  59716. * @returns the serialized JSON
  59717. */
  59718. serialize(): any;
  59719. }
  59720. }
  59721. declare module BABYLON {
  59722. /**
  59723. * This represents one of the lens effect in a `lensFlareSystem`.
  59724. * It controls one of the indiviual texture used in the effect.
  59725. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59726. */
  59727. export class LensFlare {
  59728. /**
  59729. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59730. */
  59731. size: number;
  59732. /**
  59733. * 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.
  59734. */
  59735. position: number;
  59736. /**
  59737. * Define the lens color.
  59738. */
  59739. color: Color3;
  59740. /**
  59741. * Define the lens texture.
  59742. */
  59743. texture: Nullable<Texture>;
  59744. /**
  59745. * Define the alpha mode to render this particular lens.
  59746. */
  59747. alphaMode: number;
  59748. private _system;
  59749. /**
  59750. * Creates a new Lens Flare.
  59751. * This represents one of the lens effect in a `lensFlareSystem`.
  59752. * It controls one of the indiviual texture used in the effect.
  59753. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59754. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  59755. * @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.
  59756. * @param color Define the lens color
  59757. * @param imgUrl Define the lens texture url
  59758. * @param system Define the `lensFlareSystem` this flare is part of
  59759. * @returns The newly created Lens Flare
  59760. */
  59761. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  59762. /**
  59763. * Instantiates a new Lens Flare.
  59764. * This represents one of the lens effect in a `lensFlareSystem`.
  59765. * It controls one of the indiviual texture used in the effect.
  59766. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59767. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  59768. * @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.
  59769. * @param color Define the lens color
  59770. * @param imgUrl Define the lens texture url
  59771. * @param system Define the `lensFlareSystem` this flare is part of
  59772. */
  59773. constructor(
  59774. /**
  59775. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  59776. */
  59777. size: number,
  59778. /**
  59779. * 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.
  59780. */
  59781. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  59782. /**
  59783. * Dispose and release the lens flare with its associated resources.
  59784. */
  59785. dispose(): void;
  59786. }
  59787. }
  59788. declare module BABYLON {
  59789. interface AbstractScene {
  59790. /**
  59791. * The list of lens flare system added to the scene
  59792. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59793. */
  59794. lensFlareSystems: Array<LensFlareSystem>;
  59795. /**
  59796. * Removes the given lens flare system from this scene.
  59797. * @param toRemove The lens flare system to remove
  59798. * @returns The index of the removed lens flare system
  59799. */
  59800. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  59801. /**
  59802. * Adds the given lens flare system to this scene
  59803. * @param newLensFlareSystem The lens flare system to add
  59804. */
  59805. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  59806. /**
  59807. * Gets a lens flare system using its name
  59808. * @param name defines the name to look for
  59809. * @returns the lens flare system or null if not found
  59810. */
  59811. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  59812. /**
  59813. * Gets a lens flare system using its id
  59814. * @param id defines the id to look for
  59815. * @returns the lens flare system or null if not found
  59816. */
  59817. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  59818. }
  59819. /**
  59820. * Defines the lens flare scene component responsible to manage any lens flares
  59821. * in a given scene.
  59822. */
  59823. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  59824. /**
  59825. * The component name helpfull to identify the component in the list of scene components.
  59826. */
  59827. readonly name: string;
  59828. /**
  59829. * The scene the component belongs to.
  59830. */
  59831. scene: Scene;
  59832. /**
  59833. * Creates a new instance of the component for the given scene
  59834. * @param scene Defines the scene to register the component in
  59835. */
  59836. constructor(scene: Scene);
  59837. /**
  59838. * Registers the component in a given scene
  59839. */
  59840. register(): void;
  59841. /**
  59842. * Rebuilds the elements related to this component in case of
  59843. * context lost for instance.
  59844. */
  59845. rebuild(): void;
  59846. /**
  59847. * Adds all the elements from the container to the scene
  59848. * @param container the container holding the elements
  59849. */
  59850. addFromContainer(container: AbstractScene): void;
  59851. /**
  59852. * Removes all the elements in the container from the scene
  59853. * @param container contains the elements to remove
  59854. * @param dispose if the removed element should be disposed (default: false)
  59855. */
  59856. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59857. /**
  59858. * Serializes the component data to the specified json object
  59859. * @param serializationObject The object to serialize to
  59860. */
  59861. serialize(serializationObject: any): void;
  59862. /**
  59863. * Disposes the component and the associated ressources.
  59864. */
  59865. dispose(): void;
  59866. private _draw;
  59867. }
  59868. }
  59869. declare module BABYLON {
  59870. /** @hidden */
  59871. export var depthPixelShader: {
  59872. name: string;
  59873. shader: string;
  59874. };
  59875. }
  59876. declare module BABYLON {
  59877. /** @hidden */
  59878. export var depthVertexShader: {
  59879. name: string;
  59880. shader: string;
  59881. };
  59882. }
  59883. declare module BABYLON {
  59884. /**
  59885. * This represents a depth renderer in Babylon.
  59886. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59887. */
  59888. export class DepthRenderer {
  59889. private _scene;
  59890. private _depthMap;
  59891. private _effect;
  59892. private readonly _storeNonLinearDepth;
  59893. private readonly _clearColor;
  59894. /** Get if the depth renderer is using packed depth or not */
  59895. readonly isPacked: boolean;
  59896. private _cachedDefines;
  59897. private _camera;
  59898. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  59899. enabled: boolean;
  59900. /**
  59901. * Specifiess that the depth renderer will only be used within
  59902. * the camera it is created for.
  59903. * This can help forcing its rendering during the camera processing.
  59904. */
  59905. useOnlyInActiveCamera: boolean;
  59906. /** @hidden */
  59907. static _SceneComponentInitialization: (scene: Scene) => void;
  59908. /**
  59909. * Instantiates a depth renderer
  59910. * @param scene The scene the renderer belongs to
  59911. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59912. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59913. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  59914. */
  59915. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  59916. /**
  59917. * Creates the depth rendering effect and checks if the effect is ready.
  59918. * @param subMesh The submesh to be used to render the depth map of
  59919. * @param useInstances If multiple world instances should be used
  59920. * @returns if the depth renderer is ready to render the depth map
  59921. */
  59922. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59923. /**
  59924. * Gets the texture which the depth map will be written to.
  59925. * @returns The depth map texture
  59926. */
  59927. getDepthMap(): RenderTargetTexture;
  59928. /**
  59929. * Disposes of the depth renderer.
  59930. */
  59931. dispose(): void;
  59932. }
  59933. }
  59934. declare module BABYLON {
  59935. /** @hidden */
  59936. export var minmaxReduxPixelShader: {
  59937. name: string;
  59938. shader: string;
  59939. };
  59940. }
  59941. declare module BABYLON {
  59942. /**
  59943. * This class computes a min/max reduction from a texture: it means it computes the minimum
  59944. * and maximum values from all values of the texture.
  59945. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  59946. * The source values are read from the red channel of the texture.
  59947. */
  59948. export class MinMaxReducer {
  59949. /**
  59950. * Observable triggered when the computation has been performed
  59951. */
  59952. onAfterReductionPerformed: Observable<{
  59953. min: number;
  59954. max: number;
  59955. }>;
  59956. protected _camera: Camera;
  59957. protected _sourceTexture: Nullable<RenderTargetTexture>;
  59958. protected _reductionSteps: Nullable<Array<PostProcess>>;
  59959. protected _postProcessManager: PostProcessManager;
  59960. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  59961. protected _forceFullscreenViewport: boolean;
  59962. /**
  59963. * Creates a min/max reducer
  59964. * @param camera The camera to use for the post processes
  59965. */
  59966. constructor(camera: Camera);
  59967. /**
  59968. * Gets the texture used to read the values from.
  59969. */
  59970. get sourceTexture(): Nullable<RenderTargetTexture>;
  59971. /**
  59972. * Sets the source texture to read the values from.
  59973. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  59974. * because in such textures '1' value must not be taken into account to compute the maximum
  59975. * as this value is used to clear the texture.
  59976. * Note that the computation is not activated by calling this function, you must call activate() for that!
  59977. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  59978. * @param depthRedux Indicates if the texture is a depth texture or not
  59979. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  59980. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  59981. */
  59982. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  59983. /**
  59984. * Defines the refresh rate of the computation.
  59985. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  59986. */
  59987. get refreshRate(): number;
  59988. set refreshRate(value: number);
  59989. protected _activated: boolean;
  59990. /**
  59991. * Gets the activation status of the reducer
  59992. */
  59993. get activated(): boolean;
  59994. /**
  59995. * Activates the reduction computation.
  59996. * When activated, the observers registered in onAfterReductionPerformed are
  59997. * called after the compuation is performed
  59998. */
  59999. activate(): void;
  60000. /**
  60001. * Deactivates the reduction computation.
  60002. */
  60003. deactivate(): void;
  60004. /**
  60005. * Disposes the min/max reducer
  60006. * @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.
  60007. */
  60008. dispose(disposeAll?: boolean): void;
  60009. }
  60010. }
  60011. declare module BABYLON {
  60012. /**
  60013. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60014. */
  60015. export class DepthReducer extends MinMaxReducer {
  60016. private _depthRenderer;
  60017. private _depthRendererId;
  60018. /**
  60019. * Gets the depth renderer used for the computation.
  60020. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60021. */
  60022. get depthRenderer(): Nullable<DepthRenderer>;
  60023. /**
  60024. * Creates a depth reducer
  60025. * @param camera The camera used to render the depth texture
  60026. */
  60027. constructor(camera: Camera);
  60028. /**
  60029. * Sets the depth renderer to use to generate the depth map
  60030. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60031. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60032. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60033. */
  60034. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60035. /** @hidden */
  60036. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60037. /**
  60038. * Activates the reduction computation.
  60039. * When activated, the observers registered in onAfterReductionPerformed are
  60040. * called after the compuation is performed
  60041. */
  60042. activate(): void;
  60043. /**
  60044. * Deactivates the reduction computation.
  60045. */
  60046. deactivate(): void;
  60047. /**
  60048. * Disposes the depth reducer
  60049. * @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.
  60050. */
  60051. dispose(disposeAll?: boolean): void;
  60052. }
  60053. }
  60054. declare module BABYLON {
  60055. /**
  60056. * A CSM implementation allowing casting shadows on large scenes.
  60057. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60058. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60059. */
  60060. export class CascadedShadowGenerator extends ShadowGenerator {
  60061. private static readonly frustumCornersNDCSpace;
  60062. /**
  60063. * Name of the CSM class
  60064. */
  60065. static CLASSNAME: string;
  60066. /**
  60067. * Defines the default number of cascades used by the CSM.
  60068. */
  60069. static readonly DEFAULT_CASCADES_COUNT: number;
  60070. /**
  60071. * Defines the minimum number of cascades used by the CSM.
  60072. */
  60073. static readonly MIN_CASCADES_COUNT: number;
  60074. /**
  60075. * Defines the maximum number of cascades used by the CSM.
  60076. */
  60077. static readonly MAX_CASCADES_COUNT: number;
  60078. protected _validateFilter(filter: number): number;
  60079. /**
  60080. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60081. */
  60082. penumbraDarkness: number;
  60083. private _numCascades;
  60084. /**
  60085. * Gets or set the number of cascades used by the CSM.
  60086. */
  60087. get numCascades(): number;
  60088. set numCascades(value: number);
  60089. /**
  60090. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60091. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60092. */
  60093. stabilizeCascades: boolean;
  60094. private _freezeShadowCastersBoundingInfo;
  60095. private _freezeShadowCastersBoundingInfoObservable;
  60096. /**
  60097. * Enables or disables the shadow casters bounding info computation.
  60098. * If your shadow casters don't move, you can disable this feature.
  60099. * If it is enabled, the bounding box computation is done every frame.
  60100. */
  60101. get freezeShadowCastersBoundingInfo(): boolean;
  60102. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60103. private _scbiMin;
  60104. private _scbiMax;
  60105. protected _computeShadowCastersBoundingInfo(): void;
  60106. protected _shadowCastersBoundingInfo: BoundingInfo;
  60107. /**
  60108. * Gets or sets the shadow casters bounding info.
  60109. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60110. * so that the system won't overwrite the bounds you provide
  60111. */
  60112. get shadowCastersBoundingInfo(): BoundingInfo;
  60113. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60114. protected _breaksAreDirty: boolean;
  60115. protected _minDistance: number;
  60116. protected _maxDistance: number;
  60117. /**
  60118. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60119. *
  60120. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60121. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60122. * @param min minimal distance for the breaks (default to 0.)
  60123. * @param max maximal distance for the breaks (default to 1.)
  60124. */
  60125. setMinMaxDistance(min: number, max: number): void;
  60126. /** Gets the minimal distance used in the cascade break computation */
  60127. get minDistance(): number;
  60128. /** Gets the maximal distance used in the cascade break computation */
  60129. get maxDistance(): number;
  60130. /**
  60131. * Gets the class name of that object
  60132. * @returns "CascadedShadowGenerator"
  60133. */
  60134. getClassName(): string;
  60135. private _cascadeMinExtents;
  60136. private _cascadeMaxExtents;
  60137. /**
  60138. * Gets a cascade minimum extents
  60139. * @param cascadeIndex index of the cascade
  60140. * @returns the minimum cascade extents
  60141. */
  60142. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60143. /**
  60144. * Gets a cascade maximum extents
  60145. * @param cascadeIndex index of the cascade
  60146. * @returns the maximum cascade extents
  60147. */
  60148. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60149. private _cascades;
  60150. private _currentLayer;
  60151. private _viewSpaceFrustumsZ;
  60152. private _viewMatrices;
  60153. private _projectionMatrices;
  60154. private _transformMatrices;
  60155. private _transformMatricesAsArray;
  60156. private _frustumLengths;
  60157. private _lightSizeUVCorrection;
  60158. private _depthCorrection;
  60159. private _frustumCornersWorldSpace;
  60160. private _frustumCenter;
  60161. private _shadowCameraPos;
  60162. private _shadowMaxZ;
  60163. /**
  60164. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60165. * It defaults to camera.maxZ
  60166. */
  60167. get shadowMaxZ(): number;
  60168. /**
  60169. * Sets the shadow max z distance.
  60170. */
  60171. set shadowMaxZ(value: number);
  60172. protected _debug: boolean;
  60173. /**
  60174. * Gets or sets the debug flag.
  60175. * When enabled, the cascades are materialized by different colors on the screen.
  60176. */
  60177. get debug(): boolean;
  60178. set debug(dbg: boolean);
  60179. private _depthClamp;
  60180. /**
  60181. * Gets or sets the depth clamping value.
  60182. *
  60183. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60184. * to account for the shadow casters far away.
  60185. *
  60186. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60187. */
  60188. get depthClamp(): boolean;
  60189. set depthClamp(value: boolean);
  60190. private _cascadeBlendPercentage;
  60191. /**
  60192. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60193. * It defaults to 0.1 (10% blending).
  60194. */
  60195. get cascadeBlendPercentage(): number;
  60196. set cascadeBlendPercentage(value: number);
  60197. private _lambda;
  60198. /**
  60199. * Gets or set the lambda parameter.
  60200. * This parameter is used to split the camera frustum and create the cascades.
  60201. * 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.
  60202. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60203. */
  60204. get lambda(): number;
  60205. set lambda(value: number);
  60206. /**
  60207. * Gets the view matrix corresponding to a given cascade
  60208. * @param cascadeNum cascade to retrieve the view matrix from
  60209. * @returns the cascade view matrix
  60210. */
  60211. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60212. /**
  60213. * Gets the projection matrix corresponding to a given cascade
  60214. * @param cascadeNum cascade to retrieve the projection matrix from
  60215. * @returns the cascade projection matrix
  60216. */
  60217. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60218. /**
  60219. * Gets the transformation matrix corresponding to a given cascade
  60220. * @param cascadeNum cascade to retrieve the transformation matrix from
  60221. * @returns the cascade transformation matrix
  60222. */
  60223. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60224. private _depthRenderer;
  60225. /**
  60226. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60227. *
  60228. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60229. *
  60230. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60231. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60232. * @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
  60233. */
  60234. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60235. private _depthReducer;
  60236. private _autoCalcDepthBounds;
  60237. /**
  60238. * Gets or sets the autoCalcDepthBounds property.
  60239. *
  60240. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60241. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60242. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60243. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60244. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60245. */
  60246. get autoCalcDepthBounds(): boolean;
  60247. set autoCalcDepthBounds(value: boolean);
  60248. /**
  60249. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60250. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60251. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60252. * for setting the refresh rate on the renderer yourself!
  60253. */
  60254. get autoCalcDepthBoundsRefreshRate(): number;
  60255. set autoCalcDepthBoundsRefreshRate(value: number);
  60256. /**
  60257. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60258. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60259. * you change the camera near/far planes!
  60260. */
  60261. splitFrustum(): void;
  60262. private _splitFrustum;
  60263. private _computeMatrices;
  60264. private _computeFrustumInWorldSpace;
  60265. private _computeCascadeFrustum;
  60266. /**
  60267. * Support test.
  60268. */
  60269. static get IsSupported(): boolean;
  60270. /** @hidden */
  60271. static _SceneComponentInitialization: (scene: Scene) => void;
  60272. /**
  60273. * Creates a Cascaded Shadow Generator object.
  60274. * A ShadowGenerator is the required tool to use the shadows.
  60275. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60276. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60277. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60278. * @param light The directional light object generating the shadows.
  60279. * @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.
  60280. */
  60281. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60282. protected _initializeGenerator(): void;
  60283. protected _createTargetRenderTexture(): void;
  60284. protected _initializeShadowMap(): void;
  60285. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60286. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60287. /**
  60288. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60289. * @param defines Defines of the material we want to update
  60290. * @param lightIndex Index of the light in the enabled light list of the material
  60291. */
  60292. prepareDefines(defines: any, lightIndex: number): void;
  60293. /**
  60294. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60295. * defined in the generator but impacting the effect).
  60296. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60297. * @param effect The effect we are binfing the information for
  60298. */
  60299. bindShadowLight(lightIndex: string, effect: Effect): void;
  60300. /**
  60301. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60302. * (eq to view projection * shadow projection matrices)
  60303. * @returns The transform matrix used to create the shadow map
  60304. */
  60305. getTransformMatrix(): Matrix;
  60306. /**
  60307. * Disposes the ShadowGenerator.
  60308. * Returns nothing.
  60309. */
  60310. dispose(): void;
  60311. /**
  60312. * Serializes the shadow generator setup to a json object.
  60313. * @returns The serialized JSON object
  60314. */
  60315. serialize(): any;
  60316. /**
  60317. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60318. * @param parsedShadowGenerator The JSON object to parse
  60319. * @param scene The scene to create the shadow map for
  60320. * @returns The parsed shadow generator
  60321. */
  60322. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60323. }
  60324. }
  60325. declare module BABYLON {
  60326. /**
  60327. * Defines the shadow generator component responsible to manage any shadow generators
  60328. * in a given scene.
  60329. */
  60330. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60331. /**
  60332. * The component name helpfull to identify the component in the list of scene components.
  60333. */
  60334. readonly name: string;
  60335. /**
  60336. * The scene the component belongs to.
  60337. */
  60338. scene: Scene;
  60339. /**
  60340. * Creates a new instance of the component for the given scene
  60341. * @param scene Defines the scene to register the component in
  60342. */
  60343. constructor(scene: Scene);
  60344. /**
  60345. * Registers the component in a given scene
  60346. */
  60347. register(): void;
  60348. /**
  60349. * Rebuilds the elements related to this component in case of
  60350. * context lost for instance.
  60351. */
  60352. rebuild(): void;
  60353. /**
  60354. * Serializes the component data to the specified json object
  60355. * @param serializationObject The object to serialize to
  60356. */
  60357. serialize(serializationObject: any): void;
  60358. /**
  60359. * Adds all the elements from the container to the scene
  60360. * @param container the container holding the elements
  60361. */
  60362. addFromContainer(container: AbstractScene): void;
  60363. /**
  60364. * Removes all the elements in the container from the scene
  60365. * @param container contains the elements to remove
  60366. * @param dispose if the removed element should be disposed (default: false)
  60367. */
  60368. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60369. /**
  60370. * Rebuilds the elements related to this component in case of
  60371. * context lost for instance.
  60372. */
  60373. dispose(): void;
  60374. private _gatherRenderTargets;
  60375. }
  60376. }
  60377. declare module BABYLON {
  60378. /**
  60379. * A point light is a light defined by an unique point in world space.
  60380. * The light is emitted in every direction from this point.
  60381. * A good example of a point light is a standard light bulb.
  60382. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60383. */
  60384. export class PointLight extends ShadowLight {
  60385. private _shadowAngle;
  60386. /**
  60387. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60388. * This specifies what angle the shadow will use to be created.
  60389. *
  60390. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60391. */
  60392. get shadowAngle(): number;
  60393. /**
  60394. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60395. * This specifies what angle the shadow will use to be created.
  60396. *
  60397. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60398. */
  60399. set shadowAngle(value: number);
  60400. /**
  60401. * Gets the direction if it has been set.
  60402. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60403. */
  60404. get direction(): Vector3;
  60405. /**
  60406. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60407. */
  60408. set direction(value: Vector3);
  60409. /**
  60410. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60411. * A PointLight emits the light in every direction.
  60412. * It can cast shadows.
  60413. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60414. * ```javascript
  60415. * var pointLight = new PointLight("pl", camera.position, scene);
  60416. * ```
  60417. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60418. * @param name The light friendly name
  60419. * @param position The position of the point light in the scene
  60420. * @param scene The scene the lights belongs to
  60421. */
  60422. constructor(name: string, position: Vector3, scene: Scene);
  60423. /**
  60424. * Returns the string "PointLight"
  60425. * @returns the class name
  60426. */
  60427. getClassName(): string;
  60428. /**
  60429. * Returns the integer 0.
  60430. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60431. */
  60432. getTypeID(): number;
  60433. /**
  60434. * Specifies wether or not the shadowmap should be a cube texture.
  60435. * @returns true if the shadowmap needs to be a cube texture.
  60436. */
  60437. needCube(): boolean;
  60438. /**
  60439. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60440. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60441. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60442. */
  60443. getShadowDirection(faceIndex?: number): Vector3;
  60444. /**
  60445. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60446. * - fov = PI / 2
  60447. * - aspect ratio : 1.0
  60448. * - z-near and far equal to the active camera minZ and maxZ.
  60449. * Returns the PointLight.
  60450. */
  60451. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60452. protected _buildUniformLayout(): void;
  60453. /**
  60454. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60455. * @param effect The effect to update
  60456. * @param lightIndex The index of the light in the effect to update
  60457. * @returns The point light
  60458. */
  60459. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60460. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60461. /**
  60462. * Prepares the list of defines specific to the light type.
  60463. * @param defines the list of defines
  60464. * @param lightIndex defines the index of the light for the effect
  60465. */
  60466. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60467. }
  60468. }
  60469. declare module BABYLON {
  60470. /**
  60471. * Header information of HDR texture files.
  60472. */
  60473. export interface HDRInfo {
  60474. /**
  60475. * The height of the texture in pixels.
  60476. */
  60477. height: number;
  60478. /**
  60479. * The width of the texture in pixels.
  60480. */
  60481. width: number;
  60482. /**
  60483. * The index of the beginning of the data in the binary file.
  60484. */
  60485. dataPosition: number;
  60486. }
  60487. /**
  60488. * This groups tools to convert HDR texture to native colors array.
  60489. */
  60490. export class HDRTools {
  60491. private static Ldexp;
  60492. private static Rgbe2float;
  60493. private static readStringLine;
  60494. /**
  60495. * Reads header information from an RGBE texture stored in a native array.
  60496. * More information on this format are available here:
  60497. * https://en.wikipedia.org/wiki/RGBE_image_format
  60498. *
  60499. * @param uint8array The binary file stored in native array.
  60500. * @return The header information.
  60501. */
  60502. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60503. /**
  60504. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60505. * This RGBE texture needs to store the information as a panorama.
  60506. *
  60507. * More information on this format are available here:
  60508. * https://en.wikipedia.org/wiki/RGBE_image_format
  60509. *
  60510. * @param buffer The binary file stored in an array buffer.
  60511. * @param size The expected size of the extracted cubemap.
  60512. * @return The Cube Map information.
  60513. */
  60514. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60515. /**
  60516. * Returns the pixels data extracted from an RGBE texture.
  60517. * This pixels will be stored left to right up to down in the R G B order in one array.
  60518. *
  60519. * More information on this format are available here:
  60520. * https://en.wikipedia.org/wiki/RGBE_image_format
  60521. *
  60522. * @param uint8array The binary file stored in an array buffer.
  60523. * @param hdrInfo The header information of the file.
  60524. * @return The pixels data in RGB right to left up to down order.
  60525. */
  60526. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60527. private static RGBE_ReadPixels_RLE;
  60528. private static RGBE_ReadPixels_NOT_RLE;
  60529. }
  60530. }
  60531. declare module BABYLON {
  60532. /**
  60533. * Effect Render Options
  60534. */
  60535. export interface IEffectRendererOptions {
  60536. /**
  60537. * Defines the vertices positions.
  60538. */
  60539. positions?: number[];
  60540. /**
  60541. * Defines the indices.
  60542. */
  60543. indices?: number[];
  60544. }
  60545. /**
  60546. * Helper class to render one or more effects.
  60547. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60548. */
  60549. export class EffectRenderer {
  60550. private engine;
  60551. private static _DefaultOptions;
  60552. private _vertexBuffers;
  60553. private _indexBuffer;
  60554. private _fullscreenViewport;
  60555. /**
  60556. * Creates an effect renderer
  60557. * @param engine the engine to use for rendering
  60558. * @param options defines the options of the effect renderer
  60559. */
  60560. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60561. /**
  60562. * Sets the current viewport in normalized coordinates 0-1
  60563. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60564. */
  60565. setViewport(viewport?: Viewport): void;
  60566. /**
  60567. * Binds the embedded attributes buffer to the effect.
  60568. * @param effect Defines the effect to bind the attributes for
  60569. */
  60570. bindBuffers(effect: Effect): void;
  60571. /**
  60572. * Sets the current effect wrapper to use during draw.
  60573. * The effect needs to be ready before calling this api.
  60574. * This also sets the default full screen position attribute.
  60575. * @param effectWrapper Defines the effect to draw with
  60576. */
  60577. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60578. /**
  60579. * Restores engine states
  60580. */
  60581. restoreStates(): void;
  60582. /**
  60583. * Draws a full screen quad.
  60584. */
  60585. draw(): void;
  60586. private isRenderTargetTexture;
  60587. /**
  60588. * renders one or more effects to a specified texture
  60589. * @param effectWrapper the effect to renderer
  60590. * @param outputTexture texture to draw to, if null it will render to the screen.
  60591. */
  60592. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60593. /**
  60594. * Disposes of the effect renderer
  60595. */
  60596. dispose(): void;
  60597. }
  60598. /**
  60599. * Options to create an EffectWrapper
  60600. */
  60601. interface EffectWrapperCreationOptions {
  60602. /**
  60603. * Engine to use to create the effect
  60604. */
  60605. engine: ThinEngine;
  60606. /**
  60607. * Fragment shader for the effect
  60608. */
  60609. fragmentShader: string;
  60610. /**
  60611. * Use the shader store instead of direct source code
  60612. */
  60613. useShaderStore?: boolean;
  60614. /**
  60615. * Vertex shader for the effect
  60616. */
  60617. vertexShader?: string;
  60618. /**
  60619. * Attributes to use in the shader
  60620. */
  60621. attributeNames?: Array<string>;
  60622. /**
  60623. * Uniforms to use in the shader
  60624. */
  60625. uniformNames?: Array<string>;
  60626. /**
  60627. * Texture sampler names to use in the shader
  60628. */
  60629. samplerNames?: Array<string>;
  60630. /**
  60631. * Defines to use in the shader
  60632. */
  60633. defines?: Array<string>;
  60634. /**
  60635. * Callback when effect is compiled
  60636. */
  60637. onCompiled?: Nullable<(effect: Effect) => void>;
  60638. /**
  60639. * The friendly name of the effect displayed in Spector.
  60640. */
  60641. name?: string;
  60642. }
  60643. /**
  60644. * Wraps an effect to be used for rendering
  60645. */
  60646. export class EffectWrapper {
  60647. /**
  60648. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60649. */
  60650. onApplyObservable: Observable<{}>;
  60651. /**
  60652. * The underlying effect
  60653. */
  60654. effect: Effect;
  60655. /**
  60656. * Creates an effect to be renderer
  60657. * @param creationOptions options to create the effect
  60658. */
  60659. constructor(creationOptions: EffectWrapperCreationOptions);
  60660. /**
  60661. * Disposes of the effect wrapper
  60662. */
  60663. dispose(): void;
  60664. }
  60665. }
  60666. declare module BABYLON {
  60667. /** @hidden */
  60668. export var hdrFilteringVertexShader: {
  60669. name: string;
  60670. shader: string;
  60671. };
  60672. }
  60673. declare module BABYLON {
  60674. /** @hidden */
  60675. export var hdrFilteringPixelShader: {
  60676. name: string;
  60677. shader: string;
  60678. };
  60679. }
  60680. declare module BABYLON {
  60681. /**
  60682. * Options for texture filtering
  60683. */
  60684. interface IHDRFilteringOptions {
  60685. /**
  60686. * Scales pixel intensity for the input HDR map.
  60687. */
  60688. hdrScale?: number;
  60689. /**
  60690. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60691. */
  60692. quality?: number;
  60693. }
  60694. /**
  60695. * Filters HDR maps to get correct renderings of PBR reflections
  60696. */
  60697. export class HDRFiltering {
  60698. private _engine;
  60699. private _effectRenderer;
  60700. private _effectWrapper;
  60701. private _lodGenerationOffset;
  60702. private _lodGenerationScale;
  60703. /**
  60704. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  60705. * you care about baking speed.
  60706. */
  60707. quality: number;
  60708. /**
  60709. * Scales pixel intensity for the input HDR map.
  60710. */
  60711. hdrScale: number;
  60712. /**
  60713. * Instantiates HDR filter for reflection maps
  60714. *
  60715. * @param engine Thin engine
  60716. * @param options Options
  60717. */
  60718. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  60719. private _createRenderTarget;
  60720. private _prefilterInternal;
  60721. private _createEffect;
  60722. /**
  60723. * Get a value indicating if the filter is ready to be used
  60724. * @param texture Texture to filter
  60725. * @returns true if the filter is ready
  60726. */
  60727. isReady(texture: BaseTexture): boolean;
  60728. /**
  60729. * Prefilters a cube texture to have mipmap levels representing roughness values.
  60730. * Prefiltering will be invoked at the end of next rendering pass.
  60731. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  60732. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  60733. * @param texture Texture to filter
  60734. * @param onFinished Callback when filtering is done
  60735. * @return Promise called when prefiltering is done
  60736. */
  60737. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  60738. }
  60739. }
  60740. declare module BABYLON {
  60741. /**
  60742. * This represents a texture coming from an HDR input.
  60743. *
  60744. * The only supported format is currently panorama picture stored in RGBE format.
  60745. * Example of such files can be found on HDRLib: http://hdrlib.com/
  60746. */
  60747. export class HDRCubeTexture extends BaseTexture {
  60748. private static _facesMapping;
  60749. private _generateHarmonics;
  60750. private _noMipmap;
  60751. private _prefilterOnLoad;
  60752. private _textureMatrix;
  60753. private _size;
  60754. private _onLoad;
  60755. private _onError;
  60756. /**
  60757. * The texture URL.
  60758. */
  60759. url: string;
  60760. protected _isBlocking: boolean;
  60761. /**
  60762. * Sets wether or not the texture is blocking during loading.
  60763. */
  60764. set isBlocking(value: boolean);
  60765. /**
  60766. * Gets wether or not the texture is blocking during loading.
  60767. */
  60768. get isBlocking(): boolean;
  60769. protected _rotationY: number;
  60770. /**
  60771. * Sets texture matrix rotation angle around Y axis in radians.
  60772. */
  60773. set rotationY(value: number);
  60774. /**
  60775. * Gets texture matrix rotation angle around Y axis radians.
  60776. */
  60777. get rotationY(): number;
  60778. /**
  60779. * Gets or sets the center of the bounding box associated with the cube texture
  60780. * It must define where the camera used to render the texture was set
  60781. */
  60782. boundingBoxPosition: Vector3;
  60783. private _boundingBoxSize;
  60784. /**
  60785. * Gets or sets the size of the bounding box associated with the cube texture
  60786. * When defined, the cubemap will switch to local mode
  60787. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  60788. * @example https://www.babylonjs-playground.com/#RNASML
  60789. */
  60790. set boundingBoxSize(value: Vector3);
  60791. get boundingBoxSize(): Vector3;
  60792. /**
  60793. * Instantiates an HDRTexture from the following parameters.
  60794. *
  60795. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  60796. * @param sceneOrEngine The scene or engine the texture will be used in
  60797. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  60798. * @param noMipmap Forces to not generate the mipmap if true
  60799. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  60800. * @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)
  60801. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  60802. */
  60803. 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>);
  60804. /**
  60805. * Get the current class name of the texture useful for serialization or dynamic coding.
  60806. * @returns "HDRCubeTexture"
  60807. */
  60808. getClassName(): string;
  60809. /**
  60810. * Occurs when the file is raw .hdr file.
  60811. */
  60812. private loadTexture;
  60813. clone(): HDRCubeTexture;
  60814. delayLoad(): void;
  60815. /**
  60816. * Get the texture reflection matrix used to rotate/transform the reflection.
  60817. * @returns the reflection matrix
  60818. */
  60819. getReflectionTextureMatrix(): Matrix;
  60820. /**
  60821. * Set the texture reflection matrix used to rotate/transform the reflection.
  60822. * @param value Define the reflection matrix to set
  60823. */
  60824. setReflectionTextureMatrix(value: Matrix): void;
  60825. /**
  60826. * Parses a JSON representation of an HDR Texture in order to create the texture
  60827. * @param parsedTexture Define the JSON representation
  60828. * @param scene Define the scene the texture should be created in
  60829. * @param rootUrl Define the root url in case we need to load relative dependencies
  60830. * @returns the newly created texture after parsing
  60831. */
  60832. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  60833. serialize(): any;
  60834. }
  60835. }
  60836. declare module BABYLON {
  60837. /**
  60838. * Class used to control physics engine
  60839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  60840. */
  60841. export class PhysicsEngine implements IPhysicsEngine {
  60842. private _physicsPlugin;
  60843. /**
  60844. * Global value used to control the smallest number supported by the simulation
  60845. */
  60846. static Epsilon: number;
  60847. private _impostors;
  60848. private _joints;
  60849. private _subTimeStep;
  60850. /**
  60851. * Gets the gravity vector used by the simulation
  60852. */
  60853. gravity: Vector3;
  60854. /**
  60855. * Factory used to create the default physics plugin.
  60856. * @returns The default physics plugin
  60857. */
  60858. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  60859. /**
  60860. * Creates a new Physics Engine
  60861. * @param gravity defines the gravity vector used by the simulation
  60862. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  60863. */
  60864. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  60865. /**
  60866. * Sets the gravity vector used by the simulation
  60867. * @param gravity defines the gravity vector to use
  60868. */
  60869. setGravity(gravity: Vector3): void;
  60870. /**
  60871. * Set the time step of the physics engine.
  60872. * Default is 1/60.
  60873. * To slow it down, enter 1/600 for example.
  60874. * To speed it up, 1/30
  60875. * @param newTimeStep defines the new timestep to apply to this world.
  60876. */
  60877. setTimeStep(newTimeStep?: number): void;
  60878. /**
  60879. * Get the time step of the physics engine.
  60880. * @returns the current time step
  60881. */
  60882. getTimeStep(): number;
  60883. /**
  60884. * Set the sub time step of the physics engine.
  60885. * Default is 0 meaning there is no sub steps
  60886. * To increase physics resolution precision, set a small value (like 1 ms)
  60887. * @param subTimeStep defines the new sub timestep used for physics resolution.
  60888. */
  60889. setSubTimeStep(subTimeStep?: number): void;
  60890. /**
  60891. * Get the sub time step of the physics engine.
  60892. * @returns the current sub time step
  60893. */
  60894. getSubTimeStep(): number;
  60895. /**
  60896. * Release all resources
  60897. */
  60898. dispose(): void;
  60899. /**
  60900. * Gets the name of the current physics plugin
  60901. * @returns the name of the plugin
  60902. */
  60903. getPhysicsPluginName(): string;
  60904. /**
  60905. * Adding a new impostor for the impostor tracking.
  60906. * This will be done by the impostor itself.
  60907. * @param impostor the impostor to add
  60908. */
  60909. addImpostor(impostor: PhysicsImpostor): void;
  60910. /**
  60911. * Remove an impostor from the engine.
  60912. * This impostor and its mesh will not longer be updated by the physics engine.
  60913. * @param impostor the impostor to remove
  60914. */
  60915. removeImpostor(impostor: PhysicsImpostor): void;
  60916. /**
  60917. * Add a joint to the physics engine
  60918. * @param mainImpostor defines the main impostor to which the joint is added.
  60919. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  60920. * @param joint defines the joint that will connect both impostors.
  60921. */
  60922. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60923. /**
  60924. * Removes a joint from the simulation
  60925. * @param mainImpostor defines the impostor used with the joint
  60926. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  60927. * @param joint defines the joint to remove
  60928. */
  60929. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  60930. /**
  60931. * Called by the scene. No need to call it.
  60932. * @param delta defines the timespam between frames
  60933. */
  60934. _step(delta: number): void;
  60935. /**
  60936. * Gets the current plugin used to run the simulation
  60937. * @returns current plugin
  60938. */
  60939. getPhysicsPlugin(): IPhysicsEnginePlugin;
  60940. /**
  60941. * Gets the list of physic impostors
  60942. * @returns an array of PhysicsImpostor
  60943. */
  60944. getImpostors(): Array<PhysicsImpostor>;
  60945. /**
  60946. * Gets the impostor for a physics enabled object
  60947. * @param object defines the object impersonated by the impostor
  60948. * @returns the PhysicsImpostor or null if not found
  60949. */
  60950. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  60951. /**
  60952. * Gets the impostor for a physics body object
  60953. * @param body defines physics body used by the impostor
  60954. * @returns the PhysicsImpostor or null if not found
  60955. */
  60956. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  60957. /**
  60958. * Does a raycast in the physics world
  60959. * @param from when should the ray start?
  60960. * @param to when should the ray end?
  60961. * @returns PhysicsRaycastResult
  60962. */
  60963. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  60964. }
  60965. }
  60966. declare module BABYLON {
  60967. /** @hidden */
  60968. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  60969. private _useDeltaForWorldStep;
  60970. world: any;
  60971. name: string;
  60972. private _physicsMaterials;
  60973. private _fixedTimeStep;
  60974. private _cannonRaycastResult;
  60975. private _raycastResult;
  60976. private _physicsBodysToRemoveAfterStep;
  60977. private _firstFrame;
  60978. BJSCANNON: any;
  60979. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  60980. setGravity(gravity: Vector3): void;
  60981. setTimeStep(timeStep: number): void;
  60982. getTimeStep(): number;
  60983. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  60984. private _removeMarkedPhysicsBodiesFromWorld;
  60985. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60986. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  60987. generatePhysicsBody(impostor: PhysicsImpostor): void;
  60988. private _processChildMeshes;
  60989. removePhysicsBody(impostor: PhysicsImpostor): void;
  60990. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  60991. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  60992. private _addMaterial;
  60993. private _checkWithEpsilon;
  60994. private _createShape;
  60995. private _createHeightmap;
  60996. private _minus90X;
  60997. private _plus90X;
  60998. private _tmpPosition;
  60999. private _tmpDeltaPosition;
  61000. private _tmpUnityRotation;
  61001. private _updatePhysicsBodyTransformation;
  61002. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61003. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61004. isSupported(): boolean;
  61005. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61006. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61007. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61008. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61009. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61010. getBodyMass(impostor: PhysicsImpostor): number;
  61011. getBodyFriction(impostor: PhysicsImpostor): number;
  61012. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61013. getBodyRestitution(impostor: PhysicsImpostor): number;
  61014. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61015. sleepBody(impostor: PhysicsImpostor): void;
  61016. wakeUpBody(impostor: PhysicsImpostor): void;
  61017. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61018. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61019. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61020. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61021. getRadius(impostor: PhysicsImpostor): number;
  61022. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61023. dispose(): void;
  61024. private _extendNamespace;
  61025. /**
  61026. * Does a raycast in the physics world
  61027. * @param from when should the ray start?
  61028. * @param to when should the ray end?
  61029. * @returns PhysicsRaycastResult
  61030. */
  61031. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61032. }
  61033. }
  61034. declare module BABYLON {
  61035. /** @hidden */
  61036. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61037. private _useDeltaForWorldStep;
  61038. world: any;
  61039. name: string;
  61040. BJSOIMO: any;
  61041. private _raycastResult;
  61042. private _fixedTimeStep;
  61043. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61044. setGravity(gravity: Vector3): void;
  61045. setTimeStep(timeStep: number): void;
  61046. getTimeStep(): number;
  61047. private _tmpImpostorsArray;
  61048. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61049. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61051. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61052. private _tmpPositionVector;
  61053. removePhysicsBody(impostor: PhysicsImpostor): void;
  61054. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61055. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61056. isSupported(): boolean;
  61057. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61058. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61059. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61060. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61061. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61062. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61063. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61064. getBodyMass(impostor: PhysicsImpostor): number;
  61065. getBodyFriction(impostor: PhysicsImpostor): number;
  61066. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61067. getBodyRestitution(impostor: PhysicsImpostor): number;
  61068. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61069. sleepBody(impostor: PhysicsImpostor): void;
  61070. wakeUpBody(impostor: PhysicsImpostor): void;
  61071. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61072. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61073. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61074. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61075. getRadius(impostor: PhysicsImpostor): number;
  61076. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61077. dispose(): void;
  61078. /**
  61079. * Does a raycast in the physics world
  61080. * @param from when should the ray start?
  61081. * @param to when should the ray end?
  61082. * @returns PhysicsRaycastResult
  61083. */
  61084. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61085. }
  61086. }
  61087. declare module BABYLON {
  61088. /**
  61089. * AmmoJS Physics plugin
  61090. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61091. * @see https://github.com/kripken/ammo.js/
  61092. */
  61093. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61094. private _useDeltaForWorldStep;
  61095. /**
  61096. * Reference to the Ammo library
  61097. */
  61098. bjsAMMO: any;
  61099. /**
  61100. * Created ammoJS world which physics bodies are added to
  61101. */
  61102. world: any;
  61103. /**
  61104. * Name of the plugin
  61105. */
  61106. name: string;
  61107. private _timeStep;
  61108. private _fixedTimeStep;
  61109. private _maxSteps;
  61110. private _tmpQuaternion;
  61111. private _tmpAmmoTransform;
  61112. private _tmpAmmoQuaternion;
  61113. private _tmpAmmoConcreteContactResultCallback;
  61114. private _collisionConfiguration;
  61115. private _dispatcher;
  61116. private _overlappingPairCache;
  61117. private _solver;
  61118. private _softBodySolver;
  61119. private _tmpAmmoVectorA;
  61120. private _tmpAmmoVectorB;
  61121. private _tmpAmmoVectorC;
  61122. private _tmpAmmoVectorD;
  61123. private _tmpContactCallbackResult;
  61124. private _tmpAmmoVectorRCA;
  61125. private _tmpAmmoVectorRCB;
  61126. private _raycastResult;
  61127. private static readonly DISABLE_COLLISION_FLAG;
  61128. private static readonly KINEMATIC_FLAG;
  61129. private static readonly DISABLE_DEACTIVATION_FLAG;
  61130. /**
  61131. * Initializes the ammoJS plugin
  61132. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61133. * @param ammoInjection can be used to inject your own ammo reference
  61134. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61135. */
  61136. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61137. /**
  61138. * Sets the gravity of the physics world (m/(s^2))
  61139. * @param gravity Gravity to set
  61140. */
  61141. setGravity(gravity: Vector3): void;
  61142. /**
  61143. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61144. * @param timeStep timestep to use in seconds
  61145. */
  61146. setTimeStep(timeStep: number): void;
  61147. /**
  61148. * 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)
  61149. * @param fixedTimeStep fixedTimeStep to use in seconds
  61150. */
  61151. setFixedTimeStep(fixedTimeStep: number): void;
  61152. /**
  61153. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61154. * @param maxSteps the maximum number of steps by the physics engine per frame
  61155. */
  61156. setMaxSteps(maxSteps: number): void;
  61157. /**
  61158. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61159. * @returns the current timestep in seconds
  61160. */
  61161. getTimeStep(): number;
  61162. /**
  61163. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61164. */
  61165. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61166. private _isImpostorInContact;
  61167. private _isImpostorPairInContact;
  61168. private _stepSimulation;
  61169. /**
  61170. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61171. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61172. * After the step the babylon meshes are set to the position of the physics imposters
  61173. * @param delta amount of time to step forward
  61174. * @param impostors array of imposters to update before/after the step
  61175. */
  61176. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61177. /**
  61178. * Update babylon mesh to match physics world object
  61179. * @param impostor imposter to match
  61180. */
  61181. private _afterSoftStep;
  61182. /**
  61183. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61184. * @param impostor imposter to match
  61185. */
  61186. private _ropeStep;
  61187. /**
  61188. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61189. * @param impostor imposter to match
  61190. */
  61191. private _softbodyOrClothStep;
  61192. private _tmpMatrix;
  61193. /**
  61194. * Applies an impulse on the imposter
  61195. * @param impostor imposter to apply impulse to
  61196. * @param force amount of force to be applied to the imposter
  61197. * @param contactPoint the location to apply the impulse on the imposter
  61198. */
  61199. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61200. /**
  61201. * Applies a force on the imposter
  61202. * @param impostor imposter to apply force
  61203. * @param force amount of force to be applied to the imposter
  61204. * @param contactPoint the location to apply the force on the imposter
  61205. */
  61206. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61207. /**
  61208. * Creates a physics body using the plugin
  61209. * @param impostor the imposter to create the physics body on
  61210. */
  61211. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61212. /**
  61213. * Removes the physics body from the imposter and disposes of the body's memory
  61214. * @param impostor imposter to remove the physics body from
  61215. */
  61216. removePhysicsBody(impostor: PhysicsImpostor): void;
  61217. /**
  61218. * Generates a joint
  61219. * @param impostorJoint the imposter joint to create the joint with
  61220. */
  61221. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61222. /**
  61223. * Removes a joint
  61224. * @param impostorJoint the imposter joint to remove the joint from
  61225. */
  61226. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61227. private _addMeshVerts;
  61228. /**
  61229. * Initialise the soft body vertices to match its object's (mesh) vertices
  61230. * Softbody vertices (nodes) are in world space and to match this
  61231. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61232. * @param impostor to create the softbody for
  61233. */
  61234. private _softVertexData;
  61235. /**
  61236. * Create an impostor's soft body
  61237. * @param impostor to create the softbody for
  61238. */
  61239. private _createSoftbody;
  61240. /**
  61241. * Create cloth for an impostor
  61242. * @param impostor to create the softbody for
  61243. */
  61244. private _createCloth;
  61245. /**
  61246. * Create rope for an impostor
  61247. * @param impostor to create the softbody for
  61248. */
  61249. private _createRope;
  61250. /**
  61251. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61252. * @param impostor to create the custom physics shape for
  61253. */
  61254. private _createCustom;
  61255. private _addHullVerts;
  61256. private _createShape;
  61257. /**
  61258. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61259. * @param impostor imposter containing the physics body and babylon object
  61260. */
  61261. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61262. /**
  61263. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61264. * @param impostor imposter containing the physics body and babylon object
  61265. * @param newPosition new position
  61266. * @param newRotation new rotation
  61267. */
  61268. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61269. /**
  61270. * If this plugin is supported
  61271. * @returns true if its supported
  61272. */
  61273. isSupported(): boolean;
  61274. /**
  61275. * Sets the linear velocity of the physics body
  61276. * @param impostor imposter to set the velocity on
  61277. * @param velocity velocity to set
  61278. */
  61279. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61280. /**
  61281. * Sets the angular velocity of the physics body
  61282. * @param impostor imposter to set the velocity on
  61283. * @param velocity velocity to set
  61284. */
  61285. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61286. /**
  61287. * gets the linear velocity
  61288. * @param impostor imposter to get linear velocity from
  61289. * @returns linear velocity
  61290. */
  61291. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61292. /**
  61293. * gets the angular velocity
  61294. * @param impostor imposter to get angular velocity from
  61295. * @returns angular velocity
  61296. */
  61297. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61298. /**
  61299. * Sets the mass of physics body
  61300. * @param impostor imposter to set the mass on
  61301. * @param mass mass to set
  61302. */
  61303. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61304. /**
  61305. * Gets the mass of the physics body
  61306. * @param impostor imposter to get the mass from
  61307. * @returns mass
  61308. */
  61309. getBodyMass(impostor: PhysicsImpostor): number;
  61310. /**
  61311. * Gets friction of the impostor
  61312. * @param impostor impostor to get friction from
  61313. * @returns friction value
  61314. */
  61315. getBodyFriction(impostor: PhysicsImpostor): number;
  61316. /**
  61317. * Sets friction of the impostor
  61318. * @param impostor impostor to set friction on
  61319. * @param friction friction value
  61320. */
  61321. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61322. /**
  61323. * Gets restitution of the impostor
  61324. * @param impostor impostor to get restitution from
  61325. * @returns restitution value
  61326. */
  61327. getBodyRestitution(impostor: PhysicsImpostor): number;
  61328. /**
  61329. * Sets resitution of the impostor
  61330. * @param impostor impostor to set resitution on
  61331. * @param restitution resitution value
  61332. */
  61333. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61334. /**
  61335. * Gets pressure inside the impostor
  61336. * @param impostor impostor to get pressure from
  61337. * @returns pressure value
  61338. */
  61339. getBodyPressure(impostor: PhysicsImpostor): number;
  61340. /**
  61341. * Sets pressure inside a soft body impostor
  61342. * Cloth and rope must remain 0 pressure
  61343. * @param impostor impostor to set pressure on
  61344. * @param pressure pressure value
  61345. */
  61346. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61347. /**
  61348. * Gets stiffness of the impostor
  61349. * @param impostor impostor to get stiffness from
  61350. * @returns pressure value
  61351. */
  61352. getBodyStiffness(impostor: PhysicsImpostor): number;
  61353. /**
  61354. * Sets stiffness of the impostor
  61355. * @param impostor impostor to set stiffness on
  61356. * @param stiffness stiffness value from 0 to 1
  61357. */
  61358. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61359. /**
  61360. * Gets velocityIterations of the impostor
  61361. * @param impostor impostor to get velocity iterations from
  61362. * @returns velocityIterations value
  61363. */
  61364. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61365. /**
  61366. * Sets velocityIterations of the impostor
  61367. * @param impostor impostor to set velocity iterations on
  61368. * @param velocityIterations velocityIterations value
  61369. */
  61370. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61371. /**
  61372. * Gets positionIterations of the impostor
  61373. * @param impostor impostor to get position iterations from
  61374. * @returns positionIterations value
  61375. */
  61376. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61377. /**
  61378. * Sets positionIterations of the impostor
  61379. * @param impostor impostor to set position on
  61380. * @param positionIterations positionIterations value
  61381. */
  61382. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61383. /**
  61384. * Append an anchor to a cloth object
  61385. * @param impostor is the cloth impostor to add anchor to
  61386. * @param otherImpostor is the rigid impostor to anchor to
  61387. * @param width ratio across width from 0 to 1
  61388. * @param height ratio up height from 0 to 1
  61389. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61390. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61391. */
  61392. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61393. /**
  61394. * Append an hook to a rope object
  61395. * @param impostor is the rope impostor to add hook to
  61396. * @param otherImpostor is the rigid impostor to hook to
  61397. * @param length ratio along the rope from 0 to 1
  61398. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61399. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61400. */
  61401. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61402. /**
  61403. * Sleeps the physics body and stops it from being active
  61404. * @param impostor impostor to sleep
  61405. */
  61406. sleepBody(impostor: PhysicsImpostor): void;
  61407. /**
  61408. * Activates the physics body
  61409. * @param impostor impostor to activate
  61410. */
  61411. wakeUpBody(impostor: PhysicsImpostor): void;
  61412. /**
  61413. * Updates the distance parameters of the joint
  61414. * @param joint joint to update
  61415. * @param maxDistance maximum distance of the joint
  61416. * @param minDistance minimum distance of the joint
  61417. */
  61418. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61419. /**
  61420. * Sets a motor on the joint
  61421. * @param joint joint to set motor on
  61422. * @param speed speed of the motor
  61423. * @param maxForce maximum force of the motor
  61424. * @param motorIndex index of the motor
  61425. */
  61426. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61427. /**
  61428. * Sets the motors limit
  61429. * @param joint joint to set limit on
  61430. * @param upperLimit upper limit
  61431. * @param lowerLimit lower limit
  61432. */
  61433. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61434. /**
  61435. * Syncs the position and rotation of a mesh with the impostor
  61436. * @param mesh mesh to sync
  61437. * @param impostor impostor to update the mesh with
  61438. */
  61439. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61440. /**
  61441. * Gets the radius of the impostor
  61442. * @param impostor impostor to get radius from
  61443. * @returns the radius
  61444. */
  61445. getRadius(impostor: PhysicsImpostor): number;
  61446. /**
  61447. * Gets the box size of the impostor
  61448. * @param impostor impostor to get box size from
  61449. * @param result the resulting box size
  61450. */
  61451. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61452. /**
  61453. * Disposes of the impostor
  61454. */
  61455. dispose(): void;
  61456. /**
  61457. * Does a raycast in the physics world
  61458. * @param from when should the ray start?
  61459. * @param to when should the ray end?
  61460. * @returns PhysicsRaycastResult
  61461. */
  61462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61463. }
  61464. }
  61465. declare module BABYLON {
  61466. interface AbstractScene {
  61467. /**
  61468. * The list of reflection probes added to the scene
  61469. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61470. */
  61471. reflectionProbes: Array<ReflectionProbe>;
  61472. /**
  61473. * Removes the given reflection probe from this scene.
  61474. * @param toRemove The reflection probe to remove
  61475. * @returns The index of the removed reflection probe
  61476. */
  61477. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61478. /**
  61479. * Adds the given reflection probe to this scene.
  61480. * @param newReflectionProbe The reflection probe to add
  61481. */
  61482. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61483. }
  61484. /**
  61485. * Class used to generate realtime reflection / refraction cube textures
  61486. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61487. */
  61488. export class ReflectionProbe {
  61489. /** defines the name of the probe */
  61490. name: string;
  61491. private _scene;
  61492. private _renderTargetTexture;
  61493. private _projectionMatrix;
  61494. private _viewMatrix;
  61495. private _target;
  61496. private _add;
  61497. private _attachedMesh;
  61498. private _invertYAxis;
  61499. /** Gets or sets probe position (center of the cube map) */
  61500. position: Vector3;
  61501. /**
  61502. * Creates a new reflection probe
  61503. * @param name defines the name of the probe
  61504. * @param size defines the texture resolution (for each face)
  61505. * @param scene defines the hosting scene
  61506. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61507. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61508. */
  61509. constructor(
  61510. /** defines the name of the probe */
  61511. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61512. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61513. get samples(): number;
  61514. set samples(value: number);
  61515. /** Gets or sets the refresh rate to use (on every frame by default) */
  61516. get refreshRate(): number;
  61517. set refreshRate(value: number);
  61518. /**
  61519. * Gets the hosting scene
  61520. * @returns a Scene
  61521. */
  61522. getScene(): Scene;
  61523. /** Gets the internal CubeTexture used to render to */
  61524. get cubeTexture(): RenderTargetTexture;
  61525. /** Gets the list of meshes to render */
  61526. get renderList(): Nullable<AbstractMesh[]>;
  61527. /**
  61528. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61529. * @param mesh defines the mesh to attach to
  61530. */
  61531. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61532. /**
  61533. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61534. * @param renderingGroupId The rendering group id corresponding to its index
  61535. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61536. */
  61537. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61538. /**
  61539. * Clean all associated resources
  61540. */
  61541. dispose(): void;
  61542. /**
  61543. * Converts the reflection probe information to a readable string for debug purpose.
  61544. * @param fullDetails Supports for multiple levels of logging within scene loading
  61545. * @returns the human readable reflection probe info
  61546. */
  61547. toString(fullDetails?: boolean): string;
  61548. /**
  61549. * Get the class name of the relfection probe.
  61550. * @returns "ReflectionProbe"
  61551. */
  61552. getClassName(): string;
  61553. /**
  61554. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61555. * @returns The JSON representation of the texture
  61556. */
  61557. serialize(): any;
  61558. /**
  61559. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61560. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61561. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61562. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61563. * @returns The parsed reflection probe if successful
  61564. */
  61565. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61566. }
  61567. }
  61568. declare module BABYLON {
  61569. /** @hidden */
  61570. export var _BabylonLoaderRegistered: boolean;
  61571. /**
  61572. * Helps setting up some configuration for the babylon file loader.
  61573. */
  61574. export class BabylonFileLoaderConfiguration {
  61575. /**
  61576. * The loader does not allow injecting custom physix engine into the plugins.
  61577. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61578. * So you could set this variable to your engine import to make it work.
  61579. */
  61580. static LoaderInjectedPhysicsEngine: any;
  61581. }
  61582. }
  61583. declare module BABYLON {
  61584. /**
  61585. * The Physically based simple base material of BJS.
  61586. *
  61587. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61588. * It is used as the base class for both the specGloss and metalRough conventions.
  61589. */
  61590. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61591. /**
  61592. * Number of Simultaneous lights allowed on the material.
  61593. */
  61594. maxSimultaneousLights: number;
  61595. /**
  61596. * If sets to true, disables all the lights affecting the material.
  61597. */
  61598. disableLighting: boolean;
  61599. /**
  61600. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61601. */
  61602. environmentTexture: BaseTexture;
  61603. /**
  61604. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61605. */
  61606. invertNormalMapX: boolean;
  61607. /**
  61608. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61609. */
  61610. invertNormalMapY: boolean;
  61611. /**
  61612. * Normal map used in the model.
  61613. */
  61614. normalTexture: BaseTexture;
  61615. /**
  61616. * Emissivie color used to self-illuminate the model.
  61617. */
  61618. emissiveColor: Color3;
  61619. /**
  61620. * Emissivie texture used to self-illuminate the model.
  61621. */
  61622. emissiveTexture: BaseTexture;
  61623. /**
  61624. * Occlusion Channel Strenght.
  61625. */
  61626. occlusionStrength: number;
  61627. /**
  61628. * Occlusion Texture of the material (adding extra occlusion effects).
  61629. */
  61630. occlusionTexture: BaseTexture;
  61631. /**
  61632. * Defines the alpha limits in alpha test mode.
  61633. */
  61634. alphaCutOff: number;
  61635. /**
  61636. * Gets the current double sided mode.
  61637. */
  61638. get doubleSided(): boolean;
  61639. /**
  61640. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61641. */
  61642. set doubleSided(value: boolean);
  61643. /**
  61644. * Stores the pre-calculated light information of a mesh in a texture.
  61645. */
  61646. lightmapTexture: BaseTexture;
  61647. /**
  61648. * If true, the light map contains occlusion information instead of lighting info.
  61649. */
  61650. useLightmapAsShadowmap: boolean;
  61651. /**
  61652. * Instantiates a new PBRMaterial instance.
  61653. *
  61654. * @param name The material name
  61655. * @param scene The scene the material will be use in.
  61656. */
  61657. constructor(name: string, scene: Scene);
  61658. getClassName(): string;
  61659. }
  61660. }
  61661. declare module BABYLON {
  61662. /**
  61663. * The PBR material of BJS following the metal roughness convention.
  61664. *
  61665. * This fits to the PBR convention in the GLTF definition:
  61666. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61667. */
  61668. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61669. /**
  61670. * The base color has two different interpretations depending on the value of metalness.
  61671. * When the material is a metal, the base color is the specific measured reflectance value
  61672. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61673. * of the material.
  61674. */
  61675. baseColor: Color3;
  61676. /**
  61677. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61678. * well as opacity information in the alpha channel.
  61679. */
  61680. baseTexture: BaseTexture;
  61681. /**
  61682. * Specifies the metallic scalar value of the material.
  61683. * Can also be used to scale the metalness values of the metallic texture.
  61684. */
  61685. metallic: number;
  61686. /**
  61687. * Specifies the roughness scalar value of the material.
  61688. * Can also be used to scale the roughness values of the metallic texture.
  61689. */
  61690. roughness: number;
  61691. /**
  61692. * Texture containing both the metallic value in the B channel and the
  61693. * roughness value in the G channel to keep better precision.
  61694. */
  61695. metallicRoughnessTexture: BaseTexture;
  61696. /**
  61697. * Instantiates a new PBRMetalRoughnessMaterial instance.
  61698. *
  61699. * @param name The material name
  61700. * @param scene The scene the material will be use in.
  61701. */
  61702. constructor(name: string, scene: Scene);
  61703. /**
  61704. * Return the currrent class name of the material.
  61705. */
  61706. getClassName(): string;
  61707. /**
  61708. * Makes a duplicate of the current material.
  61709. * @param name - name to use for the new material.
  61710. */
  61711. clone(name: string): PBRMetallicRoughnessMaterial;
  61712. /**
  61713. * Serialize the material to a parsable JSON object.
  61714. */
  61715. serialize(): any;
  61716. /**
  61717. * Parses a JSON object correponding to the serialize function.
  61718. */
  61719. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  61720. }
  61721. }
  61722. declare module BABYLON {
  61723. /**
  61724. * The PBR material of BJS following the specular glossiness convention.
  61725. *
  61726. * This fits to the PBR convention in the GLTF definition:
  61727. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  61728. */
  61729. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  61730. /**
  61731. * Specifies the diffuse color of the material.
  61732. */
  61733. diffuseColor: Color3;
  61734. /**
  61735. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  61736. * channel.
  61737. */
  61738. diffuseTexture: BaseTexture;
  61739. /**
  61740. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  61741. */
  61742. specularColor: Color3;
  61743. /**
  61744. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  61745. */
  61746. glossiness: number;
  61747. /**
  61748. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  61749. */
  61750. specularGlossinessTexture: BaseTexture;
  61751. /**
  61752. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  61753. *
  61754. * @param name The material name
  61755. * @param scene The scene the material will be use in.
  61756. */
  61757. constructor(name: string, scene: Scene);
  61758. /**
  61759. * Return the currrent class name of the material.
  61760. */
  61761. getClassName(): string;
  61762. /**
  61763. * Makes a duplicate of the current material.
  61764. * @param name - name to use for the new material.
  61765. */
  61766. clone(name: string): PBRSpecularGlossinessMaterial;
  61767. /**
  61768. * Serialize the material to a parsable JSON object.
  61769. */
  61770. serialize(): any;
  61771. /**
  61772. * Parses a JSON object correponding to the serialize function.
  61773. */
  61774. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  61775. }
  61776. }
  61777. declare module BABYLON {
  61778. /**
  61779. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  61780. * It can help converting any input color in a desired output one. This can then be used to create effects
  61781. * from sepia, black and white to sixties or futuristic rendering...
  61782. *
  61783. * The only supported format is currently 3dl.
  61784. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  61785. */
  61786. export class ColorGradingTexture extends BaseTexture {
  61787. /**
  61788. * The texture URL.
  61789. */
  61790. url: string;
  61791. /**
  61792. * Empty line regex stored for GC.
  61793. */
  61794. private static _noneEmptyLineRegex;
  61795. private _textureMatrix;
  61796. private _onLoad;
  61797. /**
  61798. * Instantiates a ColorGradingTexture from the following parameters.
  61799. *
  61800. * @param url The location of the color gradind data (currently only supporting 3dl)
  61801. * @param sceneOrEngine The scene or engine the texture will be used in
  61802. * @param onLoad defines a callback triggered when the texture has been loaded
  61803. */
  61804. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  61805. /**
  61806. * Fires the onload event from the constructor if requested.
  61807. */
  61808. private _triggerOnLoad;
  61809. /**
  61810. * Returns the texture matrix used in most of the material.
  61811. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  61812. */
  61813. getTextureMatrix(): Matrix;
  61814. /**
  61815. * Occurs when the file being loaded is a .3dl LUT file.
  61816. */
  61817. private load3dlTexture;
  61818. /**
  61819. * Starts the loading process of the texture.
  61820. */
  61821. private loadTexture;
  61822. /**
  61823. * Clones the color gradind texture.
  61824. */
  61825. clone(): ColorGradingTexture;
  61826. /**
  61827. * Called during delayed load for textures.
  61828. */
  61829. delayLoad(): void;
  61830. /**
  61831. * Parses a color grading texture serialized by Babylon.
  61832. * @param parsedTexture The texture information being parsedTexture
  61833. * @param scene The scene to load the texture in
  61834. * @param rootUrl The root url of the data assets to load
  61835. * @return A color gradind texture
  61836. */
  61837. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  61838. /**
  61839. * Serializes the LUT texture to json format.
  61840. */
  61841. serialize(): any;
  61842. }
  61843. }
  61844. declare module BABYLON {
  61845. /**
  61846. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  61847. */
  61848. export class EquiRectangularCubeTexture extends BaseTexture {
  61849. /** The six faces of the cube. */
  61850. private static _FacesMapping;
  61851. private _noMipmap;
  61852. private _onLoad;
  61853. private _onError;
  61854. /** The size of the cubemap. */
  61855. private _size;
  61856. /** The buffer of the image. */
  61857. private _buffer;
  61858. /** The width of the input image. */
  61859. private _width;
  61860. /** The height of the input image. */
  61861. private _height;
  61862. /** The URL to the image. */
  61863. url: string;
  61864. /**
  61865. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  61866. * @param url The location of the image
  61867. * @param scene The scene the texture will be used in
  61868. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61869. * @param noMipmap Forces to not generate the mipmap if true
  61870. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  61871. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  61872. * @param onLoad — defines a callback called when texture is loaded
  61873. * @param onError — defines a callback called if there is an error
  61874. */
  61875. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  61876. /**
  61877. * Load the image data, by putting the image on a canvas and extracting its buffer.
  61878. */
  61879. private loadImage;
  61880. /**
  61881. * Convert the image buffer into a cubemap and create a CubeTexture.
  61882. */
  61883. private loadTexture;
  61884. /**
  61885. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  61886. * @param buffer The ArrayBuffer that should be converted.
  61887. * @returns The buffer as Float32Array.
  61888. */
  61889. private getFloat32ArrayFromArrayBuffer;
  61890. /**
  61891. * Get the current class name of the texture useful for serialization or dynamic coding.
  61892. * @returns "EquiRectangularCubeTexture"
  61893. */
  61894. getClassName(): string;
  61895. /**
  61896. * Create a clone of the current EquiRectangularCubeTexture and return it.
  61897. * @returns A clone of the current EquiRectangularCubeTexture.
  61898. */
  61899. clone(): EquiRectangularCubeTexture;
  61900. }
  61901. }
  61902. declare module BABYLON {
  61903. /**
  61904. * Defines the options related to the creation of an HtmlElementTexture
  61905. */
  61906. export interface IHtmlElementTextureOptions {
  61907. /**
  61908. * Defines wether mip maps should be created or not.
  61909. */
  61910. generateMipMaps?: boolean;
  61911. /**
  61912. * Defines the sampling mode of the texture.
  61913. */
  61914. samplingMode?: number;
  61915. /**
  61916. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  61917. */
  61918. engine: Nullable<ThinEngine>;
  61919. /**
  61920. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  61921. */
  61922. scene: Nullable<Scene>;
  61923. }
  61924. /**
  61925. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  61926. * To be as efficient as possible depending on your constraints nothing aside the first upload
  61927. * is automatically managed.
  61928. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  61929. * in your application.
  61930. *
  61931. * As the update is not automatic, you need to call them manually.
  61932. */
  61933. export class HtmlElementTexture extends BaseTexture {
  61934. /**
  61935. * The texture URL.
  61936. */
  61937. element: HTMLVideoElement | HTMLCanvasElement;
  61938. private static readonly DefaultOptions;
  61939. private _textureMatrix;
  61940. private _isVideo;
  61941. private _generateMipMaps;
  61942. private _samplingMode;
  61943. /**
  61944. * Instantiates a HtmlElementTexture from the following parameters.
  61945. *
  61946. * @param name Defines the name of the texture
  61947. * @param element Defines the video or canvas the texture is filled with
  61948. * @param options Defines the other none mandatory texture creation options
  61949. */
  61950. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  61951. private _createInternalTexture;
  61952. /**
  61953. * Returns the texture matrix used in most of the material.
  61954. */
  61955. getTextureMatrix(): Matrix;
  61956. /**
  61957. * Updates the content of the texture.
  61958. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  61959. */
  61960. update(invertY?: Nullable<boolean>): void;
  61961. }
  61962. }
  61963. declare module BABYLON {
  61964. /**
  61965. * Based on jsTGALoader - Javascript loader for TGA file
  61966. * By Vincent Thibault
  61967. * @see http://blog.robrowser.com/javascript-tga-loader.html
  61968. */
  61969. export class TGATools {
  61970. private static _TYPE_INDEXED;
  61971. private static _TYPE_RGB;
  61972. private static _TYPE_GREY;
  61973. private static _TYPE_RLE_INDEXED;
  61974. private static _TYPE_RLE_RGB;
  61975. private static _TYPE_RLE_GREY;
  61976. private static _ORIGIN_MASK;
  61977. private static _ORIGIN_SHIFT;
  61978. private static _ORIGIN_BL;
  61979. private static _ORIGIN_BR;
  61980. private static _ORIGIN_UL;
  61981. private static _ORIGIN_UR;
  61982. /**
  61983. * Gets the header of a TGA file
  61984. * @param data defines the TGA data
  61985. * @returns the header
  61986. */
  61987. static GetTGAHeader(data: Uint8Array): any;
  61988. /**
  61989. * Uploads TGA content to a Babylon Texture
  61990. * @hidden
  61991. */
  61992. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  61993. /** @hidden */
  61994. 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;
  61995. /** @hidden */
  61996. 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;
  61997. /** @hidden */
  61998. 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;
  61999. /** @hidden */
  62000. 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;
  62001. /** @hidden */
  62002. 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;
  62003. /** @hidden */
  62004. 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;
  62005. }
  62006. }
  62007. declare module BABYLON {
  62008. /**
  62009. * Implementation of the TGA Texture Loader.
  62010. * @hidden
  62011. */
  62012. export class _TGATextureLoader implements IInternalTextureLoader {
  62013. /**
  62014. * Defines wether the loader supports cascade loading the different faces.
  62015. */
  62016. readonly supportCascades: boolean;
  62017. /**
  62018. * This returns if the loader support the current file information.
  62019. * @param extension defines the file extension of the file being loaded
  62020. * @returns true if the loader can load the specified file
  62021. */
  62022. canLoad(extension: string): boolean;
  62023. /**
  62024. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62025. * @param data contains the texture data
  62026. * @param texture defines the BabylonJS internal texture
  62027. * @param createPolynomials will be true if polynomials have been requested
  62028. * @param onLoad defines the callback to trigger once the texture is ready
  62029. * @param onError defines the callback to trigger in case of error
  62030. */
  62031. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62032. /**
  62033. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62034. * @param data contains the texture data
  62035. * @param texture defines the BabylonJS internal texture
  62036. * @param callback defines the method to call once ready to upload
  62037. */
  62038. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62039. }
  62040. }
  62041. declare module BABYLON {
  62042. /**
  62043. * Info about the .basis files
  62044. */
  62045. class BasisFileInfo {
  62046. /**
  62047. * If the file has alpha
  62048. */
  62049. hasAlpha: boolean;
  62050. /**
  62051. * Info about each image of the basis file
  62052. */
  62053. images: Array<{
  62054. levels: Array<{
  62055. width: number;
  62056. height: number;
  62057. transcodedPixels: ArrayBufferView;
  62058. }>;
  62059. }>;
  62060. }
  62061. /**
  62062. * Result of transcoding a basis file
  62063. */
  62064. class TranscodeResult {
  62065. /**
  62066. * Info about the .basis file
  62067. */
  62068. fileInfo: BasisFileInfo;
  62069. /**
  62070. * Format to use when loading the file
  62071. */
  62072. format: number;
  62073. }
  62074. /**
  62075. * Configuration options for the Basis transcoder
  62076. */
  62077. export class BasisTranscodeConfiguration {
  62078. /**
  62079. * Supported compression formats used to determine the supported output format of the transcoder
  62080. */
  62081. supportedCompressionFormats?: {
  62082. /**
  62083. * etc1 compression format
  62084. */
  62085. etc1?: boolean;
  62086. /**
  62087. * s3tc compression format
  62088. */
  62089. s3tc?: boolean;
  62090. /**
  62091. * pvrtc compression format
  62092. */
  62093. pvrtc?: boolean;
  62094. /**
  62095. * etc2 compression format
  62096. */
  62097. etc2?: boolean;
  62098. };
  62099. /**
  62100. * If mipmap levels should be loaded for transcoded images (Default: true)
  62101. */
  62102. loadMipmapLevels?: boolean;
  62103. /**
  62104. * Index of a single image to load (Default: all images)
  62105. */
  62106. loadSingleImage?: number;
  62107. }
  62108. /**
  62109. * Used to load .Basis files
  62110. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62111. */
  62112. export class BasisTools {
  62113. private static _IgnoreSupportedFormats;
  62114. /**
  62115. * URL to use when loading the basis transcoder
  62116. */
  62117. static JSModuleURL: string;
  62118. /**
  62119. * URL to use when loading the wasm module for the transcoder
  62120. */
  62121. static WasmModuleURL: string;
  62122. /**
  62123. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62124. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62125. * @returns internal format corresponding to the Basis format
  62126. */
  62127. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62128. private static _WorkerPromise;
  62129. private static _Worker;
  62130. private static _actionId;
  62131. private static _CreateWorkerAsync;
  62132. /**
  62133. * Transcodes a loaded image file to compressed pixel data
  62134. * @param data image data to transcode
  62135. * @param config configuration options for the transcoding
  62136. * @returns a promise resulting in the transcoded image
  62137. */
  62138. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62139. /**
  62140. * Loads a texture from the transcode result
  62141. * @param texture texture load to
  62142. * @param transcodeResult the result of transcoding the basis file to load from
  62143. */
  62144. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62145. }
  62146. }
  62147. declare module BABYLON {
  62148. /**
  62149. * Loader for .basis file format
  62150. */
  62151. export class _BasisTextureLoader implements IInternalTextureLoader {
  62152. /**
  62153. * Defines whether the loader supports cascade loading the different faces.
  62154. */
  62155. readonly supportCascades: boolean;
  62156. /**
  62157. * This returns if the loader support the current file information.
  62158. * @param extension defines the file extension of the file being loaded
  62159. * @returns true if the loader can load the specified file
  62160. */
  62161. canLoad(extension: string): boolean;
  62162. /**
  62163. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62164. * @param data contains the texture data
  62165. * @param texture defines the BabylonJS internal texture
  62166. * @param createPolynomials will be true if polynomials have been requested
  62167. * @param onLoad defines the callback to trigger once the texture is ready
  62168. * @param onError defines the callback to trigger in case of error
  62169. */
  62170. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62171. /**
  62172. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62173. * @param data contains the texture data
  62174. * @param texture defines the BabylonJS internal texture
  62175. * @param callback defines the method to call once ready to upload
  62176. */
  62177. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62178. }
  62179. }
  62180. declare module BABYLON {
  62181. /**
  62182. * Defines the basic options interface of a TexturePacker Frame
  62183. */
  62184. export interface ITexturePackerFrame {
  62185. /**
  62186. * The frame ID
  62187. */
  62188. id: number;
  62189. /**
  62190. * The frames Scale
  62191. */
  62192. scale: Vector2;
  62193. /**
  62194. * The Frames offset
  62195. */
  62196. offset: Vector2;
  62197. }
  62198. /**
  62199. * This is a support class for frame Data on texture packer sets.
  62200. */
  62201. export class TexturePackerFrame implements ITexturePackerFrame {
  62202. /**
  62203. * The frame ID
  62204. */
  62205. id: number;
  62206. /**
  62207. * The frames Scale
  62208. */
  62209. scale: Vector2;
  62210. /**
  62211. * The Frames offset
  62212. */
  62213. offset: Vector2;
  62214. /**
  62215. * Initializes a texture package frame.
  62216. * @param id The numerical frame identifier
  62217. * @param scale Scalar Vector2 for UV frame
  62218. * @param offset Vector2 for the frame position in UV units.
  62219. * @returns TexturePackerFrame
  62220. */
  62221. constructor(id: number, scale: Vector2, offset: Vector2);
  62222. }
  62223. }
  62224. declare module BABYLON {
  62225. /**
  62226. * Defines the basic options interface of a TexturePacker
  62227. */
  62228. export interface ITexturePackerOptions {
  62229. /**
  62230. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62231. */
  62232. map?: string[];
  62233. /**
  62234. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62235. */
  62236. uvsIn?: string;
  62237. /**
  62238. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62239. */
  62240. uvsOut?: string;
  62241. /**
  62242. * number representing the layout style. Defaults to LAYOUT_STRIP
  62243. */
  62244. layout?: number;
  62245. /**
  62246. * number of columns if using custom column count layout(2). This defaults to 4.
  62247. */
  62248. colnum?: number;
  62249. /**
  62250. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62251. */
  62252. updateInputMeshes?: boolean;
  62253. /**
  62254. * boolean flag to dispose all the source textures. Defaults to true.
  62255. */
  62256. disposeSources?: boolean;
  62257. /**
  62258. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62259. */
  62260. fillBlanks?: boolean;
  62261. /**
  62262. * string value representing the context fill style color. Defaults to 'black'.
  62263. */
  62264. customFillColor?: string;
  62265. /**
  62266. * Width and Height Value of each Frame in the TexturePacker Sets
  62267. */
  62268. frameSize?: number;
  62269. /**
  62270. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62271. */
  62272. paddingRatio?: number;
  62273. /**
  62274. * Number that declares the fill method for the padding gutter.
  62275. */
  62276. paddingMode?: number;
  62277. /**
  62278. * If in SUBUV_COLOR padding mode what color to use.
  62279. */
  62280. paddingColor?: Color3 | Color4;
  62281. }
  62282. /**
  62283. * Defines the basic interface of a TexturePacker JSON File
  62284. */
  62285. export interface ITexturePackerJSON {
  62286. /**
  62287. * The frame ID
  62288. */
  62289. name: string;
  62290. /**
  62291. * The base64 channel data
  62292. */
  62293. sets: any;
  62294. /**
  62295. * The options of the Packer
  62296. */
  62297. options: ITexturePackerOptions;
  62298. /**
  62299. * The frame data of the Packer
  62300. */
  62301. frames: Array<number>;
  62302. }
  62303. /**
  62304. * This is a support class that generates a series of packed texture sets.
  62305. * @see https://doc.babylonjs.com/babylon101/materials
  62306. */
  62307. export class TexturePacker {
  62308. /** Packer Layout Constant 0 */
  62309. static readonly LAYOUT_STRIP: number;
  62310. /** Packer Layout Constant 1 */
  62311. static readonly LAYOUT_POWER2: number;
  62312. /** Packer Layout Constant 2 */
  62313. static readonly LAYOUT_COLNUM: number;
  62314. /** Packer Layout Constant 0 */
  62315. static readonly SUBUV_WRAP: number;
  62316. /** Packer Layout Constant 1 */
  62317. static readonly SUBUV_EXTEND: number;
  62318. /** Packer Layout Constant 2 */
  62319. static readonly SUBUV_COLOR: number;
  62320. /** The Name of the Texture Package */
  62321. name: string;
  62322. /** The scene scope of the TexturePacker */
  62323. scene: Scene;
  62324. /** The Meshes to target */
  62325. meshes: AbstractMesh[];
  62326. /** Arguments passed with the Constructor */
  62327. options: ITexturePackerOptions;
  62328. /** The promise that is started upon initialization */
  62329. promise: Nullable<Promise<TexturePacker | string>>;
  62330. /** The Container object for the channel sets that are generated */
  62331. sets: object;
  62332. /** The Container array for the frames that are generated */
  62333. frames: TexturePackerFrame[];
  62334. /** The expected number of textures the system is parsing. */
  62335. private _expecting;
  62336. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62337. private _paddingValue;
  62338. /**
  62339. * Initializes a texture package series from an array of meshes or a single mesh.
  62340. * @param name The name of the package
  62341. * @param meshes The target meshes to compose the package from
  62342. * @param options The arguments that texture packer should follow while building.
  62343. * @param scene The scene which the textures are scoped to.
  62344. * @returns TexturePacker
  62345. */
  62346. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62347. /**
  62348. * Starts the package process
  62349. * @param resolve The promises resolution function
  62350. * @returns TexturePacker
  62351. */
  62352. private _createFrames;
  62353. /**
  62354. * Calculates the Size of the Channel Sets
  62355. * @returns Vector2
  62356. */
  62357. private _calculateSize;
  62358. /**
  62359. * Calculates the UV data for the frames.
  62360. * @param baseSize the base frameSize
  62361. * @param padding the base frame padding
  62362. * @param dtSize size of the Dynamic Texture for that channel
  62363. * @param dtUnits is 1/dtSize
  62364. * @param update flag to update the input meshes
  62365. */
  62366. private _calculateMeshUVFrames;
  62367. /**
  62368. * Calculates the frames Offset.
  62369. * @param index of the frame
  62370. * @returns Vector2
  62371. */
  62372. private _getFrameOffset;
  62373. /**
  62374. * Updates a Mesh to the frame data
  62375. * @param mesh that is the target
  62376. * @param frameID or the frame index
  62377. */
  62378. private _updateMeshUV;
  62379. /**
  62380. * Updates a Meshes materials to use the texture packer channels
  62381. * @param m is the mesh to target
  62382. * @param force all channels on the packer to be set.
  62383. */
  62384. private _updateTextureReferences;
  62385. /**
  62386. * Public method to set a Mesh to a frame
  62387. * @param m that is the target
  62388. * @param frameID or the frame index
  62389. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62390. */
  62391. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62392. /**
  62393. * Starts the async promise to compile the texture packer.
  62394. * @returns Promise<void>
  62395. */
  62396. processAsync(): Promise<void>;
  62397. /**
  62398. * Disposes all textures associated with this packer
  62399. */
  62400. dispose(): void;
  62401. /**
  62402. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62403. * @param imageType is the image type to use.
  62404. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62405. */
  62406. download(imageType?: string, quality?: number): void;
  62407. /**
  62408. * Public method to load a texturePacker JSON file.
  62409. * @param data of the JSON file in string format.
  62410. */
  62411. updateFromJSON(data: string): void;
  62412. }
  62413. }
  62414. declare module BABYLON {
  62415. /**
  62416. * 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.
  62417. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62418. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62419. */
  62420. export class CustomProceduralTexture extends ProceduralTexture {
  62421. private _animate;
  62422. private _time;
  62423. private _config;
  62424. private _texturePath;
  62425. /**
  62426. * Instantiates a new Custom Procedural Texture.
  62427. * 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.
  62428. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62429. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62430. * @param name Define the name of the texture
  62431. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62432. * @param size Define the size of the texture to create
  62433. * @param scene Define the scene the texture belongs to
  62434. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62435. * @param generateMipMaps Define if the texture should creates mip maps or not
  62436. */
  62437. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62438. private _loadJson;
  62439. /**
  62440. * Is the texture ready to be used ? (rendered at least once)
  62441. * @returns true if ready, otherwise, false.
  62442. */
  62443. isReady(): boolean;
  62444. /**
  62445. * Render the texture to its associated render target.
  62446. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62447. */
  62448. render(useCameraPostProcess?: boolean): void;
  62449. /**
  62450. * Update the list of dependant textures samplers in the shader.
  62451. */
  62452. updateTextures(): void;
  62453. /**
  62454. * Update the uniform values of the procedural texture in the shader.
  62455. */
  62456. updateShaderUniforms(): void;
  62457. /**
  62458. * Define if the texture animates or not.
  62459. */
  62460. get animate(): boolean;
  62461. set animate(value: boolean);
  62462. }
  62463. }
  62464. declare module BABYLON {
  62465. /** @hidden */
  62466. export var noisePixelShader: {
  62467. name: string;
  62468. shader: string;
  62469. };
  62470. }
  62471. declare module BABYLON {
  62472. /**
  62473. * Class used to generate noise procedural textures
  62474. */
  62475. export class NoiseProceduralTexture extends ProceduralTexture {
  62476. /** Gets or sets the start time (default is 0) */
  62477. time: number;
  62478. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62479. brightness: number;
  62480. /** Defines the number of octaves to process */
  62481. octaves: number;
  62482. /** Defines the level of persistence (0.8 by default) */
  62483. persistence: number;
  62484. /** Gets or sets animation speed factor (default is 1) */
  62485. animationSpeedFactor: number;
  62486. /**
  62487. * Creates a new NoiseProceduralTexture
  62488. * @param name defines the name fo the texture
  62489. * @param size defines the size of the texture (default is 256)
  62490. * @param scene defines the hosting scene
  62491. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62492. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62493. */
  62494. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62495. private _updateShaderUniforms;
  62496. protected _getDefines(): string;
  62497. /** Generate the current state of the procedural texture */
  62498. render(useCameraPostProcess?: boolean): void;
  62499. /**
  62500. * Serializes this noise procedural texture
  62501. * @returns a serialized noise procedural texture object
  62502. */
  62503. serialize(): any;
  62504. /**
  62505. * Clone the texture.
  62506. * @returns the cloned texture
  62507. */
  62508. clone(): NoiseProceduralTexture;
  62509. /**
  62510. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62511. * @param parsedTexture defines parsed texture data
  62512. * @param scene defines the current scene
  62513. * @param rootUrl defines the root URL containing noise procedural texture information
  62514. * @returns a parsed NoiseProceduralTexture
  62515. */
  62516. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62517. }
  62518. }
  62519. declare module BABYLON {
  62520. /**
  62521. * Raw cube texture where the raw buffers are passed in
  62522. */
  62523. export class RawCubeTexture extends CubeTexture {
  62524. /**
  62525. * Creates a cube texture where the raw buffers are passed in.
  62526. * @param scene defines the scene the texture is attached to
  62527. * @param data defines the array of data to use to create each face
  62528. * @param size defines the size of the textures
  62529. * @param format defines the format of the data
  62530. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62531. * @param generateMipMaps defines if the engine should generate the mip levels
  62532. * @param invertY defines if data must be stored with Y axis inverted
  62533. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62534. * @param compression defines the compression used (null by default)
  62535. */
  62536. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62537. /**
  62538. * Updates the raw cube texture.
  62539. * @param data defines the data to store
  62540. * @param format defines the data format
  62541. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62542. * @param invertY defines if data must be stored with Y axis inverted
  62543. * @param compression defines the compression used (null by default)
  62544. * @param level defines which level of the texture to update
  62545. */
  62546. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62547. /**
  62548. * Updates a raw cube texture with RGBD encoded data.
  62549. * @param data defines the array of data [mipmap][face] to use to create each face
  62550. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62551. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62552. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62553. * @returns a promsie that resolves when the operation is complete
  62554. */
  62555. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62556. /**
  62557. * Clones the raw cube texture.
  62558. * @return a new cube texture
  62559. */
  62560. clone(): CubeTexture;
  62561. /** @hidden */
  62562. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62563. }
  62564. }
  62565. declare module BABYLON {
  62566. /**
  62567. * Class used to store 2D array textures containing user data
  62568. */
  62569. export class RawTexture2DArray extends Texture {
  62570. /** Gets or sets the texture format to use */
  62571. format: number;
  62572. /**
  62573. * Create a new RawTexture2DArray
  62574. * @param data defines the data of the texture
  62575. * @param width defines the width of the texture
  62576. * @param height defines the height of the texture
  62577. * @param depth defines the number of layers of the texture
  62578. * @param format defines the texture format to use
  62579. * @param scene defines the hosting scene
  62580. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62581. * @param invertY defines if texture must be stored with Y axis inverted
  62582. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62583. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62584. */
  62585. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62586. /** Gets or sets the texture format to use */
  62587. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62588. /**
  62589. * Update the texture with new data
  62590. * @param data defines the data to store in the texture
  62591. */
  62592. update(data: ArrayBufferView): void;
  62593. }
  62594. }
  62595. declare module BABYLON {
  62596. /**
  62597. * Class used to store 3D textures containing user data
  62598. */
  62599. export class RawTexture3D extends Texture {
  62600. /** Gets or sets the texture format to use */
  62601. format: number;
  62602. /**
  62603. * Create a new RawTexture3D
  62604. * @param data defines the data of the texture
  62605. * @param width defines the width of the texture
  62606. * @param height defines the height of the texture
  62607. * @param depth defines the depth of the texture
  62608. * @param format defines the texture format to use
  62609. * @param scene defines the hosting scene
  62610. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62611. * @param invertY defines if texture must be stored with Y axis inverted
  62612. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62613. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62614. */
  62615. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62616. /** Gets or sets the texture format to use */
  62617. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62618. /**
  62619. * Update the texture with new data
  62620. * @param data defines the data to store in the texture
  62621. */
  62622. update(data: ArrayBufferView): void;
  62623. }
  62624. }
  62625. declare module BABYLON {
  62626. /**
  62627. * Creates a refraction texture used by refraction channel of the standard material.
  62628. * It is like a mirror but to see through a material.
  62629. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62630. */
  62631. export class RefractionTexture extends RenderTargetTexture {
  62632. /**
  62633. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62634. * 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.
  62635. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62636. */
  62637. refractionPlane: Plane;
  62638. /**
  62639. * Define how deep under the surface we should see.
  62640. */
  62641. depth: number;
  62642. /**
  62643. * Creates a refraction texture used by refraction channel of the standard material.
  62644. * It is like a mirror but to see through a material.
  62645. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62646. * @param name Define the texture name
  62647. * @param size Define the size of the underlying texture
  62648. * @param scene Define the scene the refraction belongs to
  62649. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62650. */
  62651. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62652. /**
  62653. * Clone the refraction texture.
  62654. * @returns the cloned texture
  62655. */
  62656. clone(): RefractionTexture;
  62657. /**
  62658. * Serialize the texture to a JSON representation you could use in Parse later on
  62659. * @returns the serialized JSON representation
  62660. */
  62661. serialize(): any;
  62662. }
  62663. }
  62664. declare module BABYLON {
  62665. /**
  62666. * Block used to add support for vertex skinning (bones)
  62667. */
  62668. export class BonesBlock extends NodeMaterialBlock {
  62669. /**
  62670. * Creates a new BonesBlock
  62671. * @param name defines the block name
  62672. */
  62673. constructor(name: string);
  62674. /**
  62675. * Initialize the block and prepare the context for build
  62676. * @param state defines the state that will be used for the build
  62677. */
  62678. initialize(state: NodeMaterialBuildState): void;
  62679. /**
  62680. * Gets the current class name
  62681. * @returns the class name
  62682. */
  62683. getClassName(): string;
  62684. /**
  62685. * Gets the matrix indices input component
  62686. */
  62687. get matricesIndices(): NodeMaterialConnectionPoint;
  62688. /**
  62689. * Gets the matrix weights input component
  62690. */
  62691. get matricesWeights(): NodeMaterialConnectionPoint;
  62692. /**
  62693. * Gets the extra matrix indices input component
  62694. */
  62695. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  62696. /**
  62697. * Gets the extra matrix weights input component
  62698. */
  62699. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  62700. /**
  62701. * Gets the world input component
  62702. */
  62703. get world(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. autoConfigure(material: NodeMaterial): void;
  62709. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  62710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62712. protected _buildBlock(state: NodeMaterialBuildState): this;
  62713. }
  62714. }
  62715. declare module BABYLON {
  62716. /**
  62717. * Block used to add support for instances
  62718. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  62719. */
  62720. export class InstancesBlock extends NodeMaterialBlock {
  62721. /**
  62722. * Creates a new InstancesBlock
  62723. * @param name defines the block name
  62724. */
  62725. constructor(name: string);
  62726. /**
  62727. * Gets the current class name
  62728. * @returns the class name
  62729. */
  62730. getClassName(): string;
  62731. /**
  62732. * Gets the first world row input component
  62733. */
  62734. get world0(): NodeMaterialConnectionPoint;
  62735. /**
  62736. * Gets the second world row input component
  62737. */
  62738. get world1(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the third world row input component
  62741. */
  62742. get world2(): NodeMaterialConnectionPoint;
  62743. /**
  62744. * Gets the forth world row input component
  62745. */
  62746. get world3(): NodeMaterialConnectionPoint;
  62747. /**
  62748. * Gets the world input component
  62749. */
  62750. get world(): NodeMaterialConnectionPoint;
  62751. /**
  62752. * Gets the output component
  62753. */
  62754. get output(): NodeMaterialConnectionPoint;
  62755. /**
  62756. * Gets the isntanceID component
  62757. */
  62758. get instanceID(): NodeMaterialConnectionPoint;
  62759. autoConfigure(material: NodeMaterial): void;
  62760. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  62761. protected _buildBlock(state: NodeMaterialBuildState): this;
  62762. }
  62763. }
  62764. declare module BABYLON {
  62765. /**
  62766. * Block used to add morph targets support to vertex shader
  62767. */
  62768. export class MorphTargetsBlock extends NodeMaterialBlock {
  62769. private _repeatableContentAnchor;
  62770. /**
  62771. * Create a new MorphTargetsBlock
  62772. * @param name defines the block name
  62773. */
  62774. constructor(name: string);
  62775. /**
  62776. * Gets the current class name
  62777. * @returns the class name
  62778. */
  62779. getClassName(): string;
  62780. /**
  62781. * Gets the position input component
  62782. */
  62783. get position(): NodeMaterialConnectionPoint;
  62784. /**
  62785. * Gets the normal input component
  62786. */
  62787. get normal(): NodeMaterialConnectionPoint;
  62788. /**
  62789. * Gets the tangent input component
  62790. */
  62791. get tangent(): NodeMaterialConnectionPoint;
  62792. /**
  62793. * Gets the tangent input component
  62794. */
  62795. get uv(): NodeMaterialConnectionPoint;
  62796. /**
  62797. * Gets the position output component
  62798. */
  62799. get positionOutput(): NodeMaterialConnectionPoint;
  62800. /**
  62801. * Gets the normal output component
  62802. */
  62803. get normalOutput(): NodeMaterialConnectionPoint;
  62804. /**
  62805. * Gets the tangent output component
  62806. */
  62807. get tangentOutput(): NodeMaterialConnectionPoint;
  62808. /**
  62809. * Gets the tangent output component
  62810. */
  62811. get uvOutput(): NodeMaterialConnectionPoint;
  62812. initialize(state: NodeMaterialBuildState): void;
  62813. autoConfigure(material: NodeMaterial): void;
  62814. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62815. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62816. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  62817. protected _buildBlock(state: NodeMaterialBuildState): this;
  62818. }
  62819. }
  62820. declare module BABYLON {
  62821. /**
  62822. * Block used to get data information from a light
  62823. */
  62824. export class LightInformationBlock extends NodeMaterialBlock {
  62825. private _lightDataUniformName;
  62826. private _lightColorUniformName;
  62827. private _lightTypeDefineName;
  62828. /**
  62829. * Gets or sets the light associated with this block
  62830. */
  62831. light: Nullable<Light>;
  62832. /**
  62833. * Creates a new LightInformationBlock
  62834. * @param name defines the block name
  62835. */
  62836. constructor(name: string);
  62837. /**
  62838. * Gets the current class name
  62839. * @returns the class name
  62840. */
  62841. getClassName(): string;
  62842. /**
  62843. * Gets the world position input component
  62844. */
  62845. get worldPosition(): NodeMaterialConnectionPoint;
  62846. /**
  62847. * Gets the direction output component
  62848. */
  62849. get direction(): NodeMaterialConnectionPoint;
  62850. /**
  62851. * Gets the direction output component
  62852. */
  62853. get color(): NodeMaterialConnectionPoint;
  62854. /**
  62855. * Gets the direction output component
  62856. */
  62857. get intensity(): NodeMaterialConnectionPoint;
  62858. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62859. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62860. protected _buildBlock(state: NodeMaterialBuildState): this;
  62861. serialize(): any;
  62862. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62863. }
  62864. }
  62865. declare module BABYLON {
  62866. /**
  62867. * Block used to add image processing support to fragment shader
  62868. */
  62869. export class ImageProcessingBlock extends NodeMaterialBlock {
  62870. /**
  62871. * Create a new ImageProcessingBlock
  62872. * @param name defines the block name
  62873. */
  62874. constructor(name: string);
  62875. /**
  62876. * Gets the current class name
  62877. * @returns the class name
  62878. */
  62879. getClassName(): string;
  62880. /**
  62881. * Gets the color input component
  62882. */
  62883. get color(): NodeMaterialConnectionPoint;
  62884. /**
  62885. * Gets the output component
  62886. */
  62887. get output(): NodeMaterialConnectionPoint;
  62888. /**
  62889. * Initialize the block and prepare the context for build
  62890. * @param state defines the state that will be used for the build
  62891. */
  62892. initialize(state: NodeMaterialBuildState): void;
  62893. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  62894. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62896. protected _buildBlock(state: NodeMaterialBuildState): this;
  62897. }
  62898. }
  62899. declare module BABYLON {
  62900. /**
  62901. * Block used to pertub normals based on a normal map
  62902. */
  62903. export class PerturbNormalBlock extends NodeMaterialBlock {
  62904. private _tangentSpaceParameterName;
  62905. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62906. invertX: boolean;
  62907. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  62908. invertY: boolean;
  62909. /**
  62910. * Create a new PerturbNormalBlock
  62911. * @param name defines the block name
  62912. */
  62913. constructor(name: string);
  62914. /**
  62915. * Gets the current class name
  62916. * @returns the class name
  62917. */
  62918. getClassName(): string;
  62919. /**
  62920. * Gets the world position input component
  62921. */
  62922. get worldPosition(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the world normal input component
  62925. */
  62926. get worldNormal(): NodeMaterialConnectionPoint;
  62927. /**
  62928. * Gets the world tangent input component
  62929. */
  62930. get worldTangent(): NodeMaterialConnectionPoint;
  62931. /**
  62932. * Gets the uv input component
  62933. */
  62934. get uv(): NodeMaterialConnectionPoint;
  62935. /**
  62936. * Gets the normal map color input component
  62937. */
  62938. get normalMapColor(): NodeMaterialConnectionPoint;
  62939. /**
  62940. * Gets the strength input component
  62941. */
  62942. get strength(): NodeMaterialConnectionPoint;
  62943. /**
  62944. * Gets the output component
  62945. */
  62946. get output(): NodeMaterialConnectionPoint;
  62947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62948. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62949. autoConfigure(material: NodeMaterial): void;
  62950. protected _buildBlock(state: NodeMaterialBuildState): this;
  62951. protected _dumpPropertiesCode(): string;
  62952. serialize(): any;
  62953. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62954. }
  62955. }
  62956. declare module BABYLON {
  62957. /**
  62958. * Block used to discard a pixel if a value is smaller than a cutoff
  62959. */
  62960. export class DiscardBlock extends NodeMaterialBlock {
  62961. /**
  62962. * Create a new DiscardBlock
  62963. * @param name defines the block name
  62964. */
  62965. constructor(name: string);
  62966. /**
  62967. * Gets the current class name
  62968. * @returns the class name
  62969. */
  62970. getClassName(): string;
  62971. /**
  62972. * Gets the color input component
  62973. */
  62974. get value(): NodeMaterialConnectionPoint;
  62975. /**
  62976. * Gets the cutoff input component
  62977. */
  62978. get cutoff(): NodeMaterialConnectionPoint;
  62979. protected _buildBlock(state: NodeMaterialBuildState): this;
  62980. }
  62981. }
  62982. declare module BABYLON {
  62983. /**
  62984. * Block used to test if the fragment shader is front facing
  62985. */
  62986. export class FrontFacingBlock extends NodeMaterialBlock {
  62987. /**
  62988. * Creates a new FrontFacingBlock
  62989. * @param name defines the block name
  62990. */
  62991. constructor(name: string);
  62992. /**
  62993. * Gets the current class name
  62994. * @returns the class name
  62995. */
  62996. getClassName(): string;
  62997. /**
  62998. * Gets the output component
  62999. */
  63000. get output(): NodeMaterialConnectionPoint;
  63001. protected _buildBlock(state: NodeMaterialBuildState): this;
  63002. }
  63003. }
  63004. declare module BABYLON {
  63005. /**
  63006. * Block used to get the derivative value on x and y of a given input
  63007. */
  63008. export class DerivativeBlock extends NodeMaterialBlock {
  63009. /**
  63010. * Create a new DerivativeBlock
  63011. * @param name defines the block name
  63012. */
  63013. constructor(name: string);
  63014. /**
  63015. * Gets the current class name
  63016. * @returns the class name
  63017. */
  63018. getClassName(): string;
  63019. /**
  63020. * Gets the input component
  63021. */
  63022. get input(): NodeMaterialConnectionPoint;
  63023. /**
  63024. * Gets the derivative output on x
  63025. */
  63026. get dx(): NodeMaterialConnectionPoint;
  63027. /**
  63028. * Gets the derivative output on y
  63029. */
  63030. get dy(): NodeMaterialConnectionPoint;
  63031. protected _buildBlock(state: NodeMaterialBuildState): this;
  63032. }
  63033. }
  63034. declare module BABYLON {
  63035. /**
  63036. * Block used to make gl_FragCoord available
  63037. */
  63038. export class FragCoordBlock extends NodeMaterialBlock {
  63039. /**
  63040. * Creates a new FragCoordBlock
  63041. * @param name defines the block name
  63042. */
  63043. constructor(name: string);
  63044. /**
  63045. * Gets the current class name
  63046. * @returns the class name
  63047. */
  63048. getClassName(): string;
  63049. /**
  63050. * Gets the xy component
  63051. */
  63052. get xy(): NodeMaterialConnectionPoint;
  63053. /**
  63054. * Gets the xyz component
  63055. */
  63056. get xyz(): NodeMaterialConnectionPoint;
  63057. /**
  63058. * Gets the xyzw component
  63059. */
  63060. get xyzw(): NodeMaterialConnectionPoint;
  63061. /**
  63062. * Gets the x component
  63063. */
  63064. get x(): NodeMaterialConnectionPoint;
  63065. /**
  63066. * Gets the y component
  63067. */
  63068. get y(): NodeMaterialConnectionPoint;
  63069. /**
  63070. * Gets the z component
  63071. */
  63072. get z(): NodeMaterialConnectionPoint;
  63073. /**
  63074. * Gets the w component
  63075. */
  63076. get output(): NodeMaterialConnectionPoint;
  63077. protected writeOutputs(state: NodeMaterialBuildState): string;
  63078. protected _buildBlock(state: NodeMaterialBuildState): this;
  63079. }
  63080. }
  63081. declare module BABYLON {
  63082. /**
  63083. * Block used to get the screen sizes
  63084. */
  63085. export class ScreenSizeBlock extends NodeMaterialBlock {
  63086. private _varName;
  63087. private _scene;
  63088. /**
  63089. * Creates a new ScreenSizeBlock
  63090. * @param name defines the block name
  63091. */
  63092. constructor(name: string);
  63093. /**
  63094. * Gets the current class name
  63095. * @returns the class name
  63096. */
  63097. getClassName(): string;
  63098. /**
  63099. * Gets the xy component
  63100. */
  63101. get xy(): NodeMaterialConnectionPoint;
  63102. /**
  63103. * Gets the x component
  63104. */
  63105. get x(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the y component
  63108. */
  63109. get y(): NodeMaterialConnectionPoint;
  63110. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63111. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63112. protected _buildBlock(state: NodeMaterialBuildState): this;
  63113. }
  63114. }
  63115. declare module BABYLON {
  63116. /**
  63117. * Block used to add support for scene fog
  63118. */
  63119. export class FogBlock extends NodeMaterialBlock {
  63120. private _fogDistanceName;
  63121. private _fogParameters;
  63122. /**
  63123. * Create a new FogBlock
  63124. * @param name defines the block name
  63125. */
  63126. constructor(name: string);
  63127. /**
  63128. * Gets the current class name
  63129. * @returns the class name
  63130. */
  63131. getClassName(): string;
  63132. /**
  63133. * Gets the world position input component
  63134. */
  63135. get worldPosition(): NodeMaterialConnectionPoint;
  63136. /**
  63137. * Gets the view input component
  63138. */
  63139. get view(): NodeMaterialConnectionPoint;
  63140. /**
  63141. * Gets the color input component
  63142. */
  63143. get input(): NodeMaterialConnectionPoint;
  63144. /**
  63145. * Gets the fog color input component
  63146. */
  63147. get fogColor(): NodeMaterialConnectionPoint;
  63148. /**
  63149. * Gets the output component
  63150. */
  63151. get output(): NodeMaterialConnectionPoint;
  63152. autoConfigure(material: NodeMaterial): void;
  63153. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63154. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63155. protected _buildBlock(state: NodeMaterialBuildState): this;
  63156. }
  63157. }
  63158. declare module BABYLON {
  63159. /**
  63160. * Block used to add light in the fragment shader
  63161. */
  63162. export class LightBlock extends NodeMaterialBlock {
  63163. private _lightId;
  63164. /**
  63165. * Gets or sets the light associated with this block
  63166. */
  63167. light: Nullable<Light>;
  63168. /**
  63169. * Create a new LightBlock
  63170. * @param name defines the block name
  63171. */
  63172. constructor(name: string);
  63173. /**
  63174. * Gets the current class name
  63175. * @returns the class name
  63176. */
  63177. getClassName(): string;
  63178. /**
  63179. * Gets the world position input component
  63180. */
  63181. get worldPosition(): NodeMaterialConnectionPoint;
  63182. /**
  63183. * Gets the world normal input component
  63184. */
  63185. get worldNormal(): NodeMaterialConnectionPoint;
  63186. /**
  63187. * Gets the camera (or eye) position component
  63188. */
  63189. get cameraPosition(): NodeMaterialConnectionPoint;
  63190. /**
  63191. * Gets the glossiness component
  63192. */
  63193. get glossiness(): NodeMaterialConnectionPoint;
  63194. /**
  63195. * Gets the glossinness power component
  63196. */
  63197. get glossPower(): NodeMaterialConnectionPoint;
  63198. /**
  63199. * Gets the diffuse color component
  63200. */
  63201. get diffuseColor(): NodeMaterialConnectionPoint;
  63202. /**
  63203. * Gets the specular color component
  63204. */
  63205. get specularColor(): NodeMaterialConnectionPoint;
  63206. /**
  63207. * Gets the diffuse output component
  63208. */
  63209. get diffuseOutput(): NodeMaterialConnectionPoint;
  63210. /**
  63211. * Gets the specular output component
  63212. */
  63213. get specularOutput(): NodeMaterialConnectionPoint;
  63214. /**
  63215. * Gets the shadow output component
  63216. */
  63217. get shadow(): NodeMaterialConnectionPoint;
  63218. autoConfigure(material: NodeMaterial): void;
  63219. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63220. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63221. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63222. private _injectVertexCode;
  63223. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63224. serialize(): any;
  63225. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63226. }
  63227. }
  63228. declare module BABYLON {
  63229. /**
  63230. * Block used to read a reflection texture from a sampler
  63231. */
  63232. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63233. /**
  63234. * Create a new ReflectionTextureBlock
  63235. * @param name defines the block name
  63236. */
  63237. constructor(name: string);
  63238. /**
  63239. * Gets the current class name
  63240. * @returns the class name
  63241. */
  63242. getClassName(): string;
  63243. /**
  63244. * Gets the world position input component
  63245. */
  63246. get position(): NodeMaterialConnectionPoint;
  63247. /**
  63248. * Gets the world position input component
  63249. */
  63250. get worldPosition(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the world normal input component
  63253. */
  63254. get worldNormal(): NodeMaterialConnectionPoint;
  63255. /**
  63256. * Gets the world input component
  63257. */
  63258. get world(): NodeMaterialConnectionPoint;
  63259. /**
  63260. * Gets the camera (or eye) position component
  63261. */
  63262. get cameraPosition(): NodeMaterialConnectionPoint;
  63263. /**
  63264. * Gets the view input component
  63265. */
  63266. get view(): NodeMaterialConnectionPoint;
  63267. /**
  63268. * Gets the rgb output component
  63269. */
  63270. get rgb(): NodeMaterialConnectionPoint;
  63271. /**
  63272. * Gets the rgba output component
  63273. */
  63274. get rgba(): NodeMaterialConnectionPoint;
  63275. /**
  63276. * Gets the r output component
  63277. */
  63278. get r(): NodeMaterialConnectionPoint;
  63279. /**
  63280. * Gets the g output component
  63281. */
  63282. get g(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the b output component
  63285. */
  63286. get b(): NodeMaterialConnectionPoint;
  63287. /**
  63288. * Gets the a output component
  63289. */
  63290. get a(): NodeMaterialConnectionPoint;
  63291. autoConfigure(material: NodeMaterial): void;
  63292. protected _buildBlock(state: NodeMaterialBuildState): this;
  63293. }
  63294. }
  63295. declare module BABYLON {
  63296. /**
  63297. * Block used to add 2 vectors
  63298. */
  63299. export class AddBlock extends NodeMaterialBlock {
  63300. /**
  63301. * Creates a new AddBlock
  63302. * @param name defines the block name
  63303. */
  63304. constructor(name: string);
  63305. /**
  63306. * Gets the current class name
  63307. * @returns the class name
  63308. */
  63309. getClassName(): string;
  63310. /**
  63311. * Gets the left operand input component
  63312. */
  63313. get left(): NodeMaterialConnectionPoint;
  63314. /**
  63315. * Gets the right operand input component
  63316. */
  63317. get right(): NodeMaterialConnectionPoint;
  63318. /**
  63319. * Gets the output component
  63320. */
  63321. get output(): NodeMaterialConnectionPoint;
  63322. protected _buildBlock(state: NodeMaterialBuildState): this;
  63323. }
  63324. }
  63325. declare module BABYLON {
  63326. /**
  63327. * Block used to scale a vector by a float
  63328. */
  63329. export class ScaleBlock extends NodeMaterialBlock {
  63330. /**
  63331. * Creates a new ScaleBlock
  63332. * @param name defines the block name
  63333. */
  63334. constructor(name: string);
  63335. /**
  63336. * Gets the current class name
  63337. * @returns the class name
  63338. */
  63339. getClassName(): string;
  63340. /**
  63341. * Gets the input component
  63342. */
  63343. get input(): NodeMaterialConnectionPoint;
  63344. /**
  63345. * Gets the factor input component
  63346. */
  63347. get factor(): NodeMaterialConnectionPoint;
  63348. /**
  63349. * Gets the output component
  63350. */
  63351. get output(): NodeMaterialConnectionPoint;
  63352. protected _buildBlock(state: NodeMaterialBuildState): this;
  63353. }
  63354. }
  63355. declare module BABYLON {
  63356. /**
  63357. * Block used to clamp a float
  63358. */
  63359. export class ClampBlock extends NodeMaterialBlock {
  63360. /** Gets or sets the minimum range */
  63361. minimum: number;
  63362. /** Gets or sets the maximum range */
  63363. maximum: number;
  63364. /**
  63365. * Creates a new ClampBlock
  63366. * @param name defines the block name
  63367. */
  63368. constructor(name: string);
  63369. /**
  63370. * Gets the current class name
  63371. * @returns the class name
  63372. */
  63373. getClassName(): string;
  63374. /**
  63375. * Gets the value input component
  63376. */
  63377. get value(): NodeMaterialConnectionPoint;
  63378. /**
  63379. * Gets the output component
  63380. */
  63381. get output(): NodeMaterialConnectionPoint;
  63382. protected _buildBlock(state: NodeMaterialBuildState): this;
  63383. protected _dumpPropertiesCode(): string;
  63384. serialize(): any;
  63385. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63386. }
  63387. }
  63388. declare module BABYLON {
  63389. /**
  63390. * Block used to apply a cross product between 2 vectors
  63391. */
  63392. export class CrossBlock extends NodeMaterialBlock {
  63393. /**
  63394. * Creates a new CrossBlock
  63395. * @param name defines the block name
  63396. */
  63397. constructor(name: string);
  63398. /**
  63399. * Gets the current class name
  63400. * @returns the class name
  63401. */
  63402. getClassName(): string;
  63403. /**
  63404. * Gets the left operand input component
  63405. */
  63406. get left(): NodeMaterialConnectionPoint;
  63407. /**
  63408. * Gets the right operand input component
  63409. */
  63410. get right(): NodeMaterialConnectionPoint;
  63411. /**
  63412. * Gets the output component
  63413. */
  63414. get output(): NodeMaterialConnectionPoint;
  63415. protected _buildBlock(state: NodeMaterialBuildState): this;
  63416. }
  63417. }
  63418. declare module BABYLON {
  63419. /**
  63420. * Block used to apply a dot product between 2 vectors
  63421. */
  63422. export class DotBlock extends NodeMaterialBlock {
  63423. /**
  63424. * Creates a new DotBlock
  63425. * @param name defines the block name
  63426. */
  63427. constructor(name: string);
  63428. /**
  63429. * Gets the current class name
  63430. * @returns the class name
  63431. */
  63432. getClassName(): string;
  63433. /**
  63434. * Gets the left operand input component
  63435. */
  63436. get left(): NodeMaterialConnectionPoint;
  63437. /**
  63438. * Gets the right operand input component
  63439. */
  63440. get right(): NodeMaterialConnectionPoint;
  63441. /**
  63442. * Gets the output component
  63443. */
  63444. get output(): NodeMaterialConnectionPoint;
  63445. protected _buildBlock(state: NodeMaterialBuildState): this;
  63446. }
  63447. }
  63448. declare module BABYLON {
  63449. /**
  63450. * Block used to normalize a vector
  63451. */
  63452. export class NormalizeBlock extends NodeMaterialBlock {
  63453. /**
  63454. * Creates a new NormalizeBlock
  63455. * @param name defines the block name
  63456. */
  63457. constructor(name: string);
  63458. /**
  63459. * Gets the current class name
  63460. * @returns the class name
  63461. */
  63462. getClassName(): string;
  63463. /**
  63464. * Gets the input component
  63465. */
  63466. get input(): NodeMaterialConnectionPoint;
  63467. /**
  63468. * Gets the output component
  63469. */
  63470. get output(): NodeMaterialConnectionPoint;
  63471. protected _buildBlock(state: NodeMaterialBuildState): this;
  63472. }
  63473. }
  63474. declare module BABYLON {
  63475. /**
  63476. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63477. */
  63478. export class ColorMergerBlock extends NodeMaterialBlock {
  63479. /**
  63480. * Create a new ColorMergerBlock
  63481. * @param name defines the block name
  63482. */
  63483. constructor(name: string);
  63484. /**
  63485. * Gets the current class name
  63486. * @returns the class name
  63487. */
  63488. getClassName(): string;
  63489. /**
  63490. * Gets the rgb component (input)
  63491. */
  63492. get rgbIn(): NodeMaterialConnectionPoint;
  63493. /**
  63494. * Gets the r component (input)
  63495. */
  63496. get r(): NodeMaterialConnectionPoint;
  63497. /**
  63498. * Gets the g component (input)
  63499. */
  63500. get g(): NodeMaterialConnectionPoint;
  63501. /**
  63502. * Gets the b component (input)
  63503. */
  63504. get b(): NodeMaterialConnectionPoint;
  63505. /**
  63506. * Gets the a component (input)
  63507. */
  63508. get a(): NodeMaterialConnectionPoint;
  63509. /**
  63510. * Gets the rgba component (output)
  63511. */
  63512. get rgba(): NodeMaterialConnectionPoint;
  63513. /**
  63514. * Gets the rgb component (output)
  63515. */
  63516. get rgbOut(): NodeMaterialConnectionPoint;
  63517. /**
  63518. * Gets the rgb component (output)
  63519. * @deprecated Please use rgbOut instead.
  63520. */
  63521. get rgb(): NodeMaterialConnectionPoint;
  63522. protected _buildBlock(state: NodeMaterialBuildState): this;
  63523. }
  63524. }
  63525. declare module BABYLON {
  63526. /**
  63527. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63528. */
  63529. export class VectorSplitterBlock extends NodeMaterialBlock {
  63530. /**
  63531. * Create a new VectorSplitterBlock
  63532. * @param name defines the block name
  63533. */
  63534. constructor(name: string);
  63535. /**
  63536. * Gets the current class name
  63537. * @returns the class name
  63538. */
  63539. getClassName(): string;
  63540. /**
  63541. * Gets the xyzw component (input)
  63542. */
  63543. get xyzw(): NodeMaterialConnectionPoint;
  63544. /**
  63545. * Gets the xyz component (input)
  63546. */
  63547. get xyzIn(): NodeMaterialConnectionPoint;
  63548. /**
  63549. * Gets the xy component (input)
  63550. */
  63551. get xyIn(): NodeMaterialConnectionPoint;
  63552. /**
  63553. * Gets the xyz component (output)
  63554. */
  63555. get xyzOut(): NodeMaterialConnectionPoint;
  63556. /**
  63557. * Gets the xy component (output)
  63558. */
  63559. get xyOut(): NodeMaterialConnectionPoint;
  63560. /**
  63561. * Gets the x component (output)
  63562. */
  63563. get x(): NodeMaterialConnectionPoint;
  63564. /**
  63565. * Gets the y component (output)
  63566. */
  63567. get y(): NodeMaterialConnectionPoint;
  63568. /**
  63569. * Gets the z component (output)
  63570. */
  63571. get z(): NodeMaterialConnectionPoint;
  63572. /**
  63573. * Gets the w component (output)
  63574. */
  63575. get w(): NodeMaterialConnectionPoint;
  63576. protected _inputRename(name: string): string;
  63577. protected _outputRename(name: string): string;
  63578. protected _buildBlock(state: NodeMaterialBuildState): this;
  63579. }
  63580. }
  63581. declare module BABYLON {
  63582. /**
  63583. * Block used to lerp between 2 values
  63584. */
  63585. export class LerpBlock extends NodeMaterialBlock {
  63586. /**
  63587. * Creates a new LerpBlock
  63588. * @param name defines the block name
  63589. */
  63590. constructor(name: string);
  63591. /**
  63592. * Gets the current class name
  63593. * @returns the class name
  63594. */
  63595. getClassName(): string;
  63596. /**
  63597. * Gets the left operand input component
  63598. */
  63599. get left(): NodeMaterialConnectionPoint;
  63600. /**
  63601. * Gets the right operand input component
  63602. */
  63603. get right(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the gradient operand input component
  63606. */
  63607. get gradient(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the output component
  63610. */
  63611. get output(): NodeMaterialConnectionPoint;
  63612. protected _buildBlock(state: NodeMaterialBuildState): this;
  63613. }
  63614. }
  63615. declare module BABYLON {
  63616. /**
  63617. * Block used to divide 2 vectors
  63618. */
  63619. export class DivideBlock extends NodeMaterialBlock {
  63620. /**
  63621. * Creates a new DivideBlock
  63622. * @param name defines the block name
  63623. */
  63624. constructor(name: string);
  63625. /**
  63626. * Gets the current class name
  63627. * @returns the class name
  63628. */
  63629. getClassName(): string;
  63630. /**
  63631. * Gets the left operand input component
  63632. */
  63633. get left(): NodeMaterialConnectionPoint;
  63634. /**
  63635. * Gets the right operand input component
  63636. */
  63637. get right(): NodeMaterialConnectionPoint;
  63638. /**
  63639. * Gets the output component
  63640. */
  63641. get output(): NodeMaterialConnectionPoint;
  63642. protected _buildBlock(state: NodeMaterialBuildState): this;
  63643. }
  63644. }
  63645. declare module BABYLON {
  63646. /**
  63647. * Block used to subtract 2 vectors
  63648. */
  63649. export class SubtractBlock extends NodeMaterialBlock {
  63650. /**
  63651. * Creates a new SubtractBlock
  63652. * @param name defines the block name
  63653. */
  63654. constructor(name: string);
  63655. /**
  63656. * Gets the current class name
  63657. * @returns the class name
  63658. */
  63659. getClassName(): string;
  63660. /**
  63661. * Gets the left operand input component
  63662. */
  63663. get left(): NodeMaterialConnectionPoint;
  63664. /**
  63665. * Gets the right operand input component
  63666. */
  63667. get right(): NodeMaterialConnectionPoint;
  63668. /**
  63669. * Gets the output component
  63670. */
  63671. get output(): NodeMaterialConnectionPoint;
  63672. protected _buildBlock(state: NodeMaterialBuildState): this;
  63673. }
  63674. }
  63675. declare module BABYLON {
  63676. /**
  63677. * Block used to step a value
  63678. */
  63679. export class StepBlock extends NodeMaterialBlock {
  63680. /**
  63681. * Creates a new StepBlock
  63682. * @param name defines the block name
  63683. */
  63684. constructor(name: string);
  63685. /**
  63686. * Gets the current class name
  63687. * @returns the class name
  63688. */
  63689. getClassName(): string;
  63690. /**
  63691. * Gets the value operand input component
  63692. */
  63693. get value(): NodeMaterialConnectionPoint;
  63694. /**
  63695. * Gets the edge operand input component
  63696. */
  63697. get edge(): NodeMaterialConnectionPoint;
  63698. /**
  63699. * Gets the output component
  63700. */
  63701. get output(): NodeMaterialConnectionPoint;
  63702. protected _buildBlock(state: NodeMaterialBuildState): this;
  63703. }
  63704. }
  63705. declare module BABYLON {
  63706. /**
  63707. * Block used to get the opposite (1 - x) of a value
  63708. */
  63709. export class OneMinusBlock extends NodeMaterialBlock {
  63710. /**
  63711. * Creates a new OneMinusBlock
  63712. * @param name defines the block name
  63713. */
  63714. constructor(name: string);
  63715. /**
  63716. * Gets the current class name
  63717. * @returns the class name
  63718. */
  63719. getClassName(): string;
  63720. /**
  63721. * Gets the input component
  63722. */
  63723. get input(): NodeMaterialConnectionPoint;
  63724. /**
  63725. * Gets the output component
  63726. */
  63727. get output(): NodeMaterialConnectionPoint;
  63728. protected _buildBlock(state: NodeMaterialBuildState): this;
  63729. }
  63730. }
  63731. declare module BABYLON {
  63732. /**
  63733. * Block used to get the view direction
  63734. */
  63735. export class ViewDirectionBlock extends NodeMaterialBlock {
  63736. /**
  63737. * Creates a new ViewDirectionBlock
  63738. * @param name defines the block name
  63739. */
  63740. constructor(name: string);
  63741. /**
  63742. * Gets the current class name
  63743. * @returns the class name
  63744. */
  63745. getClassName(): string;
  63746. /**
  63747. * Gets the world position component
  63748. */
  63749. get worldPosition(): NodeMaterialConnectionPoint;
  63750. /**
  63751. * Gets the camera position component
  63752. */
  63753. get cameraPosition(): NodeMaterialConnectionPoint;
  63754. /**
  63755. * Gets the output component
  63756. */
  63757. get output(): NodeMaterialConnectionPoint;
  63758. autoConfigure(material: NodeMaterial): void;
  63759. protected _buildBlock(state: NodeMaterialBuildState): this;
  63760. }
  63761. }
  63762. declare module BABYLON {
  63763. /**
  63764. * Block used to compute fresnel value
  63765. */
  63766. export class FresnelBlock extends NodeMaterialBlock {
  63767. /**
  63768. * Create a new FresnelBlock
  63769. * @param name defines the block name
  63770. */
  63771. constructor(name: string);
  63772. /**
  63773. * Gets the current class name
  63774. * @returns the class name
  63775. */
  63776. getClassName(): string;
  63777. /**
  63778. * Gets the world normal input component
  63779. */
  63780. get worldNormal(): NodeMaterialConnectionPoint;
  63781. /**
  63782. * Gets the view direction input component
  63783. */
  63784. get viewDirection(): NodeMaterialConnectionPoint;
  63785. /**
  63786. * Gets the bias input component
  63787. */
  63788. get bias(): NodeMaterialConnectionPoint;
  63789. /**
  63790. * Gets the camera (or eye) position component
  63791. */
  63792. get power(): NodeMaterialConnectionPoint;
  63793. /**
  63794. * Gets the fresnel output component
  63795. */
  63796. get fresnel(): NodeMaterialConnectionPoint;
  63797. autoConfigure(material: NodeMaterial): void;
  63798. protected _buildBlock(state: NodeMaterialBuildState): this;
  63799. }
  63800. }
  63801. declare module BABYLON {
  63802. /**
  63803. * Block used to get the max of 2 values
  63804. */
  63805. export class MaxBlock extends NodeMaterialBlock {
  63806. /**
  63807. * Creates a new MaxBlock
  63808. * @param name defines the block name
  63809. */
  63810. constructor(name: string);
  63811. /**
  63812. * Gets the current class name
  63813. * @returns the class name
  63814. */
  63815. getClassName(): string;
  63816. /**
  63817. * Gets the left operand input component
  63818. */
  63819. get left(): NodeMaterialConnectionPoint;
  63820. /**
  63821. * Gets the right operand input component
  63822. */
  63823. get right(): NodeMaterialConnectionPoint;
  63824. /**
  63825. * Gets the output component
  63826. */
  63827. get output(): NodeMaterialConnectionPoint;
  63828. protected _buildBlock(state: NodeMaterialBuildState): this;
  63829. }
  63830. }
  63831. declare module BABYLON {
  63832. /**
  63833. * Block used to get the min of 2 values
  63834. */
  63835. export class MinBlock extends NodeMaterialBlock {
  63836. /**
  63837. * Creates a new MinBlock
  63838. * @param name defines the block name
  63839. */
  63840. constructor(name: string);
  63841. /**
  63842. * Gets the current class name
  63843. * @returns the class name
  63844. */
  63845. getClassName(): string;
  63846. /**
  63847. * Gets the left operand input component
  63848. */
  63849. get left(): NodeMaterialConnectionPoint;
  63850. /**
  63851. * Gets the right operand input component
  63852. */
  63853. get right(): NodeMaterialConnectionPoint;
  63854. /**
  63855. * Gets the output component
  63856. */
  63857. get output(): NodeMaterialConnectionPoint;
  63858. protected _buildBlock(state: NodeMaterialBuildState): this;
  63859. }
  63860. }
  63861. declare module BABYLON {
  63862. /**
  63863. * Block used to get the distance between 2 values
  63864. */
  63865. export class DistanceBlock extends NodeMaterialBlock {
  63866. /**
  63867. * Creates a new DistanceBlock
  63868. * @param name defines the block name
  63869. */
  63870. constructor(name: string);
  63871. /**
  63872. * Gets the current class name
  63873. * @returns the class name
  63874. */
  63875. getClassName(): string;
  63876. /**
  63877. * Gets the left operand input component
  63878. */
  63879. get left(): NodeMaterialConnectionPoint;
  63880. /**
  63881. * Gets the right operand input component
  63882. */
  63883. get right(): NodeMaterialConnectionPoint;
  63884. /**
  63885. * Gets the output component
  63886. */
  63887. get output(): NodeMaterialConnectionPoint;
  63888. protected _buildBlock(state: NodeMaterialBuildState): this;
  63889. }
  63890. }
  63891. declare module BABYLON {
  63892. /**
  63893. * Block used to get the length of a vector
  63894. */
  63895. export class LengthBlock extends NodeMaterialBlock {
  63896. /**
  63897. * Creates a new LengthBlock
  63898. * @param name defines the block name
  63899. */
  63900. constructor(name: string);
  63901. /**
  63902. * Gets the current class name
  63903. * @returns the class name
  63904. */
  63905. getClassName(): string;
  63906. /**
  63907. * Gets the value input component
  63908. */
  63909. get value(): NodeMaterialConnectionPoint;
  63910. /**
  63911. * Gets the output component
  63912. */
  63913. get output(): NodeMaterialConnectionPoint;
  63914. protected _buildBlock(state: NodeMaterialBuildState): this;
  63915. }
  63916. }
  63917. declare module BABYLON {
  63918. /**
  63919. * Block used to get negative version of a value (i.e. x * -1)
  63920. */
  63921. export class NegateBlock extends NodeMaterialBlock {
  63922. /**
  63923. * Creates a new NegateBlock
  63924. * @param name defines the block name
  63925. */
  63926. constructor(name: string);
  63927. /**
  63928. * Gets the current class name
  63929. * @returns the class name
  63930. */
  63931. getClassName(): string;
  63932. /**
  63933. * Gets the value input component
  63934. */
  63935. get value(): NodeMaterialConnectionPoint;
  63936. /**
  63937. * Gets the output component
  63938. */
  63939. get output(): NodeMaterialConnectionPoint;
  63940. protected _buildBlock(state: NodeMaterialBuildState): this;
  63941. }
  63942. }
  63943. declare module BABYLON {
  63944. /**
  63945. * Block used to get the value of the first parameter raised to the power of the second
  63946. */
  63947. export class PowBlock extends NodeMaterialBlock {
  63948. /**
  63949. * Creates a new PowBlock
  63950. * @param name defines the block name
  63951. */
  63952. constructor(name: string);
  63953. /**
  63954. * Gets the current class name
  63955. * @returns the class name
  63956. */
  63957. getClassName(): string;
  63958. /**
  63959. * Gets the value operand input component
  63960. */
  63961. get value(): NodeMaterialConnectionPoint;
  63962. /**
  63963. * Gets the power operand input component
  63964. */
  63965. get power(): NodeMaterialConnectionPoint;
  63966. /**
  63967. * Gets the output component
  63968. */
  63969. get output(): NodeMaterialConnectionPoint;
  63970. protected _buildBlock(state: NodeMaterialBuildState): this;
  63971. }
  63972. }
  63973. declare module BABYLON {
  63974. /**
  63975. * Block used to get a random number
  63976. */
  63977. export class RandomNumberBlock extends NodeMaterialBlock {
  63978. /**
  63979. * Creates a new RandomNumberBlock
  63980. * @param name defines the block name
  63981. */
  63982. constructor(name: string);
  63983. /**
  63984. * Gets the current class name
  63985. * @returns the class name
  63986. */
  63987. getClassName(): string;
  63988. /**
  63989. * Gets the seed input component
  63990. */
  63991. get seed(): NodeMaterialConnectionPoint;
  63992. /**
  63993. * Gets the output component
  63994. */
  63995. get output(): NodeMaterialConnectionPoint;
  63996. protected _buildBlock(state: NodeMaterialBuildState): this;
  63997. }
  63998. }
  63999. declare module BABYLON {
  64000. /**
  64001. * Block used to compute arc tangent of 2 values
  64002. */
  64003. export class ArcTan2Block extends NodeMaterialBlock {
  64004. /**
  64005. * Creates a new ArcTan2Block
  64006. * @param name defines the block name
  64007. */
  64008. constructor(name: string);
  64009. /**
  64010. * Gets the current class name
  64011. * @returns the class name
  64012. */
  64013. getClassName(): string;
  64014. /**
  64015. * Gets the x operand input component
  64016. */
  64017. get x(): NodeMaterialConnectionPoint;
  64018. /**
  64019. * Gets the y operand input component
  64020. */
  64021. get y(): NodeMaterialConnectionPoint;
  64022. /**
  64023. * Gets the output component
  64024. */
  64025. get output(): NodeMaterialConnectionPoint;
  64026. protected _buildBlock(state: NodeMaterialBuildState): this;
  64027. }
  64028. }
  64029. declare module BABYLON {
  64030. /**
  64031. * Block used to smooth step a value
  64032. */
  64033. export class SmoothStepBlock extends NodeMaterialBlock {
  64034. /**
  64035. * Creates a new SmoothStepBlock
  64036. * @param name defines the block name
  64037. */
  64038. constructor(name: string);
  64039. /**
  64040. * Gets the current class name
  64041. * @returns the class name
  64042. */
  64043. getClassName(): string;
  64044. /**
  64045. * Gets the value operand input component
  64046. */
  64047. get value(): NodeMaterialConnectionPoint;
  64048. /**
  64049. * Gets the first edge operand input component
  64050. */
  64051. get edge0(): NodeMaterialConnectionPoint;
  64052. /**
  64053. * Gets the second edge operand input component
  64054. */
  64055. get edge1(): NodeMaterialConnectionPoint;
  64056. /**
  64057. * Gets the output component
  64058. */
  64059. get output(): NodeMaterialConnectionPoint;
  64060. protected _buildBlock(state: NodeMaterialBuildState): this;
  64061. }
  64062. }
  64063. declare module BABYLON {
  64064. /**
  64065. * Block used to get the reciprocal (1 / x) of a value
  64066. */
  64067. export class ReciprocalBlock extends NodeMaterialBlock {
  64068. /**
  64069. * Creates a new ReciprocalBlock
  64070. * @param name defines the block name
  64071. */
  64072. constructor(name: string);
  64073. /**
  64074. * Gets the current class name
  64075. * @returns the class name
  64076. */
  64077. getClassName(): string;
  64078. /**
  64079. * Gets the input component
  64080. */
  64081. get input(): NodeMaterialConnectionPoint;
  64082. /**
  64083. * Gets the output component
  64084. */
  64085. get output(): NodeMaterialConnectionPoint;
  64086. protected _buildBlock(state: NodeMaterialBuildState): this;
  64087. }
  64088. }
  64089. declare module BABYLON {
  64090. /**
  64091. * Block used to replace a color by another one
  64092. */
  64093. export class ReplaceColorBlock extends NodeMaterialBlock {
  64094. /**
  64095. * Creates a new ReplaceColorBlock
  64096. * @param name defines the block name
  64097. */
  64098. constructor(name: string);
  64099. /**
  64100. * Gets the current class name
  64101. * @returns the class name
  64102. */
  64103. getClassName(): string;
  64104. /**
  64105. * Gets the value input component
  64106. */
  64107. get value(): NodeMaterialConnectionPoint;
  64108. /**
  64109. * Gets the reference input component
  64110. */
  64111. get reference(): NodeMaterialConnectionPoint;
  64112. /**
  64113. * Gets the distance input component
  64114. */
  64115. get distance(): NodeMaterialConnectionPoint;
  64116. /**
  64117. * Gets the replacement input component
  64118. */
  64119. get replacement(): NodeMaterialConnectionPoint;
  64120. /**
  64121. * Gets the output component
  64122. */
  64123. get output(): NodeMaterialConnectionPoint;
  64124. protected _buildBlock(state: NodeMaterialBuildState): this;
  64125. }
  64126. }
  64127. declare module BABYLON {
  64128. /**
  64129. * Block used to posterize a value
  64130. * @see https://en.wikipedia.org/wiki/Posterization
  64131. */
  64132. export class PosterizeBlock extends NodeMaterialBlock {
  64133. /**
  64134. * Creates a new PosterizeBlock
  64135. * @param name defines the block name
  64136. */
  64137. constructor(name: string);
  64138. /**
  64139. * Gets the current class name
  64140. * @returns the class name
  64141. */
  64142. getClassName(): string;
  64143. /**
  64144. * Gets the value input component
  64145. */
  64146. get value(): NodeMaterialConnectionPoint;
  64147. /**
  64148. * Gets the steps input component
  64149. */
  64150. get steps(): NodeMaterialConnectionPoint;
  64151. /**
  64152. * Gets the output component
  64153. */
  64154. get output(): NodeMaterialConnectionPoint;
  64155. protected _buildBlock(state: NodeMaterialBuildState): this;
  64156. }
  64157. }
  64158. declare module BABYLON {
  64159. /**
  64160. * Operations supported by the Wave block
  64161. */
  64162. export enum WaveBlockKind {
  64163. /** SawTooth */
  64164. SawTooth = 0,
  64165. /** Square */
  64166. Square = 1,
  64167. /** Triangle */
  64168. Triangle = 2
  64169. }
  64170. /**
  64171. * Block used to apply wave operation to floats
  64172. */
  64173. export class WaveBlock extends NodeMaterialBlock {
  64174. /**
  64175. * Gets or sets the kibnd of wave to be applied by the block
  64176. */
  64177. kind: WaveBlockKind;
  64178. /**
  64179. * Creates a new WaveBlock
  64180. * @param name defines the block name
  64181. */
  64182. constructor(name: string);
  64183. /**
  64184. * Gets the current class name
  64185. * @returns the class name
  64186. */
  64187. getClassName(): string;
  64188. /**
  64189. * Gets the input component
  64190. */
  64191. get input(): NodeMaterialConnectionPoint;
  64192. /**
  64193. * Gets the output component
  64194. */
  64195. get output(): NodeMaterialConnectionPoint;
  64196. protected _buildBlock(state: NodeMaterialBuildState): this;
  64197. serialize(): any;
  64198. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64199. }
  64200. }
  64201. declare module BABYLON {
  64202. /**
  64203. * Class used to store a color step for the GradientBlock
  64204. */
  64205. export class GradientBlockColorStep {
  64206. private _step;
  64207. /**
  64208. * Gets value indicating which step this color is associated with (between 0 and 1)
  64209. */
  64210. get step(): number;
  64211. /**
  64212. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64213. */
  64214. set step(val: number);
  64215. private _color;
  64216. /**
  64217. * Gets the color associated with this step
  64218. */
  64219. get color(): Color3;
  64220. /**
  64221. * Sets the color associated with this step
  64222. */
  64223. set color(val: Color3);
  64224. /**
  64225. * Creates a new GradientBlockColorStep
  64226. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64227. * @param color defines the color associated with this step
  64228. */
  64229. constructor(step: number, color: Color3);
  64230. }
  64231. /**
  64232. * Block used to return a color from a gradient based on an input value between 0 and 1
  64233. */
  64234. export class GradientBlock extends NodeMaterialBlock {
  64235. /**
  64236. * Gets or sets the list of color steps
  64237. */
  64238. colorSteps: GradientBlockColorStep[];
  64239. /** Gets an observable raised when the value is changed */
  64240. onValueChangedObservable: Observable<GradientBlock>;
  64241. /** calls observable when the value is changed*/
  64242. colorStepsUpdated(): void;
  64243. /**
  64244. * Creates a new GradientBlock
  64245. * @param name defines the block name
  64246. */
  64247. constructor(name: string);
  64248. /**
  64249. * Gets the current class name
  64250. * @returns the class name
  64251. */
  64252. getClassName(): string;
  64253. /**
  64254. * Gets the gradient input component
  64255. */
  64256. get gradient(): NodeMaterialConnectionPoint;
  64257. /**
  64258. * Gets the output component
  64259. */
  64260. get output(): NodeMaterialConnectionPoint;
  64261. private _writeColorConstant;
  64262. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64263. serialize(): any;
  64264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64265. protected _dumpPropertiesCode(): string;
  64266. }
  64267. }
  64268. declare module BABYLON {
  64269. /**
  64270. * Block used to normalize lerp between 2 values
  64271. */
  64272. export class NLerpBlock extends NodeMaterialBlock {
  64273. /**
  64274. * Creates a new NLerpBlock
  64275. * @param name defines the block name
  64276. */
  64277. constructor(name: string);
  64278. /**
  64279. * Gets the current class name
  64280. * @returns the class name
  64281. */
  64282. getClassName(): string;
  64283. /**
  64284. * Gets the left operand input component
  64285. */
  64286. get left(): NodeMaterialConnectionPoint;
  64287. /**
  64288. * Gets the right operand input component
  64289. */
  64290. get right(): NodeMaterialConnectionPoint;
  64291. /**
  64292. * Gets the gradient operand input component
  64293. */
  64294. get gradient(): NodeMaterialConnectionPoint;
  64295. /**
  64296. * Gets the output component
  64297. */
  64298. get output(): NodeMaterialConnectionPoint;
  64299. protected _buildBlock(state: NodeMaterialBuildState): this;
  64300. }
  64301. }
  64302. declare module BABYLON {
  64303. /**
  64304. * block used to Generate a Worley Noise 3D Noise Pattern
  64305. */
  64306. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64307. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64308. manhattanDistance: boolean;
  64309. /**
  64310. * Creates a new WorleyNoise3DBlock
  64311. * @param name defines the block name
  64312. */
  64313. constructor(name: string);
  64314. /**
  64315. * Gets the current class name
  64316. * @returns the class name
  64317. */
  64318. getClassName(): string;
  64319. /**
  64320. * Gets the seed input component
  64321. */
  64322. get seed(): NodeMaterialConnectionPoint;
  64323. /**
  64324. * Gets the jitter input component
  64325. */
  64326. get jitter(): NodeMaterialConnectionPoint;
  64327. /**
  64328. * Gets the output component
  64329. */
  64330. get output(): NodeMaterialConnectionPoint;
  64331. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64332. /**
  64333. * Exposes the properties to the UI?
  64334. */
  64335. protected _dumpPropertiesCode(): string;
  64336. /**
  64337. * Exposes the properties to the Seralize?
  64338. */
  64339. serialize(): any;
  64340. /**
  64341. * Exposes the properties to the deseralize?
  64342. */
  64343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64344. }
  64345. }
  64346. declare module BABYLON {
  64347. /**
  64348. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64349. */
  64350. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64351. /**
  64352. * Creates a new SimplexPerlin3DBlock
  64353. * @param name defines the block name
  64354. */
  64355. constructor(name: string);
  64356. /**
  64357. * Gets the current class name
  64358. * @returns the class name
  64359. */
  64360. getClassName(): string;
  64361. /**
  64362. * Gets the seed operand input component
  64363. */
  64364. get seed(): NodeMaterialConnectionPoint;
  64365. /**
  64366. * Gets the output component
  64367. */
  64368. get output(): NodeMaterialConnectionPoint;
  64369. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64370. }
  64371. }
  64372. declare module BABYLON {
  64373. /**
  64374. * Block used to blend normals
  64375. */
  64376. export class NormalBlendBlock extends NodeMaterialBlock {
  64377. /**
  64378. * Creates a new NormalBlendBlock
  64379. * @param name defines the block name
  64380. */
  64381. constructor(name: string);
  64382. /**
  64383. * Gets the current class name
  64384. * @returns the class name
  64385. */
  64386. getClassName(): string;
  64387. /**
  64388. * Gets the first input component
  64389. */
  64390. get normalMap0(): NodeMaterialConnectionPoint;
  64391. /**
  64392. * Gets the second input component
  64393. */
  64394. get normalMap1(): NodeMaterialConnectionPoint;
  64395. /**
  64396. * Gets the output component
  64397. */
  64398. get output(): NodeMaterialConnectionPoint;
  64399. protected _buildBlock(state: NodeMaterialBuildState): this;
  64400. }
  64401. }
  64402. declare module BABYLON {
  64403. /**
  64404. * Block used to rotate a 2d vector by a given angle
  64405. */
  64406. export class Rotate2dBlock extends NodeMaterialBlock {
  64407. /**
  64408. * Creates a new Rotate2dBlock
  64409. * @param name defines the block name
  64410. */
  64411. constructor(name: string);
  64412. /**
  64413. * Gets the current class name
  64414. * @returns the class name
  64415. */
  64416. getClassName(): string;
  64417. /**
  64418. * Gets the input vector
  64419. */
  64420. get input(): NodeMaterialConnectionPoint;
  64421. /**
  64422. * Gets the input angle
  64423. */
  64424. get angle(): NodeMaterialConnectionPoint;
  64425. /**
  64426. * Gets the output component
  64427. */
  64428. get output(): NodeMaterialConnectionPoint;
  64429. autoConfigure(material: NodeMaterial): void;
  64430. protected _buildBlock(state: NodeMaterialBuildState): this;
  64431. }
  64432. }
  64433. declare module BABYLON {
  64434. /**
  64435. * Block used to get the reflected vector from a direction and a normal
  64436. */
  64437. export class ReflectBlock extends NodeMaterialBlock {
  64438. /**
  64439. * Creates a new ReflectBlock
  64440. * @param name defines the block name
  64441. */
  64442. constructor(name: string);
  64443. /**
  64444. * Gets the current class name
  64445. * @returns the class name
  64446. */
  64447. getClassName(): string;
  64448. /**
  64449. * Gets the incident component
  64450. */
  64451. get incident(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the normal component
  64454. */
  64455. get normal(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the output component
  64458. */
  64459. get output(): NodeMaterialConnectionPoint;
  64460. protected _buildBlock(state: NodeMaterialBuildState): this;
  64461. }
  64462. }
  64463. declare module BABYLON {
  64464. /**
  64465. * Block used to get the refracted vector from a direction and a normal
  64466. */
  64467. export class RefractBlock extends NodeMaterialBlock {
  64468. /**
  64469. * Creates a new RefractBlock
  64470. * @param name defines the block name
  64471. */
  64472. constructor(name: string);
  64473. /**
  64474. * Gets the current class name
  64475. * @returns the class name
  64476. */
  64477. getClassName(): string;
  64478. /**
  64479. * Gets the incident component
  64480. */
  64481. get incident(): NodeMaterialConnectionPoint;
  64482. /**
  64483. * Gets the normal component
  64484. */
  64485. get normal(): NodeMaterialConnectionPoint;
  64486. /**
  64487. * Gets the index of refraction component
  64488. */
  64489. get ior(): NodeMaterialConnectionPoint;
  64490. /**
  64491. * Gets the output component
  64492. */
  64493. get output(): NodeMaterialConnectionPoint;
  64494. protected _buildBlock(state: NodeMaterialBuildState): this;
  64495. }
  64496. }
  64497. declare module BABYLON {
  64498. /**
  64499. * Block used to desaturate a color
  64500. */
  64501. export class DesaturateBlock extends NodeMaterialBlock {
  64502. /**
  64503. * Creates a new DesaturateBlock
  64504. * @param name defines the block name
  64505. */
  64506. constructor(name: string);
  64507. /**
  64508. * Gets the current class name
  64509. * @returns the class name
  64510. */
  64511. getClassName(): string;
  64512. /**
  64513. * Gets the color operand input component
  64514. */
  64515. get color(): NodeMaterialConnectionPoint;
  64516. /**
  64517. * Gets the level operand input component
  64518. */
  64519. get level(): NodeMaterialConnectionPoint;
  64520. /**
  64521. * Gets the output component
  64522. */
  64523. get output(): NodeMaterialConnectionPoint;
  64524. protected _buildBlock(state: NodeMaterialBuildState): this;
  64525. }
  64526. }
  64527. declare module BABYLON {
  64528. /**
  64529. * Block used to implement the ambient occlusion module of the PBR material
  64530. */
  64531. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64532. /**
  64533. * Create a new AmbientOcclusionBlock
  64534. * @param name defines the block name
  64535. */
  64536. constructor(name: string);
  64537. /**
  64538. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64539. */
  64540. useAmbientInGrayScale: boolean;
  64541. /**
  64542. * Initialize the block and prepare the context for build
  64543. * @param state defines the state that will be used for the build
  64544. */
  64545. initialize(state: NodeMaterialBuildState): void;
  64546. /**
  64547. * Gets the current class name
  64548. * @returns the class name
  64549. */
  64550. getClassName(): string;
  64551. /**
  64552. * Gets the texture input component
  64553. */
  64554. get texture(): NodeMaterialConnectionPoint;
  64555. /**
  64556. * Gets the texture intensity component
  64557. */
  64558. get intensity(): NodeMaterialConnectionPoint;
  64559. /**
  64560. * Gets the direct light intensity input component
  64561. */
  64562. get directLightIntensity(): NodeMaterialConnectionPoint;
  64563. /**
  64564. * Gets the ambient occlusion object output component
  64565. */
  64566. get ambientOcc(): NodeMaterialConnectionPoint;
  64567. /**
  64568. * Gets the main code of the block (fragment side)
  64569. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64570. * @returns the shader code
  64571. */
  64572. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64573. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64574. protected _buildBlock(state: NodeMaterialBuildState): this;
  64575. protected _dumpPropertiesCode(): string;
  64576. serialize(): any;
  64577. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64578. }
  64579. }
  64580. declare module BABYLON {
  64581. /**
  64582. * Block used to implement the reflection module of the PBR material
  64583. */
  64584. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64585. /** @hidden */
  64586. _defineLODReflectionAlpha: string;
  64587. /** @hidden */
  64588. _defineLinearSpecularReflection: string;
  64589. private _vEnvironmentIrradianceName;
  64590. /** @hidden */
  64591. _vReflectionMicrosurfaceInfosName: string;
  64592. /** @hidden */
  64593. _vReflectionInfosName: string;
  64594. /** @hidden */
  64595. _vReflectionFilteringInfoName: string;
  64596. private _scene;
  64597. /**
  64598. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64599. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64600. * It's less burden on the user side in the editor part.
  64601. */
  64602. /** @hidden */
  64603. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64604. /** @hidden */
  64605. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64606. /** @hidden */
  64607. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64608. /**
  64609. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64610. * diffuse part of the IBL.
  64611. */
  64612. useSphericalHarmonics: boolean;
  64613. /**
  64614. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64615. */
  64616. forceIrradianceInFragment: boolean;
  64617. /**
  64618. * Create a new ReflectionBlock
  64619. * @param name defines the block name
  64620. */
  64621. constructor(name: string);
  64622. /**
  64623. * Gets the current class name
  64624. * @returns the class name
  64625. */
  64626. getClassName(): string;
  64627. /**
  64628. * Gets the position input component
  64629. */
  64630. get position(): NodeMaterialConnectionPoint;
  64631. /**
  64632. * Gets the world position input component
  64633. */
  64634. get worldPosition(): NodeMaterialConnectionPoint;
  64635. /**
  64636. * Gets the world normal input component
  64637. */
  64638. get worldNormal(): NodeMaterialConnectionPoint;
  64639. /**
  64640. * Gets the world input component
  64641. */
  64642. get world(): NodeMaterialConnectionPoint;
  64643. /**
  64644. * Gets the camera (or eye) position component
  64645. */
  64646. get cameraPosition(): NodeMaterialConnectionPoint;
  64647. /**
  64648. * Gets the view input component
  64649. */
  64650. get view(): NodeMaterialConnectionPoint;
  64651. /**
  64652. * Gets the color input component
  64653. */
  64654. get color(): NodeMaterialConnectionPoint;
  64655. /**
  64656. * Gets the reflection object output component
  64657. */
  64658. get reflection(): NodeMaterialConnectionPoint;
  64659. /**
  64660. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64661. */
  64662. get hasTexture(): boolean;
  64663. /**
  64664. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64665. */
  64666. get reflectionColor(): string;
  64667. protected _getTexture(): Nullable<BaseTexture>;
  64668. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64669. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64670. /**
  64671. * Gets the code to inject in the vertex shader
  64672. * @param state current state of the node material building
  64673. * @returns the shader code
  64674. */
  64675. handleVertexSide(state: NodeMaterialBuildState): string;
  64676. /**
  64677. * Gets the main code of the block (fragment side)
  64678. * @param state current state of the node material building
  64679. * @param normalVarName name of the existing variable corresponding to the normal
  64680. * @returns the shader code
  64681. */
  64682. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64683. protected _buildBlock(state: NodeMaterialBuildState): this;
  64684. protected _dumpPropertiesCode(): string;
  64685. serialize(): any;
  64686. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64687. }
  64688. }
  64689. declare module BABYLON {
  64690. /**
  64691. * Block used to implement the sheen module of the PBR material
  64692. */
  64693. export class SheenBlock extends NodeMaterialBlock {
  64694. /**
  64695. * Create a new SheenBlock
  64696. * @param name defines the block name
  64697. */
  64698. constructor(name: string);
  64699. /**
  64700. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  64701. * It allows the strength of the sheen effect to not depend on the base color of the material,
  64702. * making it easier to setup and tweak the effect
  64703. */
  64704. albedoScaling: boolean;
  64705. /**
  64706. * Defines if the sheen is linked to the sheen color.
  64707. */
  64708. linkSheenWithAlbedo: boolean;
  64709. /**
  64710. * Initialize the block and prepare the context for build
  64711. * @param state defines the state that will be used for the build
  64712. */
  64713. initialize(state: NodeMaterialBuildState): void;
  64714. /**
  64715. * Gets the current class name
  64716. * @returns the class name
  64717. */
  64718. getClassName(): string;
  64719. /**
  64720. * Gets the intensity input component
  64721. */
  64722. get intensity(): NodeMaterialConnectionPoint;
  64723. /**
  64724. * Gets the color input component
  64725. */
  64726. get color(): NodeMaterialConnectionPoint;
  64727. /**
  64728. * Gets the roughness input component
  64729. */
  64730. get roughness(): NodeMaterialConnectionPoint;
  64731. /**
  64732. * Gets the sheen object output component
  64733. */
  64734. get sheen(): NodeMaterialConnectionPoint;
  64735. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64736. /**
  64737. * Gets the main code of the block (fragment side)
  64738. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64739. * @returns the shader code
  64740. */
  64741. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  64742. protected _buildBlock(state: NodeMaterialBuildState): this;
  64743. protected _dumpPropertiesCode(): string;
  64744. serialize(): any;
  64745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64746. }
  64747. }
  64748. declare module BABYLON {
  64749. /**
  64750. * Block used to implement the reflectivity module of the PBR material
  64751. */
  64752. export class ReflectivityBlock extends NodeMaterialBlock {
  64753. private _metallicReflectanceColor;
  64754. private _metallicF0Factor;
  64755. /** @hidden */
  64756. _vMetallicReflectanceFactorsName: string;
  64757. /**
  64758. * The property below is set by the main PBR block prior to calling methods of this class.
  64759. */
  64760. /** @hidden */
  64761. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  64762. /**
  64763. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  64764. */
  64765. useAmbientOcclusionFromMetallicTextureRed: boolean;
  64766. /**
  64767. * Specifies if the metallic texture contains the metallness information in its blue channel.
  64768. */
  64769. useMetallnessFromMetallicTextureBlue: boolean;
  64770. /**
  64771. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  64772. */
  64773. useRoughnessFromMetallicTextureAlpha: boolean;
  64774. /**
  64775. * Specifies if the metallic texture contains the roughness information in its green channel.
  64776. */
  64777. useRoughnessFromMetallicTextureGreen: boolean;
  64778. /**
  64779. * Create a new ReflectivityBlock
  64780. * @param name defines the block name
  64781. */
  64782. constructor(name: string);
  64783. /**
  64784. * Initialize the block and prepare the context for build
  64785. * @param state defines the state that will be used for the build
  64786. */
  64787. initialize(state: NodeMaterialBuildState): void;
  64788. /**
  64789. * Gets the current class name
  64790. * @returns the class name
  64791. */
  64792. getClassName(): string;
  64793. /**
  64794. * Gets the metallic input component
  64795. */
  64796. get metallic(): NodeMaterialConnectionPoint;
  64797. /**
  64798. * Gets the roughness input component
  64799. */
  64800. get roughness(): NodeMaterialConnectionPoint;
  64801. /**
  64802. * Gets the texture input component
  64803. */
  64804. get texture(): NodeMaterialConnectionPoint;
  64805. /**
  64806. * Gets the reflectivity object output component
  64807. */
  64808. get reflectivity(): NodeMaterialConnectionPoint;
  64809. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64810. /**
  64811. * Gets the main code of the block (fragment side)
  64812. * @param state current state of the node material building
  64813. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  64814. * @returns the shader code
  64815. */
  64816. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  64817. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64818. protected _buildBlock(state: NodeMaterialBuildState): this;
  64819. protected _dumpPropertiesCode(): string;
  64820. serialize(): any;
  64821. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64822. }
  64823. }
  64824. declare module BABYLON {
  64825. /**
  64826. * Block used to implement the anisotropy module of the PBR material
  64827. */
  64828. export class AnisotropyBlock extends NodeMaterialBlock {
  64829. /**
  64830. * The two properties below are set by the main PBR block prior to calling methods of this class.
  64831. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64832. * It's less burden on the user side in the editor part.
  64833. */
  64834. /** @hidden */
  64835. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64836. /** @hidden */
  64837. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64838. /**
  64839. * Create a new AnisotropyBlock
  64840. * @param name defines the block name
  64841. */
  64842. constructor(name: string);
  64843. /**
  64844. * Initialize the block and prepare the context for build
  64845. * @param state defines the state that will be used for the build
  64846. */
  64847. initialize(state: NodeMaterialBuildState): void;
  64848. /**
  64849. * Gets the current class name
  64850. * @returns the class name
  64851. */
  64852. getClassName(): string;
  64853. /**
  64854. * Gets the intensity input component
  64855. */
  64856. get intensity(): NodeMaterialConnectionPoint;
  64857. /**
  64858. * Gets the direction input component
  64859. */
  64860. get direction(): NodeMaterialConnectionPoint;
  64861. /**
  64862. * Gets the texture input component
  64863. */
  64864. get texture(): NodeMaterialConnectionPoint;
  64865. /**
  64866. * Gets the uv input component
  64867. */
  64868. get uv(): NodeMaterialConnectionPoint;
  64869. /**
  64870. * Gets the worldTangent input component
  64871. */
  64872. get worldTangent(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the anisotropy object output component
  64875. */
  64876. get anisotropy(): NodeMaterialConnectionPoint;
  64877. private _generateTBNSpace;
  64878. /**
  64879. * Gets the main code of the block (fragment side)
  64880. * @param state current state of the node material building
  64881. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64882. * @returns the shader code
  64883. */
  64884. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  64885. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64886. protected _buildBlock(state: NodeMaterialBuildState): this;
  64887. }
  64888. }
  64889. declare module BABYLON {
  64890. /**
  64891. * Block used to implement the clear coat module of the PBR material
  64892. */
  64893. export class ClearCoatBlock extends NodeMaterialBlock {
  64894. private _scene;
  64895. /**
  64896. * Create a new ClearCoatBlock
  64897. * @param name defines the block name
  64898. */
  64899. constructor(name: string);
  64900. /**
  64901. * Initialize the block and prepare the context for build
  64902. * @param state defines the state that will be used for the build
  64903. */
  64904. initialize(state: NodeMaterialBuildState): void;
  64905. /**
  64906. * Gets the current class name
  64907. * @returns the class name
  64908. */
  64909. getClassName(): string;
  64910. /**
  64911. * Gets the intensity input component
  64912. */
  64913. get intensity(): NodeMaterialConnectionPoint;
  64914. /**
  64915. * Gets the roughness input component
  64916. */
  64917. get roughness(): NodeMaterialConnectionPoint;
  64918. /**
  64919. * Gets the ior input component
  64920. */
  64921. get ior(): NodeMaterialConnectionPoint;
  64922. /**
  64923. * Gets the texture input component
  64924. */
  64925. get texture(): NodeMaterialConnectionPoint;
  64926. /**
  64927. * Gets the bump texture input component
  64928. */
  64929. get bumpTexture(): NodeMaterialConnectionPoint;
  64930. /**
  64931. * Gets the uv input component
  64932. */
  64933. get uv(): NodeMaterialConnectionPoint;
  64934. /**
  64935. * Gets the tint color input component
  64936. */
  64937. get tintColor(): NodeMaterialConnectionPoint;
  64938. /**
  64939. * Gets the tint "at distance" input component
  64940. */
  64941. get tintAtDistance(): NodeMaterialConnectionPoint;
  64942. /**
  64943. * Gets the tint thickness input component
  64944. */
  64945. get tintThickness(): NodeMaterialConnectionPoint;
  64946. /**
  64947. * Gets the world tangent input component
  64948. */
  64949. get worldTangent(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the clear coat object output component
  64952. */
  64953. get clearcoat(): NodeMaterialConnectionPoint;
  64954. autoConfigure(material: NodeMaterial): void;
  64955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64957. private _generateTBNSpace;
  64958. /**
  64959. * Gets the main code of the block (fragment side)
  64960. * @param state current state of the node material building
  64961. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  64962. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  64963. * @param worldPosVarName name of the variable holding the world position
  64964. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  64965. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  64966. * @param worldNormalVarName name of the variable holding the world normal
  64967. * @returns the shader code
  64968. */
  64969. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  64970. protected _buildBlock(state: NodeMaterialBuildState): this;
  64971. }
  64972. }
  64973. declare module BABYLON {
  64974. /**
  64975. * Block used to implement the sub surface module of the PBR material
  64976. */
  64977. export class SubSurfaceBlock extends NodeMaterialBlock {
  64978. /**
  64979. * Create a new SubSurfaceBlock
  64980. * @param name defines the block name
  64981. */
  64982. constructor(name: string);
  64983. /**
  64984. * Stores the intensity of the different subsurface effects in the thickness texture.
  64985. * * the green channel is the translucency intensity.
  64986. * * the blue channel is the scattering intensity.
  64987. * * the alpha channel is the refraction intensity.
  64988. */
  64989. useMaskFromThicknessTexture: boolean;
  64990. /**
  64991. * Initialize the block and prepare the context for build
  64992. * @param state defines the state that will be used for the build
  64993. */
  64994. initialize(state: NodeMaterialBuildState): void;
  64995. /**
  64996. * Gets the current class name
  64997. * @returns the class name
  64998. */
  64999. getClassName(): string;
  65000. /**
  65001. * Gets the min thickness input component
  65002. */
  65003. get minThickness(): NodeMaterialConnectionPoint;
  65004. /**
  65005. * Gets the max thickness input component
  65006. */
  65007. get maxThickness(): NodeMaterialConnectionPoint;
  65008. /**
  65009. * Gets the thickness texture component
  65010. */
  65011. get thicknessTexture(): NodeMaterialConnectionPoint;
  65012. /**
  65013. * Gets the tint color input component
  65014. */
  65015. get tintColor(): NodeMaterialConnectionPoint;
  65016. /**
  65017. * Gets the translucency intensity input component
  65018. */
  65019. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65020. /**
  65021. * Gets the translucency diffusion distance input component
  65022. */
  65023. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65024. /**
  65025. * Gets the refraction object parameters
  65026. */
  65027. get refraction(): NodeMaterialConnectionPoint;
  65028. /**
  65029. * Gets the sub surface object output component
  65030. */
  65031. get subsurface(): NodeMaterialConnectionPoint;
  65032. autoConfigure(material: NodeMaterial): void;
  65033. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65034. /**
  65035. * Gets the main code of the block (fragment side)
  65036. * @param state current state of the node material building
  65037. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65038. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65039. * @param worldPosVarName name of the variable holding the world position
  65040. * @returns the shader code
  65041. */
  65042. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65043. protected _buildBlock(state: NodeMaterialBuildState): this;
  65044. }
  65045. }
  65046. declare module BABYLON {
  65047. /**
  65048. * Block used to implement the PBR metallic/roughness model
  65049. */
  65050. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65051. /**
  65052. * Gets or sets the light associated with this block
  65053. */
  65054. light: Nullable<Light>;
  65055. private _lightId;
  65056. private _scene;
  65057. private _environmentBRDFTexture;
  65058. private _environmentBrdfSamplerName;
  65059. private _vNormalWName;
  65060. private _invertNormalName;
  65061. /**
  65062. * Create a new ReflectionBlock
  65063. * @param name defines the block name
  65064. */
  65065. constructor(name: string);
  65066. /**
  65067. * Intensity of the direct lights e.g. the four lights available in your scene.
  65068. * This impacts both the direct diffuse and specular highlights.
  65069. */
  65070. directIntensity: number;
  65071. /**
  65072. * Intensity of the environment e.g. how much the environment will light the object
  65073. * either through harmonics for rough material or through the refelction for shiny ones.
  65074. */
  65075. environmentIntensity: number;
  65076. /**
  65077. * This is a special control allowing the reduction of the specular highlights coming from the
  65078. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65079. */
  65080. specularIntensity: number;
  65081. /**
  65082. * Defines the falloff type used in this material.
  65083. * It by default is Physical.
  65084. */
  65085. lightFalloff: number;
  65086. /**
  65087. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65088. */
  65089. useAlphaFromAlbedoTexture: boolean;
  65090. /**
  65091. * Specifies that alpha test should be used
  65092. */
  65093. useAlphaTest: boolean;
  65094. /**
  65095. * Defines the alpha limits in alpha test mode.
  65096. */
  65097. alphaTestCutoff: number;
  65098. /**
  65099. * Specifies that alpha blending should be used
  65100. */
  65101. useAlphaBlending: boolean;
  65102. /**
  65103. * Defines if the alpha value should be determined via the rgb values.
  65104. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65105. */
  65106. opacityRGB: boolean;
  65107. /**
  65108. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65109. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65110. */
  65111. useRadianceOverAlpha: boolean;
  65112. /**
  65113. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65114. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65115. */
  65116. useSpecularOverAlpha: boolean;
  65117. /**
  65118. * Enables specular anti aliasing in the PBR shader.
  65119. * It will both interacts on the Geometry for analytical and IBL lighting.
  65120. * It also prefilter the roughness map based on the bump values.
  65121. */
  65122. enableSpecularAntiAliasing: boolean;
  65123. /**
  65124. * Enables realtime filtering on the texture.
  65125. */
  65126. realTimeFiltering: boolean;
  65127. /**
  65128. * Quality switch for realtime filtering
  65129. */
  65130. realTimeFilteringQuality: number;
  65131. /**
  65132. * Defines if the material uses energy conservation.
  65133. */
  65134. useEnergyConservation: boolean;
  65135. /**
  65136. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65137. * too much the area relying on ambient texture to define their ambient occlusion.
  65138. */
  65139. useRadianceOcclusion: boolean;
  65140. /**
  65141. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65142. * makes the reflect vector face the model (under horizon).
  65143. */
  65144. useHorizonOcclusion: boolean;
  65145. /**
  65146. * If set to true, no lighting calculations will be applied.
  65147. */
  65148. unlit: boolean;
  65149. /**
  65150. * Force normal to face away from face.
  65151. */
  65152. forceNormalForward: boolean;
  65153. /**
  65154. * Defines the material debug mode.
  65155. * It helps seeing only some components of the material while troubleshooting.
  65156. */
  65157. debugMode: number;
  65158. /**
  65159. * Specify from where on screen the debug mode should start.
  65160. * The value goes from -1 (full screen) to 1 (not visible)
  65161. * It helps with side by side comparison against the final render
  65162. * This defaults to 0
  65163. */
  65164. debugLimit: number;
  65165. /**
  65166. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65167. * You can use the factor to better multiply the final value.
  65168. */
  65169. debugFactor: number;
  65170. /**
  65171. * Initialize the block and prepare the context for build
  65172. * @param state defines the state that will be used for the build
  65173. */
  65174. initialize(state: NodeMaterialBuildState): void;
  65175. /**
  65176. * Gets the current class name
  65177. * @returns the class name
  65178. */
  65179. getClassName(): string;
  65180. /**
  65181. * Gets the world position input component
  65182. */
  65183. get worldPosition(): NodeMaterialConnectionPoint;
  65184. /**
  65185. * Gets the world normal input component
  65186. */
  65187. get worldNormal(): NodeMaterialConnectionPoint;
  65188. /**
  65189. * Gets the perturbed normal input component
  65190. */
  65191. get perturbedNormal(): NodeMaterialConnectionPoint;
  65192. /**
  65193. * Gets the camera position input component
  65194. */
  65195. get cameraPosition(): NodeMaterialConnectionPoint;
  65196. /**
  65197. * Gets the base color input component
  65198. */
  65199. get baseColor(): NodeMaterialConnectionPoint;
  65200. /**
  65201. * Gets the opacity texture input component
  65202. */
  65203. get opacityTexture(): NodeMaterialConnectionPoint;
  65204. /**
  65205. * Gets the ambient color input component
  65206. */
  65207. get ambientColor(): NodeMaterialConnectionPoint;
  65208. /**
  65209. * Gets the reflectivity object parameters
  65210. */
  65211. get reflectivity(): NodeMaterialConnectionPoint;
  65212. /**
  65213. * Gets the ambient occlusion object parameters
  65214. */
  65215. get ambientOcc(): NodeMaterialConnectionPoint;
  65216. /**
  65217. * Gets the reflection object parameters
  65218. */
  65219. get reflection(): NodeMaterialConnectionPoint;
  65220. /**
  65221. * Gets the sheen object parameters
  65222. */
  65223. get sheen(): NodeMaterialConnectionPoint;
  65224. /**
  65225. * Gets the clear coat object parameters
  65226. */
  65227. get clearcoat(): NodeMaterialConnectionPoint;
  65228. /**
  65229. * Gets the sub surface object parameters
  65230. */
  65231. get subsurface(): NodeMaterialConnectionPoint;
  65232. /**
  65233. * Gets the anisotropy object parameters
  65234. */
  65235. get anisotropy(): NodeMaterialConnectionPoint;
  65236. /**
  65237. * Gets the ambient output component
  65238. */
  65239. get ambient(): NodeMaterialConnectionPoint;
  65240. /**
  65241. * Gets the diffuse output component
  65242. */
  65243. get diffuse(): NodeMaterialConnectionPoint;
  65244. /**
  65245. * Gets the specular output component
  65246. */
  65247. get specular(): NodeMaterialConnectionPoint;
  65248. /**
  65249. * Gets the sheen output component
  65250. */
  65251. get sheenDir(): NodeMaterialConnectionPoint;
  65252. /**
  65253. * Gets the clear coat output component
  65254. */
  65255. get clearcoatDir(): NodeMaterialConnectionPoint;
  65256. /**
  65257. * Gets the indirect diffuse output component
  65258. */
  65259. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65260. /**
  65261. * Gets the indirect specular output component
  65262. */
  65263. get specularIndirect(): NodeMaterialConnectionPoint;
  65264. /**
  65265. * Gets the indirect sheen output component
  65266. */
  65267. get sheenIndirect(): NodeMaterialConnectionPoint;
  65268. /**
  65269. * Gets the indirect clear coat output component
  65270. */
  65271. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65272. /**
  65273. * Gets the refraction output component
  65274. */
  65275. get refraction(): NodeMaterialConnectionPoint;
  65276. /**
  65277. * Gets the global lighting output component
  65278. */
  65279. get lighting(): NodeMaterialConnectionPoint;
  65280. /**
  65281. * Gets the shadow output component
  65282. */
  65283. get shadow(): NodeMaterialConnectionPoint;
  65284. /**
  65285. * Gets the alpha output component
  65286. */
  65287. get alpha(): NodeMaterialConnectionPoint;
  65288. autoConfigure(material: NodeMaterial): void;
  65289. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65290. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65292. private _injectVertexCode;
  65293. /**
  65294. * Gets the code corresponding to the albedo/opacity module
  65295. * @returns the shader code
  65296. */
  65297. getAlbedoOpacityCode(): string;
  65298. protected _buildBlock(state: NodeMaterialBuildState): this;
  65299. protected _dumpPropertiesCode(): string;
  65300. serialize(): any;
  65301. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65302. }
  65303. }
  65304. declare module BABYLON {
  65305. /**
  65306. * Block used to compute value of one parameter modulo another
  65307. */
  65308. export class ModBlock extends NodeMaterialBlock {
  65309. /**
  65310. * Creates a new ModBlock
  65311. * @param name defines the block name
  65312. */
  65313. constructor(name: string);
  65314. /**
  65315. * Gets the current class name
  65316. * @returns the class name
  65317. */
  65318. getClassName(): string;
  65319. /**
  65320. * Gets the left operand input component
  65321. */
  65322. get left(): NodeMaterialConnectionPoint;
  65323. /**
  65324. * Gets the right operand input component
  65325. */
  65326. get right(): NodeMaterialConnectionPoint;
  65327. /**
  65328. * Gets the output component
  65329. */
  65330. get output(): NodeMaterialConnectionPoint;
  65331. protected _buildBlock(state: NodeMaterialBuildState): this;
  65332. }
  65333. }
  65334. declare module BABYLON {
  65335. /**
  65336. * Configuration for Draco compression
  65337. */
  65338. export interface IDracoCompressionConfiguration {
  65339. /**
  65340. * Configuration for the decoder.
  65341. */
  65342. decoder: {
  65343. /**
  65344. * The url to the WebAssembly module.
  65345. */
  65346. wasmUrl?: string;
  65347. /**
  65348. * The url to the WebAssembly binary.
  65349. */
  65350. wasmBinaryUrl?: string;
  65351. /**
  65352. * The url to the fallback JavaScript module.
  65353. */
  65354. fallbackUrl?: string;
  65355. };
  65356. }
  65357. /**
  65358. * Draco compression (https://google.github.io/draco/)
  65359. *
  65360. * This class wraps the Draco module.
  65361. *
  65362. * **Encoder**
  65363. *
  65364. * The encoder is not currently implemented.
  65365. *
  65366. * **Decoder**
  65367. *
  65368. * 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.
  65369. *
  65370. * To update the configuration, use the following code:
  65371. * ```javascript
  65372. * DracoCompression.Configuration = {
  65373. * decoder: {
  65374. * wasmUrl: "<url to the WebAssembly library>",
  65375. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65376. * fallbackUrl: "<url to the fallback JavaScript library>",
  65377. * }
  65378. * };
  65379. * ```
  65380. *
  65381. * 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.
  65382. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65383. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65384. *
  65385. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65386. * ```javascript
  65387. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65388. * ```
  65389. *
  65390. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65391. */
  65392. export class DracoCompression implements IDisposable {
  65393. private _workerPoolPromise?;
  65394. private _decoderModulePromise?;
  65395. /**
  65396. * The configuration. Defaults to the following urls:
  65397. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65398. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65399. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65400. */
  65401. static Configuration: IDracoCompressionConfiguration;
  65402. /**
  65403. * Returns true if the decoder configuration is available.
  65404. */
  65405. static get DecoderAvailable(): boolean;
  65406. /**
  65407. * Default number of workers to create when creating the draco compression object.
  65408. */
  65409. static DefaultNumWorkers: number;
  65410. private static GetDefaultNumWorkers;
  65411. private static _Default;
  65412. /**
  65413. * Default instance for the draco compression object.
  65414. */
  65415. static get Default(): DracoCompression;
  65416. /**
  65417. * Constructor
  65418. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65419. */
  65420. constructor(numWorkers?: number);
  65421. /**
  65422. * Stop all async operations and release resources.
  65423. */
  65424. dispose(): void;
  65425. /**
  65426. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65427. * @returns a promise that resolves when ready
  65428. */
  65429. whenReadyAsync(): Promise<void>;
  65430. /**
  65431. * Decode Draco compressed mesh data to vertex data.
  65432. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65433. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65434. * @returns A promise that resolves with the decoded vertex data
  65435. */
  65436. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65437. [kind: string]: number;
  65438. }): Promise<VertexData>;
  65439. }
  65440. }
  65441. declare module BABYLON {
  65442. /**
  65443. * Class for building Constructive Solid Geometry
  65444. */
  65445. export class CSG {
  65446. private polygons;
  65447. /**
  65448. * The world matrix
  65449. */
  65450. matrix: Matrix;
  65451. /**
  65452. * Stores the position
  65453. */
  65454. position: Vector3;
  65455. /**
  65456. * Stores the rotation
  65457. */
  65458. rotation: Vector3;
  65459. /**
  65460. * Stores the rotation quaternion
  65461. */
  65462. rotationQuaternion: Nullable<Quaternion>;
  65463. /**
  65464. * Stores the scaling vector
  65465. */
  65466. scaling: Vector3;
  65467. /**
  65468. * Convert the Mesh to CSG
  65469. * @param mesh The Mesh to convert to CSG
  65470. * @returns A new CSG from the Mesh
  65471. */
  65472. static FromMesh(mesh: Mesh): CSG;
  65473. /**
  65474. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65475. * @param polygons Polygons used to construct a CSG solid
  65476. */
  65477. private static FromPolygons;
  65478. /**
  65479. * Clones, or makes a deep copy, of the CSG
  65480. * @returns A new CSG
  65481. */
  65482. clone(): CSG;
  65483. /**
  65484. * Unions this CSG with another CSG
  65485. * @param csg The CSG to union against this CSG
  65486. * @returns The unioned CSG
  65487. */
  65488. union(csg: CSG): CSG;
  65489. /**
  65490. * Unions this CSG with another CSG in place
  65491. * @param csg The CSG to union against this CSG
  65492. */
  65493. unionInPlace(csg: CSG): void;
  65494. /**
  65495. * Subtracts this CSG with another CSG
  65496. * @param csg The CSG to subtract against this CSG
  65497. * @returns A new CSG
  65498. */
  65499. subtract(csg: CSG): CSG;
  65500. /**
  65501. * Subtracts this CSG with another CSG in place
  65502. * @param csg The CSG to subtact against this CSG
  65503. */
  65504. subtractInPlace(csg: CSG): void;
  65505. /**
  65506. * Intersect this CSG with another CSG
  65507. * @param csg The CSG to intersect against this CSG
  65508. * @returns A new CSG
  65509. */
  65510. intersect(csg: CSG): CSG;
  65511. /**
  65512. * Intersects this CSG with another CSG in place
  65513. * @param csg The CSG to intersect against this CSG
  65514. */
  65515. intersectInPlace(csg: CSG): void;
  65516. /**
  65517. * Return a new CSG solid with solid and empty space switched. This solid is
  65518. * not modified.
  65519. * @returns A new CSG solid with solid and empty space switched
  65520. */
  65521. inverse(): CSG;
  65522. /**
  65523. * Inverses the CSG in place
  65524. */
  65525. inverseInPlace(): void;
  65526. /**
  65527. * This is used to keep meshes transformations so they can be restored
  65528. * when we build back a Babylon Mesh
  65529. * NB : All CSG operations are performed in world coordinates
  65530. * @param csg The CSG to copy the transform attributes from
  65531. * @returns This CSG
  65532. */
  65533. copyTransformAttributes(csg: CSG): CSG;
  65534. /**
  65535. * Build Raw mesh from CSG
  65536. * Coordinates here are in world space
  65537. * @param name The name of the mesh geometry
  65538. * @param scene The Scene
  65539. * @param keepSubMeshes Specifies if the submeshes should be kept
  65540. * @returns A new Mesh
  65541. */
  65542. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65543. /**
  65544. * Build Mesh from CSG taking material and transforms into account
  65545. * @param name The name of the Mesh
  65546. * @param material The material of the Mesh
  65547. * @param scene The Scene
  65548. * @param keepSubMeshes Specifies if submeshes should be kept
  65549. * @returns The new Mesh
  65550. */
  65551. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65552. }
  65553. }
  65554. declare module BABYLON {
  65555. /**
  65556. * Class used to create a trail following a mesh
  65557. */
  65558. export class TrailMesh extends Mesh {
  65559. private _generator;
  65560. private _autoStart;
  65561. private _running;
  65562. private _diameter;
  65563. private _length;
  65564. private _sectionPolygonPointsCount;
  65565. private _sectionVectors;
  65566. private _sectionNormalVectors;
  65567. private _beforeRenderObserver;
  65568. /**
  65569. * @constructor
  65570. * @param name The value used by scene.getMeshByName() to do a lookup.
  65571. * @param generator The mesh or transform node to generate a trail.
  65572. * @param scene The scene to add this mesh to.
  65573. * @param diameter Diameter of trailing mesh. Default is 1.
  65574. * @param length Length of trailing mesh. Default is 60.
  65575. * @param autoStart Automatically start trailing mesh. Default true.
  65576. */
  65577. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65578. /**
  65579. * "TrailMesh"
  65580. * @returns "TrailMesh"
  65581. */
  65582. getClassName(): string;
  65583. private _createMesh;
  65584. /**
  65585. * Start trailing mesh.
  65586. */
  65587. start(): void;
  65588. /**
  65589. * Stop trailing mesh.
  65590. */
  65591. stop(): void;
  65592. /**
  65593. * Update trailing mesh geometry.
  65594. */
  65595. update(): void;
  65596. /**
  65597. * Returns a new TrailMesh object.
  65598. * @param name is a string, the name given to the new mesh
  65599. * @param newGenerator use new generator object for cloned trail mesh
  65600. * @returns a new mesh
  65601. */
  65602. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65603. /**
  65604. * Serializes this trail mesh
  65605. * @param serializationObject object to write serialization to
  65606. */
  65607. serialize(serializationObject: any): void;
  65608. /**
  65609. * Parses a serialized trail mesh
  65610. * @param parsedMesh the serialized mesh
  65611. * @param scene the scene to create the trail mesh in
  65612. * @returns the created trail mesh
  65613. */
  65614. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65615. }
  65616. }
  65617. declare module BABYLON {
  65618. /**
  65619. * Class containing static functions to help procedurally build meshes
  65620. */
  65621. export class TiledBoxBuilder {
  65622. /**
  65623. * Creates a box mesh
  65624. * 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)
  65625. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65627. * * 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
  65628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65629. * @param name defines the name of the mesh
  65630. * @param options defines the options used to create the mesh
  65631. * @param scene defines the hosting scene
  65632. * @returns the box mesh
  65633. */
  65634. static CreateTiledBox(name: string, options: {
  65635. pattern?: number;
  65636. width?: number;
  65637. height?: number;
  65638. depth?: number;
  65639. tileSize?: number;
  65640. tileWidth?: number;
  65641. tileHeight?: number;
  65642. alignHorizontal?: number;
  65643. alignVertical?: number;
  65644. faceUV?: Vector4[];
  65645. faceColors?: Color4[];
  65646. sideOrientation?: number;
  65647. updatable?: boolean;
  65648. }, scene?: Nullable<Scene>): Mesh;
  65649. }
  65650. }
  65651. declare module BABYLON {
  65652. /**
  65653. * Class containing static functions to help procedurally build meshes
  65654. */
  65655. export class TorusKnotBuilder {
  65656. /**
  65657. * Creates a torus knot mesh
  65658. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65659. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65660. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65661. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65663. * * 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
  65664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65665. * @param name defines the name of the mesh
  65666. * @param options defines the options used to create the mesh
  65667. * @param scene defines the hosting scene
  65668. * @returns the torus knot mesh
  65669. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65670. */
  65671. static CreateTorusKnot(name: string, options: {
  65672. radius?: number;
  65673. tube?: number;
  65674. radialSegments?: number;
  65675. tubularSegments?: number;
  65676. p?: number;
  65677. q?: number;
  65678. updatable?: boolean;
  65679. sideOrientation?: number;
  65680. frontUVs?: Vector4;
  65681. backUVs?: Vector4;
  65682. }, scene: any): Mesh;
  65683. }
  65684. }
  65685. declare module BABYLON {
  65686. /**
  65687. * Polygon
  65688. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65689. */
  65690. export class Polygon {
  65691. /**
  65692. * Creates a rectangle
  65693. * @param xmin bottom X coord
  65694. * @param ymin bottom Y coord
  65695. * @param xmax top X coord
  65696. * @param ymax top Y coord
  65697. * @returns points that make the resulting rectation
  65698. */
  65699. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  65700. /**
  65701. * Creates a circle
  65702. * @param radius radius of circle
  65703. * @param cx scale in x
  65704. * @param cy scale in y
  65705. * @param numberOfSides number of sides that make up the circle
  65706. * @returns points that make the resulting circle
  65707. */
  65708. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  65709. /**
  65710. * Creates a polygon from input string
  65711. * @param input Input polygon data
  65712. * @returns the parsed points
  65713. */
  65714. static Parse(input: string): Vector2[];
  65715. /**
  65716. * Starts building a polygon from x and y coordinates
  65717. * @param x x coordinate
  65718. * @param y y coordinate
  65719. * @returns the started path2
  65720. */
  65721. static StartingAt(x: number, y: number): Path2;
  65722. }
  65723. /**
  65724. * Builds a polygon
  65725. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  65726. */
  65727. export class PolygonMeshBuilder {
  65728. private _points;
  65729. private _outlinepoints;
  65730. private _holes;
  65731. private _name;
  65732. private _scene;
  65733. private _epoints;
  65734. private _eholes;
  65735. private _addToepoint;
  65736. /**
  65737. * Babylon reference to the earcut plugin.
  65738. */
  65739. bjsEarcut: any;
  65740. /**
  65741. * Creates a PolygonMeshBuilder
  65742. * @param name name of the builder
  65743. * @param contours Path of the polygon
  65744. * @param scene scene to add to when creating the mesh
  65745. * @param earcutInjection can be used to inject your own earcut reference
  65746. */
  65747. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  65748. /**
  65749. * Adds a whole within the polygon
  65750. * @param hole Array of points defining the hole
  65751. * @returns this
  65752. */
  65753. addHole(hole: Vector2[]): PolygonMeshBuilder;
  65754. /**
  65755. * Creates the polygon
  65756. * @param updatable If the mesh should be updatable
  65757. * @param depth The depth of the mesh created
  65758. * @returns the created mesh
  65759. */
  65760. build(updatable?: boolean, depth?: number): Mesh;
  65761. /**
  65762. * Creates the polygon
  65763. * @param depth The depth of the mesh created
  65764. * @returns the created VertexData
  65765. */
  65766. buildVertexData(depth?: number): VertexData;
  65767. /**
  65768. * Adds a side to the polygon
  65769. * @param positions points that make the polygon
  65770. * @param normals normals of the polygon
  65771. * @param uvs uvs of the polygon
  65772. * @param indices indices of the polygon
  65773. * @param bounds bounds of the polygon
  65774. * @param points points of the polygon
  65775. * @param depth depth of the polygon
  65776. * @param flip flip of the polygon
  65777. */
  65778. private addSide;
  65779. }
  65780. }
  65781. declare module BABYLON {
  65782. /**
  65783. * Class containing static functions to help procedurally build meshes
  65784. */
  65785. export class PolygonBuilder {
  65786. /**
  65787. * Creates a polygon mesh
  65788. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65789. * * 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
  65790. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65792. * * 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)
  65793. * * Remember you can only change the shape positions, not their number when updating a polygon
  65794. * @param name defines the name of the mesh
  65795. * @param options defines the options used to create the mesh
  65796. * @param scene defines the hosting scene
  65797. * @param earcutInjection can be used to inject your own earcut reference
  65798. * @returns the polygon mesh
  65799. */
  65800. static CreatePolygon(name: string, options: {
  65801. shape: Vector3[];
  65802. holes?: Vector3[][];
  65803. depth?: number;
  65804. faceUV?: Vector4[];
  65805. faceColors?: Color4[];
  65806. updatable?: boolean;
  65807. sideOrientation?: number;
  65808. frontUVs?: Vector4;
  65809. backUVs?: Vector4;
  65810. wrap?: boolean;
  65811. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65812. /**
  65813. * Creates an extruded polygon mesh, with depth in the Y direction.
  65814. * * 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)
  65815. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65816. * @param name defines the name of the mesh
  65817. * @param options defines the options used to create the mesh
  65818. * @param scene defines the hosting scene
  65819. * @param earcutInjection can be used to inject your own earcut reference
  65820. * @returns the polygon mesh
  65821. */
  65822. static ExtrudePolygon(name: string, options: {
  65823. shape: Vector3[];
  65824. holes?: Vector3[][];
  65825. depth?: number;
  65826. faceUV?: Vector4[];
  65827. faceColors?: Color4[];
  65828. updatable?: boolean;
  65829. sideOrientation?: number;
  65830. frontUVs?: Vector4;
  65831. backUVs?: Vector4;
  65832. wrap?: boolean;
  65833. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65834. }
  65835. }
  65836. declare module BABYLON {
  65837. /**
  65838. * Class containing static functions to help procedurally build meshes
  65839. */
  65840. export class LatheBuilder {
  65841. /**
  65842. * Creates lathe mesh.
  65843. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65844. * * 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
  65845. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65846. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65847. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65848. * * 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
  65849. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65850. * * 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
  65851. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65852. * * 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
  65853. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65854. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65855. * @param name defines the name of the mesh
  65856. * @param options defines the options used to create the mesh
  65857. * @param scene defines the hosting scene
  65858. * @returns the lathe mesh
  65859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65860. */
  65861. static CreateLathe(name: string, options: {
  65862. shape: Vector3[];
  65863. radius?: number;
  65864. tessellation?: number;
  65865. clip?: number;
  65866. arc?: number;
  65867. closed?: boolean;
  65868. updatable?: boolean;
  65869. sideOrientation?: number;
  65870. frontUVs?: Vector4;
  65871. backUVs?: Vector4;
  65872. cap?: number;
  65873. invertUV?: boolean;
  65874. }, scene?: Nullable<Scene>): Mesh;
  65875. }
  65876. }
  65877. declare module BABYLON {
  65878. /**
  65879. * Class containing static functions to help procedurally build meshes
  65880. */
  65881. export class TiledPlaneBuilder {
  65882. /**
  65883. * Creates a tiled plane mesh
  65884. * * The parameter `pattern` will, depending on value, do nothing or
  65885. * * * flip (reflect about central vertical) alternate tiles across and up
  65886. * * * flip every tile on alternate rows
  65887. * * * rotate (180 degs) alternate tiles across and up
  65888. * * * rotate every tile on alternate rows
  65889. * * * flip and rotate alternate tiles across and up
  65890. * * * flip and rotate every tile on alternate rows
  65891. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  65892. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  65893. * * 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
  65894. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65895. * * 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)
  65896. * * 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)
  65897. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  65898. * @param name defines the name of the mesh
  65899. * @param options defines the options used to create the mesh
  65900. * @param scene defines the hosting scene
  65901. * @returns the box mesh
  65902. */
  65903. static CreateTiledPlane(name: string, options: {
  65904. pattern?: number;
  65905. tileSize?: number;
  65906. tileWidth?: number;
  65907. tileHeight?: number;
  65908. size?: number;
  65909. width?: number;
  65910. height?: number;
  65911. alignHorizontal?: number;
  65912. alignVertical?: number;
  65913. sideOrientation?: number;
  65914. frontUVs?: Vector4;
  65915. backUVs?: Vector4;
  65916. updatable?: boolean;
  65917. }, scene?: Nullable<Scene>): Mesh;
  65918. }
  65919. }
  65920. declare module BABYLON {
  65921. /**
  65922. * Class containing static functions to help procedurally build meshes
  65923. */
  65924. export class TubeBuilder {
  65925. /**
  65926. * Creates a tube mesh.
  65927. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65928. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65929. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65930. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65931. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65932. * * 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)
  65933. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65934. * * 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
  65935. * * 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
  65936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65937. * * 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
  65938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65940. * @param name defines the name of the mesh
  65941. * @param options defines the options used to create the mesh
  65942. * @param scene defines the hosting scene
  65943. * @returns the tube mesh
  65944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65945. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65946. */
  65947. static CreateTube(name: string, options: {
  65948. path: Vector3[];
  65949. radius?: number;
  65950. tessellation?: number;
  65951. radiusFunction?: {
  65952. (i: number, distance: number): number;
  65953. };
  65954. cap?: number;
  65955. arc?: number;
  65956. updatable?: boolean;
  65957. sideOrientation?: number;
  65958. frontUVs?: Vector4;
  65959. backUVs?: Vector4;
  65960. instance?: Mesh;
  65961. invertUV?: boolean;
  65962. }, scene?: Nullable<Scene>): Mesh;
  65963. }
  65964. }
  65965. declare module BABYLON {
  65966. /**
  65967. * Class containing static functions to help procedurally build meshes
  65968. */
  65969. export class IcoSphereBuilder {
  65970. /**
  65971. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  65972. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  65973. * * 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`)
  65974. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  65975. * * 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
  65976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65977. * * 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
  65978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65979. * @param name defines the name of the mesh
  65980. * @param options defines the options used to create the mesh
  65981. * @param scene defines the hosting scene
  65982. * @returns the icosahedron mesh
  65983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  65984. */
  65985. static CreateIcoSphere(name: string, options: {
  65986. radius?: number;
  65987. radiusX?: number;
  65988. radiusY?: number;
  65989. radiusZ?: number;
  65990. flat?: boolean;
  65991. subdivisions?: number;
  65992. sideOrientation?: number;
  65993. frontUVs?: Vector4;
  65994. backUVs?: Vector4;
  65995. updatable?: boolean;
  65996. }, scene?: Nullable<Scene>): Mesh;
  65997. }
  65998. }
  65999. declare module BABYLON {
  66000. /**
  66001. * Class containing static functions to help procedurally build meshes
  66002. */
  66003. export class DecalBuilder {
  66004. /**
  66005. * Creates a decal mesh.
  66006. * 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
  66007. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66008. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66009. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66010. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66011. * @param name defines the name of the mesh
  66012. * @param sourceMesh defines the mesh where the decal must be applied
  66013. * @param options defines the options used to create the mesh
  66014. * @param scene defines the hosting scene
  66015. * @returns the decal mesh
  66016. * @see https://doc.babylonjs.com/how_to/decals
  66017. */
  66018. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66019. position?: Vector3;
  66020. normal?: Vector3;
  66021. size?: Vector3;
  66022. angle?: number;
  66023. }): Mesh;
  66024. }
  66025. }
  66026. declare module BABYLON {
  66027. /**
  66028. * Class containing static functions to help procedurally build meshes
  66029. */
  66030. export class MeshBuilder {
  66031. /**
  66032. * Creates a box mesh
  66033. * * The parameter `size` sets the size (float) of each box side (default 1)
  66034. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66035. * * 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)
  66036. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66038. * * 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
  66039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66040. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66041. * @param name defines the name of the mesh
  66042. * @param options defines the options used to create the mesh
  66043. * @param scene defines the hosting scene
  66044. * @returns the box mesh
  66045. */
  66046. static CreateBox(name: string, options: {
  66047. size?: number;
  66048. width?: number;
  66049. height?: number;
  66050. depth?: number;
  66051. faceUV?: Vector4[];
  66052. faceColors?: Color4[];
  66053. sideOrientation?: number;
  66054. frontUVs?: Vector4;
  66055. backUVs?: Vector4;
  66056. wrap?: boolean;
  66057. topBaseAt?: number;
  66058. bottomBaseAt?: number;
  66059. updatable?: boolean;
  66060. }, scene?: Nullable<Scene>): Mesh;
  66061. /**
  66062. * Creates a tiled box mesh
  66063. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66065. * @param name defines the name of the mesh
  66066. * @param options defines the options used to create the mesh
  66067. * @param scene defines the hosting scene
  66068. * @returns the tiled box mesh
  66069. */
  66070. static CreateTiledBox(name: string, options: {
  66071. pattern?: number;
  66072. size?: number;
  66073. width?: number;
  66074. height?: number;
  66075. depth: number;
  66076. tileSize?: number;
  66077. tileWidth?: number;
  66078. tileHeight?: number;
  66079. faceUV?: Vector4[];
  66080. faceColors?: Color4[];
  66081. alignHorizontal?: number;
  66082. alignVertical?: number;
  66083. sideOrientation?: number;
  66084. updatable?: boolean;
  66085. }, scene?: Nullable<Scene>): Mesh;
  66086. /**
  66087. * Creates a sphere mesh
  66088. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66089. * * 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`)
  66090. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66091. * * 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
  66092. * * 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)
  66093. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66094. * * 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
  66095. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66096. * @param name defines the name of the mesh
  66097. * @param options defines the options used to create the mesh
  66098. * @param scene defines the hosting scene
  66099. * @returns the sphere mesh
  66100. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66101. */
  66102. static CreateSphere(name: string, options: {
  66103. segments?: number;
  66104. diameter?: number;
  66105. diameterX?: number;
  66106. diameterY?: number;
  66107. diameterZ?: number;
  66108. arc?: number;
  66109. slice?: number;
  66110. sideOrientation?: number;
  66111. frontUVs?: Vector4;
  66112. backUVs?: Vector4;
  66113. updatable?: boolean;
  66114. }, scene?: Nullable<Scene>): Mesh;
  66115. /**
  66116. * Creates a plane polygonal mesh. By default, this is a disc
  66117. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66118. * * 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
  66119. * * 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
  66120. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66121. * * 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
  66122. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66123. * @param name defines the name of the mesh
  66124. * @param options defines the options used to create the mesh
  66125. * @param scene defines the hosting scene
  66126. * @returns the plane polygonal mesh
  66127. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66128. */
  66129. static CreateDisc(name: string, options: {
  66130. radius?: number;
  66131. tessellation?: number;
  66132. arc?: number;
  66133. updatable?: boolean;
  66134. sideOrientation?: number;
  66135. frontUVs?: Vector4;
  66136. backUVs?: Vector4;
  66137. }, scene?: Nullable<Scene>): Mesh;
  66138. /**
  66139. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66140. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66141. * * 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`)
  66142. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66143. * * 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
  66144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66145. * * 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
  66146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66147. * @param name defines the name of the mesh
  66148. * @param options defines the options used to create the mesh
  66149. * @param scene defines the hosting scene
  66150. * @returns the icosahedron mesh
  66151. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66152. */
  66153. static CreateIcoSphere(name: string, options: {
  66154. radius?: number;
  66155. radiusX?: number;
  66156. radiusY?: number;
  66157. radiusZ?: number;
  66158. flat?: boolean;
  66159. subdivisions?: number;
  66160. sideOrientation?: number;
  66161. frontUVs?: Vector4;
  66162. backUVs?: Vector4;
  66163. updatable?: boolean;
  66164. }, scene?: Nullable<Scene>): Mesh;
  66165. /**
  66166. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66167. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66168. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66169. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66170. * * 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
  66171. * * 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
  66172. * * 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
  66173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66174. * * 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
  66175. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66176. * * 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
  66177. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66178. * * 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
  66179. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66181. * @param name defines the name of the mesh
  66182. * @param options defines the options used to create the mesh
  66183. * @param scene defines the hosting scene
  66184. * @returns the ribbon mesh
  66185. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66187. */
  66188. static CreateRibbon(name: string, options: {
  66189. pathArray: Vector3[][];
  66190. closeArray?: boolean;
  66191. closePath?: boolean;
  66192. offset?: number;
  66193. updatable?: boolean;
  66194. sideOrientation?: number;
  66195. frontUVs?: Vector4;
  66196. backUVs?: Vector4;
  66197. instance?: Mesh;
  66198. invertUV?: boolean;
  66199. uvs?: Vector2[];
  66200. colors?: Color4[];
  66201. }, scene?: Nullable<Scene>): Mesh;
  66202. /**
  66203. * Creates a cylinder or a cone mesh
  66204. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66205. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66206. * * 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.
  66207. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66208. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66209. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66210. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66211. * * 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).
  66212. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66213. * * 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).
  66214. * * 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
  66215. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66216. * * 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
  66217. * * 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.
  66218. * * If `enclose` is false, a ring surface is one element.
  66219. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66220. * * 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
  66221. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66222. * * 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
  66223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66224. * @param name defines the name of the mesh
  66225. * @param options defines the options used to create the mesh
  66226. * @param scene defines the hosting scene
  66227. * @returns the cylinder mesh
  66228. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66229. */
  66230. static CreateCylinder(name: string, options: {
  66231. height?: number;
  66232. diameterTop?: number;
  66233. diameterBottom?: number;
  66234. diameter?: number;
  66235. tessellation?: number;
  66236. subdivisions?: number;
  66237. arc?: number;
  66238. faceColors?: Color4[];
  66239. faceUV?: Vector4[];
  66240. updatable?: boolean;
  66241. hasRings?: boolean;
  66242. enclose?: boolean;
  66243. cap?: number;
  66244. sideOrientation?: number;
  66245. frontUVs?: Vector4;
  66246. backUVs?: Vector4;
  66247. }, scene?: Nullable<Scene>): Mesh;
  66248. /**
  66249. * Creates a torus mesh
  66250. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66251. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66252. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66254. * * 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
  66255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66256. * @param name defines the name of the mesh
  66257. * @param options defines the options used to create the mesh
  66258. * @param scene defines the hosting scene
  66259. * @returns the torus mesh
  66260. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66261. */
  66262. static CreateTorus(name: string, options: {
  66263. diameter?: number;
  66264. thickness?: number;
  66265. tessellation?: number;
  66266. updatable?: boolean;
  66267. sideOrientation?: number;
  66268. frontUVs?: Vector4;
  66269. backUVs?: Vector4;
  66270. }, scene?: Nullable<Scene>): Mesh;
  66271. /**
  66272. * Creates a torus knot mesh
  66273. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66274. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66275. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66276. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66277. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66278. * * 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
  66279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66280. * @param name defines the name of the mesh
  66281. * @param options defines the options used to create the mesh
  66282. * @param scene defines the hosting scene
  66283. * @returns the torus knot mesh
  66284. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66285. */
  66286. static CreateTorusKnot(name: string, options: {
  66287. radius?: number;
  66288. tube?: number;
  66289. radialSegments?: number;
  66290. tubularSegments?: number;
  66291. p?: number;
  66292. q?: number;
  66293. updatable?: boolean;
  66294. sideOrientation?: number;
  66295. frontUVs?: Vector4;
  66296. backUVs?: Vector4;
  66297. }, scene?: Nullable<Scene>): Mesh;
  66298. /**
  66299. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66300. * * 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
  66301. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66302. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66303. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66304. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66305. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66306. * * 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
  66307. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66309. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66310. * @param name defines the name of the new line system
  66311. * @param options defines the options used to create the line system
  66312. * @param scene defines the hosting scene
  66313. * @returns a new line system mesh
  66314. */
  66315. static CreateLineSystem(name: string, options: {
  66316. lines: Vector3[][];
  66317. updatable?: boolean;
  66318. instance?: Nullable<LinesMesh>;
  66319. colors?: Nullable<Color4[][]>;
  66320. useVertexAlpha?: boolean;
  66321. }, scene: Nullable<Scene>): LinesMesh;
  66322. /**
  66323. * Creates a line mesh
  66324. * 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
  66325. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66326. * * The parameter `points` is an array successive Vector3
  66327. * * 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
  66328. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66329. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66330. * * When updating an instance, remember that only point positions can change, not the number of points
  66331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66332. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66333. * @param name defines the name of the new line system
  66334. * @param options defines the options used to create the line system
  66335. * @param scene defines the hosting scene
  66336. * @returns a new line mesh
  66337. */
  66338. static CreateLines(name: string, options: {
  66339. points: Vector3[];
  66340. updatable?: boolean;
  66341. instance?: Nullable<LinesMesh>;
  66342. colors?: Color4[];
  66343. useVertexAlpha?: boolean;
  66344. }, scene?: Nullable<Scene>): LinesMesh;
  66345. /**
  66346. * Creates a dashed line mesh
  66347. * * 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
  66348. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66349. * * The parameter `points` is an array successive Vector3
  66350. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66351. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66352. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66353. * * 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
  66354. * * When updating an instance, remember that only point positions can change, not the number of points
  66355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66356. * @param name defines the name of the mesh
  66357. * @param options defines the options used to create the mesh
  66358. * @param scene defines the hosting scene
  66359. * @returns the dashed line mesh
  66360. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66361. */
  66362. static CreateDashedLines(name: string, options: {
  66363. points: Vector3[];
  66364. dashSize?: number;
  66365. gapSize?: number;
  66366. dashNb?: number;
  66367. updatable?: boolean;
  66368. instance?: LinesMesh;
  66369. }, scene?: Nullable<Scene>): LinesMesh;
  66370. /**
  66371. * 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.
  66372. * * 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.
  66373. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66374. * * 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.
  66375. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66376. * * 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
  66377. * * 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
  66378. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66380. * * 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
  66381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66383. * @param name defines the name of the mesh
  66384. * @param options defines the options used to create the mesh
  66385. * @param scene defines the hosting scene
  66386. * @returns the extruded shape mesh
  66387. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66388. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66389. */
  66390. static ExtrudeShape(name: string, options: {
  66391. shape: Vector3[];
  66392. path: Vector3[];
  66393. scale?: number;
  66394. rotation?: number;
  66395. cap?: number;
  66396. updatable?: boolean;
  66397. sideOrientation?: number;
  66398. frontUVs?: Vector4;
  66399. backUVs?: Vector4;
  66400. instance?: Mesh;
  66401. invertUV?: boolean;
  66402. }, scene?: Nullable<Scene>): Mesh;
  66403. /**
  66404. * Creates an custom extruded shape mesh.
  66405. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66406. * * 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.
  66407. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66408. * * 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
  66409. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66410. * * 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
  66411. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66412. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66413. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66414. * * 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
  66415. * * 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
  66416. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66418. * * 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
  66419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66421. * @param name defines the name of the mesh
  66422. * @param options defines the options used to create the mesh
  66423. * @param scene defines the hosting scene
  66424. * @returns the custom extruded shape mesh
  66425. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66427. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66428. */
  66429. static ExtrudeShapeCustom(name: string, options: {
  66430. shape: Vector3[];
  66431. path: Vector3[];
  66432. scaleFunction?: any;
  66433. rotationFunction?: any;
  66434. ribbonCloseArray?: boolean;
  66435. ribbonClosePath?: boolean;
  66436. cap?: number;
  66437. updatable?: boolean;
  66438. sideOrientation?: number;
  66439. frontUVs?: Vector4;
  66440. backUVs?: Vector4;
  66441. instance?: Mesh;
  66442. invertUV?: boolean;
  66443. }, scene?: Nullable<Scene>): Mesh;
  66444. /**
  66445. * Creates lathe mesh.
  66446. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66447. * * 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
  66448. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66449. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66450. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66451. * * 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
  66452. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66453. * * 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
  66454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66455. * * 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
  66456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66458. * @param name defines the name of the mesh
  66459. * @param options defines the options used to create the mesh
  66460. * @param scene defines the hosting scene
  66461. * @returns the lathe mesh
  66462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66463. */
  66464. static CreateLathe(name: string, options: {
  66465. shape: Vector3[];
  66466. radius?: number;
  66467. tessellation?: number;
  66468. clip?: number;
  66469. arc?: number;
  66470. closed?: boolean;
  66471. updatable?: boolean;
  66472. sideOrientation?: number;
  66473. frontUVs?: Vector4;
  66474. backUVs?: Vector4;
  66475. cap?: number;
  66476. invertUV?: boolean;
  66477. }, scene?: Nullable<Scene>): Mesh;
  66478. /**
  66479. * Creates a tiled plane mesh
  66480. * * You can set a limited pattern arrangement with the tiles
  66481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66482. * * 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
  66483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66484. * @param name defines the name of the mesh
  66485. * @param options defines the options used to create the mesh
  66486. * @param scene defines the hosting scene
  66487. * @returns the plane mesh
  66488. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66489. */
  66490. static CreateTiledPlane(name: string, options: {
  66491. pattern?: number;
  66492. tileSize?: number;
  66493. tileWidth?: number;
  66494. tileHeight?: number;
  66495. size?: number;
  66496. width?: number;
  66497. height?: number;
  66498. alignHorizontal?: number;
  66499. alignVertical?: number;
  66500. sideOrientation?: number;
  66501. frontUVs?: Vector4;
  66502. backUVs?: Vector4;
  66503. updatable?: boolean;
  66504. }, scene?: Nullable<Scene>): Mesh;
  66505. /**
  66506. * Creates a plane mesh
  66507. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66508. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66509. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66511. * * 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
  66512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66513. * @param name defines the name of the mesh
  66514. * @param options defines the options used to create the mesh
  66515. * @param scene defines the hosting scene
  66516. * @returns the plane mesh
  66517. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66518. */
  66519. static CreatePlane(name: string, options: {
  66520. size?: number;
  66521. width?: number;
  66522. height?: number;
  66523. sideOrientation?: number;
  66524. frontUVs?: Vector4;
  66525. backUVs?: Vector4;
  66526. updatable?: boolean;
  66527. sourcePlane?: Plane;
  66528. }, scene?: Nullable<Scene>): Mesh;
  66529. /**
  66530. * Creates a ground mesh
  66531. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66532. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66533. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66534. * @param name defines the name of the mesh
  66535. * @param options defines the options used to create the mesh
  66536. * @param scene defines the hosting scene
  66537. * @returns the ground mesh
  66538. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66539. */
  66540. static CreateGround(name: string, options: {
  66541. width?: number;
  66542. height?: number;
  66543. subdivisions?: number;
  66544. subdivisionsX?: number;
  66545. subdivisionsY?: number;
  66546. updatable?: boolean;
  66547. }, scene?: Nullable<Scene>): Mesh;
  66548. /**
  66549. * Creates a tiled ground mesh
  66550. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66551. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66552. * * 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
  66553. * * 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
  66554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66555. * @param name defines the name of the mesh
  66556. * @param options defines the options used to create the mesh
  66557. * @param scene defines the hosting scene
  66558. * @returns the tiled ground mesh
  66559. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66560. */
  66561. static CreateTiledGround(name: string, options: {
  66562. xmin: number;
  66563. zmin: number;
  66564. xmax: number;
  66565. zmax: number;
  66566. subdivisions?: {
  66567. w: number;
  66568. h: number;
  66569. };
  66570. precision?: {
  66571. w: number;
  66572. h: number;
  66573. };
  66574. updatable?: boolean;
  66575. }, scene?: Nullable<Scene>): Mesh;
  66576. /**
  66577. * Creates a ground mesh from a height map
  66578. * * The parameter `url` sets the URL of the height map image resource.
  66579. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66580. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66581. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66582. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66583. * * 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.
  66584. * * 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).
  66585. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66587. * @param name defines the name of the mesh
  66588. * @param url defines the url to the height map
  66589. * @param options defines the options used to create the mesh
  66590. * @param scene defines the hosting scene
  66591. * @returns the ground mesh
  66592. * @see https://doc.babylonjs.com/babylon101/height_map
  66593. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66594. */
  66595. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66596. width?: number;
  66597. height?: number;
  66598. subdivisions?: number;
  66599. minHeight?: number;
  66600. maxHeight?: number;
  66601. colorFilter?: Color3;
  66602. alphaFilter?: number;
  66603. updatable?: boolean;
  66604. onReady?: (mesh: GroundMesh) => void;
  66605. }, scene?: Nullable<Scene>): GroundMesh;
  66606. /**
  66607. * Creates a polygon mesh
  66608. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66609. * * 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
  66610. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66612. * * 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)
  66613. * * Remember you can only change the shape positions, not their number when updating a polygon
  66614. * @param name defines the name of the mesh
  66615. * @param options defines the options used to create the mesh
  66616. * @param scene defines the hosting scene
  66617. * @param earcutInjection can be used to inject your own earcut reference
  66618. * @returns the polygon mesh
  66619. */
  66620. static CreatePolygon(name: string, options: {
  66621. shape: Vector3[];
  66622. holes?: Vector3[][];
  66623. depth?: number;
  66624. faceUV?: Vector4[];
  66625. faceColors?: Color4[];
  66626. updatable?: boolean;
  66627. sideOrientation?: number;
  66628. frontUVs?: Vector4;
  66629. backUVs?: Vector4;
  66630. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66631. /**
  66632. * Creates an extruded polygon mesh, with depth in the Y direction.
  66633. * * 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)
  66634. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66635. * @param name defines the name of the mesh
  66636. * @param options defines the options used to create the mesh
  66637. * @param scene defines the hosting scene
  66638. * @param earcutInjection can be used to inject your own earcut reference
  66639. * @returns the polygon mesh
  66640. */
  66641. static ExtrudePolygon(name: string, options: {
  66642. shape: Vector3[];
  66643. holes?: Vector3[][];
  66644. depth?: number;
  66645. faceUV?: Vector4[];
  66646. faceColors?: Color4[];
  66647. updatable?: boolean;
  66648. sideOrientation?: number;
  66649. frontUVs?: Vector4;
  66650. backUVs?: Vector4;
  66651. wrap?: boolean;
  66652. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66653. /**
  66654. * Creates a tube mesh.
  66655. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66656. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66657. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66658. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66659. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66660. * * 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)
  66661. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66662. * * 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
  66663. * * 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
  66664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66665. * * 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
  66666. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66668. * @param name defines the name of the mesh
  66669. * @param options defines the options used to create the mesh
  66670. * @param scene defines the hosting scene
  66671. * @returns the tube mesh
  66672. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66673. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66674. */
  66675. static CreateTube(name: string, options: {
  66676. path: Vector3[];
  66677. radius?: number;
  66678. tessellation?: number;
  66679. radiusFunction?: {
  66680. (i: number, distance: number): number;
  66681. };
  66682. cap?: number;
  66683. arc?: number;
  66684. updatable?: boolean;
  66685. sideOrientation?: number;
  66686. frontUVs?: Vector4;
  66687. backUVs?: Vector4;
  66688. instance?: Mesh;
  66689. invertUV?: boolean;
  66690. }, scene?: Nullable<Scene>): Mesh;
  66691. /**
  66692. * Creates a polyhedron mesh
  66693. * * 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
  66694. * * The parameter `size` (positive float, default 1) sets the polygon size
  66695. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  66696. * * 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`
  66697. * * 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
  66698. * * 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)`)
  66699. * * 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
  66700. * * 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
  66701. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66702. * * 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
  66703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66704. * @param name defines the name of the mesh
  66705. * @param options defines the options used to create the mesh
  66706. * @param scene defines the hosting scene
  66707. * @returns the polyhedron mesh
  66708. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  66709. */
  66710. static CreatePolyhedron(name: string, options: {
  66711. type?: number;
  66712. size?: number;
  66713. sizeX?: number;
  66714. sizeY?: number;
  66715. sizeZ?: number;
  66716. custom?: any;
  66717. faceUV?: Vector4[];
  66718. faceColors?: Color4[];
  66719. flat?: boolean;
  66720. updatable?: boolean;
  66721. sideOrientation?: number;
  66722. frontUVs?: Vector4;
  66723. backUVs?: Vector4;
  66724. }, scene?: Nullable<Scene>): Mesh;
  66725. /**
  66726. * Creates a decal mesh.
  66727. * 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
  66728. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66729. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66730. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66731. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66732. * @param name defines the name of the mesh
  66733. * @param sourceMesh defines the mesh where the decal must be applied
  66734. * @param options defines the options used to create the mesh
  66735. * @param scene defines the hosting scene
  66736. * @returns the decal mesh
  66737. * @see https://doc.babylonjs.com/how_to/decals
  66738. */
  66739. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66740. position?: Vector3;
  66741. normal?: Vector3;
  66742. size?: Vector3;
  66743. angle?: number;
  66744. }): Mesh;
  66745. /**
  66746. * Creates a Capsule Mesh
  66747. * @param name defines the name of the mesh.
  66748. * @param options the constructors options used to shape the mesh.
  66749. * @param scene defines the scene the mesh is scoped to.
  66750. * @returns the capsule mesh
  66751. * @see https://doc.babylonjs.com/how_to/capsule_shape
  66752. */
  66753. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  66754. }
  66755. }
  66756. declare module BABYLON {
  66757. /**
  66758. * A simplifier interface for future simplification implementations
  66759. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66760. */
  66761. export interface ISimplifier {
  66762. /**
  66763. * Simplification of a given mesh according to the given settings.
  66764. * Since this requires computation, it is assumed that the function runs async.
  66765. * @param settings The settings of the simplification, including quality and distance
  66766. * @param successCallback A callback that will be called after the mesh was simplified.
  66767. * @param errorCallback in case of an error, this callback will be called. optional.
  66768. */
  66769. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  66770. }
  66771. /**
  66772. * Expected simplification settings.
  66773. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  66774. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66775. */
  66776. export interface ISimplificationSettings {
  66777. /**
  66778. * Gets or sets the expected quality
  66779. */
  66780. quality: number;
  66781. /**
  66782. * Gets or sets the distance when this optimized version should be used
  66783. */
  66784. distance: number;
  66785. /**
  66786. * Gets an already optimized mesh
  66787. */
  66788. optimizeMesh?: boolean;
  66789. }
  66790. /**
  66791. * Class used to specify simplification options
  66792. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66793. */
  66794. export class SimplificationSettings implements ISimplificationSettings {
  66795. /** expected quality */
  66796. quality: number;
  66797. /** distance when this optimized version should be used */
  66798. distance: number;
  66799. /** already optimized mesh */
  66800. optimizeMesh?: boolean | undefined;
  66801. /**
  66802. * Creates a SimplificationSettings
  66803. * @param quality expected quality
  66804. * @param distance distance when this optimized version should be used
  66805. * @param optimizeMesh already optimized mesh
  66806. */
  66807. constructor(
  66808. /** expected quality */
  66809. quality: number,
  66810. /** distance when this optimized version should be used */
  66811. distance: number,
  66812. /** already optimized mesh */
  66813. optimizeMesh?: boolean | undefined);
  66814. }
  66815. /**
  66816. * Interface used to define a simplification task
  66817. */
  66818. export interface ISimplificationTask {
  66819. /**
  66820. * Array of settings
  66821. */
  66822. settings: Array<ISimplificationSettings>;
  66823. /**
  66824. * Simplification type
  66825. */
  66826. simplificationType: SimplificationType;
  66827. /**
  66828. * Mesh to simplify
  66829. */
  66830. mesh: Mesh;
  66831. /**
  66832. * Callback called on success
  66833. */
  66834. successCallback?: () => void;
  66835. /**
  66836. * Defines if parallel processing can be used
  66837. */
  66838. parallelProcessing: boolean;
  66839. }
  66840. /**
  66841. * Queue used to order the simplification tasks
  66842. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66843. */
  66844. export class SimplificationQueue {
  66845. private _simplificationArray;
  66846. /**
  66847. * Gets a boolean indicating that the process is still running
  66848. */
  66849. running: boolean;
  66850. /**
  66851. * Creates a new queue
  66852. */
  66853. constructor();
  66854. /**
  66855. * Adds a new simplification task
  66856. * @param task defines a task to add
  66857. */
  66858. addTask(task: ISimplificationTask): void;
  66859. /**
  66860. * Execute next task
  66861. */
  66862. executeNext(): void;
  66863. /**
  66864. * Execute a simplification task
  66865. * @param task defines the task to run
  66866. */
  66867. runSimplification(task: ISimplificationTask): void;
  66868. private getSimplifier;
  66869. }
  66870. /**
  66871. * The implemented types of simplification
  66872. * At the moment only Quadratic Error Decimation is implemented
  66873. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66874. */
  66875. export enum SimplificationType {
  66876. /** Quadratic error decimation */
  66877. QUADRATIC = 0
  66878. }
  66879. /**
  66880. * An implementation of the Quadratic Error simplification algorithm.
  66881. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  66882. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  66883. * @author RaananW
  66884. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66885. */
  66886. export class QuadraticErrorSimplification implements ISimplifier {
  66887. private _mesh;
  66888. private triangles;
  66889. private vertices;
  66890. private references;
  66891. private _reconstructedMesh;
  66892. /** Gets or sets the number pf sync interations */
  66893. syncIterations: number;
  66894. /** Gets or sets the aggressiveness of the simplifier */
  66895. aggressiveness: number;
  66896. /** Gets or sets the number of allowed iterations for decimation */
  66897. decimationIterations: number;
  66898. /** Gets or sets the espilon to use for bounding box computation */
  66899. boundingBoxEpsilon: number;
  66900. /**
  66901. * Creates a new QuadraticErrorSimplification
  66902. * @param _mesh defines the target mesh
  66903. */
  66904. constructor(_mesh: Mesh);
  66905. /**
  66906. * Simplification of a given mesh according to the given settings.
  66907. * Since this requires computation, it is assumed that the function runs async.
  66908. * @param settings The settings of the simplification, including quality and distance
  66909. * @param successCallback A callback that will be called after the mesh was simplified.
  66910. */
  66911. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  66912. private runDecimation;
  66913. private initWithMesh;
  66914. private init;
  66915. private reconstructMesh;
  66916. private initDecimatedMesh;
  66917. private isFlipped;
  66918. private updateTriangles;
  66919. private identifyBorder;
  66920. private updateMesh;
  66921. private vertexError;
  66922. private calculateError;
  66923. }
  66924. }
  66925. declare module BABYLON {
  66926. interface Scene {
  66927. /** @hidden (Backing field) */
  66928. _simplificationQueue: SimplificationQueue;
  66929. /**
  66930. * Gets or sets the simplification queue attached to the scene
  66931. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  66932. */
  66933. simplificationQueue: SimplificationQueue;
  66934. }
  66935. interface Mesh {
  66936. /**
  66937. * Simplify the mesh according to the given array of settings.
  66938. * Function will return immediately and will simplify async
  66939. * @param settings a collection of simplification settings
  66940. * @param parallelProcessing should all levels calculate parallel or one after the other
  66941. * @param simplificationType the type of simplification to run
  66942. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  66943. * @returns the current mesh
  66944. */
  66945. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  66946. }
  66947. /**
  66948. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  66949. * created in a scene
  66950. */
  66951. export class SimplicationQueueSceneComponent implements ISceneComponent {
  66952. /**
  66953. * The component name helpfull to identify the component in the list of scene components.
  66954. */
  66955. readonly name: string;
  66956. /**
  66957. * The scene the component belongs to.
  66958. */
  66959. scene: Scene;
  66960. /**
  66961. * Creates a new instance of the component for the given scene
  66962. * @param scene Defines the scene to register the component in
  66963. */
  66964. constructor(scene: Scene);
  66965. /**
  66966. * Registers the component in a given scene
  66967. */
  66968. register(): void;
  66969. /**
  66970. * Rebuilds the elements related to this component in case of
  66971. * context lost for instance.
  66972. */
  66973. rebuild(): void;
  66974. /**
  66975. * Disposes the component and the associated ressources
  66976. */
  66977. dispose(): void;
  66978. private _beforeCameraUpdate;
  66979. }
  66980. }
  66981. declare module BABYLON {
  66982. interface Mesh {
  66983. /**
  66984. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  66985. */
  66986. thinInstanceEnablePicking: boolean;
  66987. /**
  66988. * Creates a new thin instance
  66989. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  66990. * @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
  66991. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  66992. */
  66993. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  66994. /**
  66995. * Adds the transformation (matrix) of the current mesh as a thin instance
  66996. * @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
  66997. * @returns the thin instance index number
  66998. */
  66999. thinInstanceAddSelf(refresh: boolean): number;
  67000. /**
  67001. * Registers a custom attribute to be used with thin instances
  67002. * @param kind name of the attribute
  67003. * @param stride size in floats of the attribute
  67004. */
  67005. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67006. /**
  67007. * Sets the matrix of a thin instance
  67008. * @param index index of the thin instance
  67009. * @param matrix matrix to set
  67010. * @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
  67011. */
  67012. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67013. /**
  67014. * Sets the value of a custom attribute for a thin instance
  67015. * @param kind name of the attribute
  67016. * @param index index of the thin instance
  67017. * @param value value to set
  67018. * @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
  67019. */
  67020. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67021. /**
  67022. * 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.
  67023. */
  67024. thinInstanceCount: number;
  67025. /**
  67026. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67027. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67028. * @param buffer buffer to set
  67029. * @param stride size in floats of each value of the buffer
  67030. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67031. */
  67032. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67033. /**
  67034. * Gets the list of world matrices
  67035. * @return an array containing all the world matrices from the thin instances
  67036. */
  67037. thinInstanceGetWorldMatrices(): Matrix[];
  67038. /**
  67039. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67040. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67041. */
  67042. thinInstanceBufferUpdated(kind: string): void;
  67043. /**
  67044. * Applies a partial update to a buffer directly on the GPU
  67045. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  67046. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67047. * @param data the data to set in the GPU buffer
  67048. * @param offset the offset in the GPU buffer where to update the data
  67049. */
  67050. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67051. /**
  67052. * Refreshes the bounding info, taking into account all the thin instances defined
  67053. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67054. */
  67055. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67056. /** @hidden */
  67057. _thinInstanceInitializeUserStorage(): void;
  67058. /** @hidden */
  67059. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67060. /** @hidden */
  67061. _userThinInstanceBuffersStorage: {
  67062. data: {
  67063. [key: string]: Float32Array;
  67064. };
  67065. sizes: {
  67066. [key: string]: number;
  67067. };
  67068. vertexBuffers: {
  67069. [key: string]: Nullable<VertexBuffer>;
  67070. };
  67071. strides: {
  67072. [key: string]: number;
  67073. };
  67074. };
  67075. }
  67076. }
  67077. declare module BABYLON {
  67078. /**
  67079. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67080. */
  67081. export interface INavigationEnginePlugin {
  67082. /**
  67083. * plugin name
  67084. */
  67085. name: string;
  67086. /**
  67087. * Creates a navigation mesh
  67088. * @param meshes array of all the geometry used to compute the navigatio mesh
  67089. * @param parameters bunch of parameters used to filter geometry
  67090. */
  67091. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67092. /**
  67093. * Create a navigation mesh debug mesh
  67094. * @param scene is where the mesh will be added
  67095. * @returns debug display mesh
  67096. */
  67097. createDebugNavMesh(scene: Scene): Mesh;
  67098. /**
  67099. * Get a navigation mesh constrained position, closest to the parameter position
  67100. * @param position world position
  67101. * @returns the closest point to position constrained by the navigation mesh
  67102. */
  67103. getClosestPoint(position: Vector3): Vector3;
  67104. /**
  67105. * Get a navigation mesh constrained position, closest to the parameter position
  67106. * @param position world position
  67107. * @param result output the closest point to position constrained by the navigation mesh
  67108. */
  67109. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67110. /**
  67111. * Get a navigation mesh constrained position, within a particular radius
  67112. * @param position world position
  67113. * @param maxRadius the maximum distance to the constrained world position
  67114. * @returns the closest point to position constrained by the navigation mesh
  67115. */
  67116. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67117. /**
  67118. * Get a navigation mesh constrained position, within a particular radius
  67119. * @param position world position
  67120. * @param maxRadius the maximum distance to the constrained world position
  67121. * @param result output the closest point to position constrained by the navigation mesh
  67122. */
  67123. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67124. /**
  67125. * Compute the final position from a segment made of destination-position
  67126. * @param position world position
  67127. * @param destination world position
  67128. * @returns the resulting point along the navmesh
  67129. */
  67130. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67131. /**
  67132. * Compute the final position from a segment made of destination-position
  67133. * @param position world position
  67134. * @param destination world position
  67135. * @param result output the resulting point along the navmesh
  67136. */
  67137. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67138. /**
  67139. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67140. * @param start world position
  67141. * @param end world position
  67142. * @returns array containing world position composing the path
  67143. */
  67144. computePath(start: Vector3, end: Vector3): Vector3[];
  67145. /**
  67146. * If this plugin is supported
  67147. * @returns true if plugin is supported
  67148. */
  67149. isSupported(): boolean;
  67150. /**
  67151. * Create a new Crowd so you can add agents
  67152. * @param maxAgents the maximum agent count in the crowd
  67153. * @param maxAgentRadius the maximum radius an agent can have
  67154. * @param scene to attach the crowd to
  67155. * @returns the crowd you can add agents to
  67156. */
  67157. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67158. /**
  67159. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67160. * The queries will try to find a solution within those bounds
  67161. * default is (1,1,1)
  67162. * @param extent x,y,z value that define the extent around the queries point of reference
  67163. */
  67164. setDefaultQueryExtent(extent: Vector3): void;
  67165. /**
  67166. * Get the Bounding box extent specified by setDefaultQueryExtent
  67167. * @returns the box extent values
  67168. */
  67169. getDefaultQueryExtent(): Vector3;
  67170. /**
  67171. * build the navmesh from a previously saved state using getNavmeshData
  67172. * @param data the Uint8Array returned by getNavmeshData
  67173. */
  67174. buildFromNavmeshData(data: Uint8Array): void;
  67175. /**
  67176. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67177. * @returns data the Uint8Array that can be saved and reused
  67178. */
  67179. getNavmeshData(): Uint8Array;
  67180. /**
  67181. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67182. * @param result output the box extent values
  67183. */
  67184. getDefaultQueryExtentToRef(result: Vector3): void;
  67185. /**
  67186. * Release all resources
  67187. */
  67188. dispose(): void;
  67189. }
  67190. /**
  67191. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67192. */
  67193. export interface ICrowd {
  67194. /**
  67195. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67196. * You can attach anything to that node. The node position is updated in the scene update tick.
  67197. * @param pos world position that will be constrained by the navigation mesh
  67198. * @param parameters agent parameters
  67199. * @param transform hooked to the agent that will be update by the scene
  67200. * @returns agent index
  67201. */
  67202. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67203. /**
  67204. * Returns the agent position in world space
  67205. * @param index agent index returned by addAgent
  67206. * @returns world space position
  67207. */
  67208. getAgentPosition(index: number): Vector3;
  67209. /**
  67210. * Gets the agent position result in world space
  67211. * @param index agent index returned by addAgent
  67212. * @param result output world space position
  67213. */
  67214. getAgentPositionToRef(index: number, result: Vector3): void;
  67215. /**
  67216. * Gets the agent velocity in world space
  67217. * @param index agent index returned by addAgent
  67218. * @returns world space velocity
  67219. */
  67220. getAgentVelocity(index: number): Vector3;
  67221. /**
  67222. * Gets the agent velocity result in world space
  67223. * @param index agent index returned by addAgent
  67224. * @param result output world space velocity
  67225. */
  67226. getAgentVelocityToRef(index: number, result: Vector3): void;
  67227. /**
  67228. * remove a particular agent previously created
  67229. * @param index agent index returned by addAgent
  67230. */
  67231. removeAgent(index: number): void;
  67232. /**
  67233. * get the list of all agents attached to this crowd
  67234. * @returns list of agent indices
  67235. */
  67236. getAgents(): number[];
  67237. /**
  67238. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67239. * @param deltaTime in seconds
  67240. */
  67241. update(deltaTime: number): void;
  67242. /**
  67243. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67244. * @param index agent index returned by addAgent
  67245. * @param destination targeted world position
  67246. */
  67247. agentGoto(index: number, destination: Vector3): void;
  67248. /**
  67249. * Teleport the agent to a new position
  67250. * @param index agent index returned by addAgent
  67251. * @param destination targeted world position
  67252. */
  67253. agentTeleport(index: number, destination: Vector3): void;
  67254. /**
  67255. * Update agent parameters
  67256. * @param index agent index returned by addAgent
  67257. * @param parameters agent parameters
  67258. */
  67259. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67260. /**
  67261. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67262. * The queries will try to find a solution within those bounds
  67263. * default is (1,1,1)
  67264. * @param extent x,y,z value that define the extent around the queries point of reference
  67265. */
  67266. setDefaultQueryExtent(extent: Vector3): void;
  67267. /**
  67268. * Get the Bounding box extent specified by setDefaultQueryExtent
  67269. * @returns the box extent values
  67270. */
  67271. getDefaultQueryExtent(): Vector3;
  67272. /**
  67273. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67274. * @param result output the box extent values
  67275. */
  67276. getDefaultQueryExtentToRef(result: Vector3): void;
  67277. /**
  67278. * Release all resources
  67279. */
  67280. dispose(): void;
  67281. }
  67282. /**
  67283. * Configures an agent
  67284. */
  67285. export interface IAgentParameters {
  67286. /**
  67287. * Agent radius. [Limit: >= 0]
  67288. */
  67289. radius: number;
  67290. /**
  67291. * Agent height. [Limit: > 0]
  67292. */
  67293. height: number;
  67294. /**
  67295. * Maximum allowed acceleration. [Limit: >= 0]
  67296. */
  67297. maxAcceleration: number;
  67298. /**
  67299. * Maximum allowed speed. [Limit: >= 0]
  67300. */
  67301. maxSpeed: number;
  67302. /**
  67303. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67304. */
  67305. collisionQueryRange: number;
  67306. /**
  67307. * The path visibility optimization range. [Limit: > 0]
  67308. */
  67309. pathOptimizationRange: number;
  67310. /**
  67311. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67312. */
  67313. separationWeight: number;
  67314. }
  67315. /**
  67316. * Configures the navigation mesh creation
  67317. */
  67318. export interface INavMeshParameters {
  67319. /**
  67320. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67321. */
  67322. cs: number;
  67323. /**
  67324. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67325. */
  67326. ch: number;
  67327. /**
  67328. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67329. */
  67330. walkableSlopeAngle: number;
  67331. /**
  67332. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67333. * be considered walkable. [Limit: >= 3] [Units: vx]
  67334. */
  67335. walkableHeight: number;
  67336. /**
  67337. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67338. */
  67339. walkableClimb: number;
  67340. /**
  67341. * The distance to erode/shrink the walkable area of the heightfield away from
  67342. * obstructions. [Limit: >=0] [Units: vx]
  67343. */
  67344. walkableRadius: number;
  67345. /**
  67346. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67347. */
  67348. maxEdgeLen: number;
  67349. /**
  67350. * The maximum distance a simplfied contour's border edges should deviate
  67351. * the original raw contour. [Limit: >=0] [Units: vx]
  67352. */
  67353. maxSimplificationError: number;
  67354. /**
  67355. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67356. */
  67357. minRegionArea: number;
  67358. /**
  67359. * Any regions with a span count smaller than this value will, if possible,
  67360. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67361. */
  67362. mergeRegionArea: number;
  67363. /**
  67364. * The maximum number of vertices allowed for polygons generated during the
  67365. * contour to polygon conversion process. [Limit: >= 3]
  67366. */
  67367. maxVertsPerPoly: number;
  67368. /**
  67369. * Sets the sampling distance to use when generating the detail mesh.
  67370. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67371. */
  67372. detailSampleDist: number;
  67373. /**
  67374. * The maximum distance the detail mesh surface should deviate from heightfield
  67375. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67376. */
  67377. detailSampleMaxError: number;
  67378. }
  67379. }
  67380. declare module BABYLON {
  67381. /**
  67382. * RecastJS navigation plugin
  67383. */
  67384. export class RecastJSPlugin implements INavigationEnginePlugin {
  67385. /**
  67386. * Reference to the Recast library
  67387. */
  67388. bjsRECAST: any;
  67389. /**
  67390. * plugin name
  67391. */
  67392. name: string;
  67393. /**
  67394. * the first navmesh created. We might extend this to support multiple navmeshes
  67395. */
  67396. navMesh: any;
  67397. /**
  67398. * Initializes the recastJS plugin
  67399. * @param recastInjection can be used to inject your own recast reference
  67400. */
  67401. constructor(recastInjection?: any);
  67402. /**
  67403. * Creates a navigation mesh
  67404. * @param meshes array of all the geometry used to compute the navigatio mesh
  67405. * @param parameters bunch of parameters used to filter geometry
  67406. */
  67407. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67408. /**
  67409. * Create a navigation mesh debug mesh
  67410. * @param scene is where the mesh will be added
  67411. * @returns debug display mesh
  67412. */
  67413. createDebugNavMesh(scene: Scene): Mesh;
  67414. /**
  67415. * Get a navigation mesh constrained position, closest to the parameter position
  67416. * @param position world position
  67417. * @returns the closest point to position constrained by the navigation mesh
  67418. */
  67419. getClosestPoint(position: Vector3): Vector3;
  67420. /**
  67421. * Get a navigation mesh constrained position, closest to the parameter position
  67422. * @param position world position
  67423. * @param result output the closest point to position constrained by the navigation mesh
  67424. */
  67425. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67426. /**
  67427. * Get a navigation mesh constrained position, within a particular radius
  67428. * @param position world position
  67429. * @param maxRadius the maximum distance to the constrained world position
  67430. * @returns the closest point to position constrained by the navigation mesh
  67431. */
  67432. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67433. /**
  67434. * Get a navigation mesh constrained position, within a particular radius
  67435. * @param position world position
  67436. * @param maxRadius the maximum distance to the constrained world position
  67437. * @param result output the closest point to position constrained by the navigation mesh
  67438. */
  67439. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67440. /**
  67441. * Compute the final position from a segment made of destination-position
  67442. * @param position world position
  67443. * @param destination world position
  67444. * @returns the resulting point along the navmesh
  67445. */
  67446. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67447. /**
  67448. * Compute the final position from a segment made of destination-position
  67449. * @param position world position
  67450. * @param destination world position
  67451. * @param result output the resulting point along the navmesh
  67452. */
  67453. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67454. /**
  67455. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67456. * @param start world position
  67457. * @param end world position
  67458. * @returns array containing world position composing the path
  67459. */
  67460. computePath(start: Vector3, end: Vector3): Vector3[];
  67461. /**
  67462. * Create a new Crowd so you can add agents
  67463. * @param maxAgents the maximum agent count in the crowd
  67464. * @param maxAgentRadius the maximum radius an agent can have
  67465. * @param scene to attach the crowd to
  67466. * @returns the crowd you can add agents to
  67467. */
  67468. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67469. /**
  67470. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67471. * The queries will try to find a solution within those bounds
  67472. * default is (1,1,1)
  67473. * @param extent x,y,z value that define the extent around the queries point of reference
  67474. */
  67475. setDefaultQueryExtent(extent: Vector3): void;
  67476. /**
  67477. * Get the Bounding box extent specified by setDefaultQueryExtent
  67478. * @returns the box extent values
  67479. */
  67480. getDefaultQueryExtent(): Vector3;
  67481. /**
  67482. * build the navmesh from a previously saved state using getNavmeshData
  67483. * @param data the Uint8Array returned by getNavmeshData
  67484. */
  67485. buildFromNavmeshData(data: Uint8Array): void;
  67486. /**
  67487. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67488. * @returns data the Uint8Array that can be saved and reused
  67489. */
  67490. getNavmeshData(): Uint8Array;
  67491. /**
  67492. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67493. * @param result output the box extent values
  67494. */
  67495. getDefaultQueryExtentToRef(result: Vector3): void;
  67496. /**
  67497. * Disposes
  67498. */
  67499. dispose(): void;
  67500. /**
  67501. * If this plugin is supported
  67502. * @returns true if plugin is supported
  67503. */
  67504. isSupported(): boolean;
  67505. }
  67506. /**
  67507. * Recast detour crowd implementation
  67508. */
  67509. export class RecastJSCrowd implements ICrowd {
  67510. /**
  67511. * Recast/detour plugin
  67512. */
  67513. bjsRECASTPlugin: RecastJSPlugin;
  67514. /**
  67515. * Link to the detour crowd
  67516. */
  67517. recastCrowd: any;
  67518. /**
  67519. * One transform per agent
  67520. */
  67521. transforms: TransformNode[];
  67522. /**
  67523. * All agents created
  67524. */
  67525. agents: number[];
  67526. /**
  67527. * Link to the scene is kept to unregister the crowd from the scene
  67528. */
  67529. private _scene;
  67530. /**
  67531. * Observer for crowd updates
  67532. */
  67533. private _onBeforeAnimationsObserver;
  67534. /**
  67535. * Constructor
  67536. * @param plugin recastJS plugin
  67537. * @param maxAgents the maximum agent count in the crowd
  67538. * @param maxAgentRadius the maximum radius an agent can have
  67539. * @param scene to attach the crowd to
  67540. * @returns the crowd you can add agents to
  67541. */
  67542. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67543. /**
  67544. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67545. * You can attach anything to that node. The node position is updated in the scene update tick.
  67546. * @param pos world position that will be constrained by the navigation mesh
  67547. * @param parameters agent parameters
  67548. * @param transform hooked to the agent that will be update by the scene
  67549. * @returns agent index
  67550. */
  67551. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67552. /**
  67553. * Returns the agent position in world space
  67554. * @param index agent index returned by addAgent
  67555. * @returns world space position
  67556. */
  67557. getAgentPosition(index: number): Vector3;
  67558. /**
  67559. * Returns the agent position result in world space
  67560. * @param index agent index returned by addAgent
  67561. * @param result output world space position
  67562. */
  67563. getAgentPositionToRef(index: number, result: Vector3): void;
  67564. /**
  67565. * Returns the agent velocity in world space
  67566. * @param index agent index returned by addAgent
  67567. * @returns world space velocity
  67568. */
  67569. getAgentVelocity(index: number): Vector3;
  67570. /**
  67571. * Returns the agent velocity result in world space
  67572. * @param index agent index returned by addAgent
  67573. * @param result output world space velocity
  67574. */
  67575. getAgentVelocityToRef(index: number, result: Vector3): void;
  67576. /**
  67577. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67578. * @param index agent index returned by addAgent
  67579. * @param destination targeted world position
  67580. */
  67581. agentGoto(index: number, destination: Vector3): void;
  67582. /**
  67583. * Teleport the agent to a new position
  67584. * @param index agent index returned by addAgent
  67585. * @param destination targeted world position
  67586. */
  67587. agentTeleport(index: number, destination: Vector3): void;
  67588. /**
  67589. * Update agent parameters
  67590. * @param index agent index returned by addAgent
  67591. * @param parameters agent parameters
  67592. */
  67593. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67594. /**
  67595. * remove a particular agent previously created
  67596. * @param index agent index returned by addAgent
  67597. */
  67598. removeAgent(index: number): void;
  67599. /**
  67600. * get the list of all agents attached to this crowd
  67601. * @returns list of agent indices
  67602. */
  67603. getAgents(): number[];
  67604. /**
  67605. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67606. * @param deltaTime in seconds
  67607. */
  67608. update(deltaTime: number): void;
  67609. /**
  67610. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67611. * The queries will try to find a solution within those bounds
  67612. * default is (1,1,1)
  67613. * @param extent x,y,z value that define the extent around the queries point of reference
  67614. */
  67615. setDefaultQueryExtent(extent: Vector3): void;
  67616. /**
  67617. * Get the Bounding box extent specified by setDefaultQueryExtent
  67618. * @returns the box extent values
  67619. */
  67620. getDefaultQueryExtent(): Vector3;
  67621. /**
  67622. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67623. * @param result output the box extent values
  67624. */
  67625. getDefaultQueryExtentToRef(result: Vector3): void;
  67626. /**
  67627. * Release all resources
  67628. */
  67629. dispose(): void;
  67630. }
  67631. }
  67632. declare module BABYLON {
  67633. /**
  67634. * Class used to enable access to IndexedDB
  67635. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67636. */
  67637. export class Database implements IOfflineProvider {
  67638. private _callbackManifestChecked;
  67639. private _currentSceneUrl;
  67640. private _db;
  67641. private _enableSceneOffline;
  67642. private _enableTexturesOffline;
  67643. private _manifestVersionFound;
  67644. private _mustUpdateRessources;
  67645. private _hasReachedQuota;
  67646. private _isSupported;
  67647. private _idbFactory;
  67648. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67649. private static IsUASupportingBlobStorage;
  67650. /**
  67651. * Gets a boolean indicating if Database storate is enabled (off by default)
  67652. */
  67653. static IDBStorageEnabled: boolean;
  67654. /**
  67655. * Gets a boolean indicating if scene must be saved in the database
  67656. */
  67657. get enableSceneOffline(): boolean;
  67658. /**
  67659. * Gets a boolean indicating if textures must be saved in the database
  67660. */
  67661. get enableTexturesOffline(): boolean;
  67662. /**
  67663. * Creates a new Database
  67664. * @param urlToScene defines the url to load the scene
  67665. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67666. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67667. */
  67668. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67669. private static _ParseURL;
  67670. private static _ReturnFullUrlLocation;
  67671. private _checkManifestFile;
  67672. /**
  67673. * Open the database and make it available
  67674. * @param successCallback defines the callback to call on success
  67675. * @param errorCallback defines the callback to call on error
  67676. */
  67677. open(successCallback: () => void, errorCallback: () => void): void;
  67678. /**
  67679. * Loads an image from the database
  67680. * @param url defines the url to load from
  67681. * @param image defines the target DOM image
  67682. */
  67683. loadImage(url: string, image: HTMLImageElement): void;
  67684. private _loadImageFromDBAsync;
  67685. private _saveImageIntoDBAsync;
  67686. private _checkVersionFromDB;
  67687. private _loadVersionFromDBAsync;
  67688. private _saveVersionIntoDBAsync;
  67689. /**
  67690. * Loads a file from database
  67691. * @param url defines the URL to load from
  67692. * @param sceneLoaded defines a callback to call on success
  67693. * @param progressCallBack defines a callback to call when progress changed
  67694. * @param errorCallback defines a callback to call on error
  67695. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  67696. */
  67697. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  67698. private _loadFileAsync;
  67699. private _saveFileAsync;
  67700. /**
  67701. * Validates if xhr data is correct
  67702. * @param xhr defines the request to validate
  67703. * @param dataType defines the expected data type
  67704. * @returns true if data is correct
  67705. */
  67706. private static _ValidateXHRData;
  67707. }
  67708. }
  67709. declare module BABYLON {
  67710. /** @hidden */
  67711. export var gpuUpdateParticlesPixelShader: {
  67712. name: string;
  67713. shader: string;
  67714. };
  67715. }
  67716. declare module BABYLON {
  67717. /** @hidden */
  67718. export var gpuUpdateParticlesVertexShader: {
  67719. name: string;
  67720. shader: string;
  67721. };
  67722. }
  67723. declare module BABYLON {
  67724. /** @hidden */
  67725. export var clipPlaneFragmentDeclaration2: {
  67726. name: string;
  67727. shader: string;
  67728. };
  67729. }
  67730. declare module BABYLON {
  67731. /** @hidden */
  67732. export var gpuRenderParticlesPixelShader: {
  67733. name: string;
  67734. shader: string;
  67735. };
  67736. }
  67737. declare module BABYLON {
  67738. /** @hidden */
  67739. export var clipPlaneVertexDeclaration2: {
  67740. name: string;
  67741. shader: string;
  67742. };
  67743. }
  67744. declare module BABYLON {
  67745. /** @hidden */
  67746. export var gpuRenderParticlesVertexShader: {
  67747. name: string;
  67748. shader: string;
  67749. };
  67750. }
  67751. declare module BABYLON {
  67752. /**
  67753. * This represents a GPU particle system in Babylon
  67754. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  67755. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  67756. */
  67757. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  67758. /**
  67759. * The layer mask we are rendering the particles through.
  67760. */
  67761. layerMask: number;
  67762. private _capacity;
  67763. private _activeCount;
  67764. private _currentActiveCount;
  67765. private _accumulatedCount;
  67766. private _renderEffect;
  67767. private _updateEffect;
  67768. private _buffer0;
  67769. private _buffer1;
  67770. private _spriteBuffer;
  67771. private _updateVAO;
  67772. private _renderVAO;
  67773. private _targetIndex;
  67774. private _sourceBuffer;
  67775. private _targetBuffer;
  67776. private _currentRenderId;
  67777. private _started;
  67778. private _stopped;
  67779. private _timeDelta;
  67780. private _randomTexture;
  67781. private _randomTexture2;
  67782. private _attributesStrideSize;
  67783. private _updateEffectOptions;
  67784. private _randomTextureSize;
  67785. private _actualFrame;
  67786. private _customEffect;
  67787. private readonly _rawTextureWidth;
  67788. /**
  67789. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  67790. */
  67791. static get IsSupported(): boolean;
  67792. /**
  67793. * An event triggered when the system is disposed.
  67794. */
  67795. onDisposeObservable: Observable<IParticleSystem>;
  67796. /**
  67797. * Gets the maximum number of particles active at the same time.
  67798. * @returns The max number of active particles.
  67799. */
  67800. getCapacity(): number;
  67801. /**
  67802. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  67803. * to override the particles.
  67804. */
  67805. forceDepthWrite: boolean;
  67806. /**
  67807. * Gets or set the number of active particles
  67808. */
  67809. get activeParticleCount(): number;
  67810. set activeParticleCount(value: number);
  67811. private _preWarmDone;
  67812. /**
  67813. * Specifies if the particles are updated in emitter local space or world space.
  67814. */
  67815. isLocal: boolean;
  67816. /** Gets or sets a matrix to use to compute projection */
  67817. defaultProjectionMatrix: Matrix;
  67818. /**
  67819. * Is this system ready to be used/rendered
  67820. * @return true if the system is ready
  67821. */
  67822. isReady(): boolean;
  67823. /**
  67824. * Gets if the system has been started. (Note: this will still be true after stop is called)
  67825. * @returns True if it has been started, otherwise false.
  67826. */
  67827. isStarted(): boolean;
  67828. /**
  67829. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  67830. * @returns True if it has been stopped, otherwise false.
  67831. */
  67832. isStopped(): boolean;
  67833. /**
  67834. * Gets a boolean indicating that the system is stopping
  67835. * @returns true if the system is currently stopping
  67836. */
  67837. isStopping(): boolean;
  67838. /**
  67839. * Gets the number of particles active at the same time.
  67840. * @returns The number of active particles.
  67841. */
  67842. getActiveCount(): number;
  67843. /**
  67844. * Starts the particle system and begins to emit
  67845. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  67846. */
  67847. start(delay?: number): void;
  67848. /**
  67849. * Stops the particle system.
  67850. */
  67851. stop(): void;
  67852. /**
  67853. * Remove all active particles
  67854. */
  67855. reset(): void;
  67856. /**
  67857. * Returns the string "GPUParticleSystem"
  67858. * @returns a string containing the class name
  67859. */
  67860. getClassName(): string;
  67861. /**
  67862. * Gets the custom effect used to render the particles
  67863. * @param blendMode Blend mode for which the effect should be retrieved
  67864. * @returns The effect
  67865. */
  67866. getCustomEffect(blendMode?: number): Nullable<Effect>;
  67867. /**
  67868. * Sets the custom effect used to render the particles
  67869. * @param effect The effect to set
  67870. * @param blendMode Blend mode for which the effect should be set
  67871. */
  67872. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  67873. /** @hidden */
  67874. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  67875. /**
  67876. * Observable that will be called just before the particles are drawn
  67877. */
  67878. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  67879. /**
  67880. * Gets the name of the particle vertex shader
  67881. */
  67882. get vertexShaderName(): string;
  67883. private _colorGradientsTexture;
  67884. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  67885. /**
  67886. * Adds a new color gradient
  67887. * @param gradient defines the gradient to use (between 0 and 1)
  67888. * @param color1 defines the color to affect to the specified gradient
  67889. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  67890. * @returns the current particle system
  67891. */
  67892. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  67893. private _refreshColorGradient;
  67894. /** Force the system to rebuild all gradients that need to be resync */
  67895. forceRefreshGradients(): void;
  67896. /**
  67897. * Remove a specific color gradient
  67898. * @param gradient defines the gradient to remove
  67899. * @returns the current particle system
  67900. */
  67901. removeColorGradient(gradient: number): GPUParticleSystem;
  67902. private _angularSpeedGradientsTexture;
  67903. private _sizeGradientsTexture;
  67904. private _velocityGradientsTexture;
  67905. private _limitVelocityGradientsTexture;
  67906. private _dragGradientsTexture;
  67907. private _addFactorGradient;
  67908. /**
  67909. * Adds a new size gradient
  67910. * @param gradient defines the gradient to use (between 0 and 1)
  67911. * @param factor defines the size factor to affect to the specified gradient
  67912. * @returns the current particle system
  67913. */
  67914. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  67915. /**
  67916. * Remove a specific size gradient
  67917. * @param gradient defines the gradient to remove
  67918. * @returns the current particle system
  67919. */
  67920. removeSizeGradient(gradient: number): GPUParticleSystem;
  67921. private _refreshFactorGradient;
  67922. /**
  67923. * Adds a new angular speed gradient
  67924. * @param gradient defines the gradient to use (between 0 and 1)
  67925. * @param factor defines the angular speed to affect to the specified gradient
  67926. * @returns the current particle system
  67927. */
  67928. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  67929. /**
  67930. * Remove a specific angular speed gradient
  67931. * @param gradient defines the gradient to remove
  67932. * @returns the current particle system
  67933. */
  67934. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  67935. /**
  67936. * Adds a new velocity gradient
  67937. * @param gradient defines the gradient to use (between 0 and 1)
  67938. * @param factor defines the velocity to affect to the specified gradient
  67939. * @returns the current particle system
  67940. */
  67941. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67942. /**
  67943. * Remove a specific velocity gradient
  67944. * @param gradient defines the gradient to remove
  67945. * @returns the current particle system
  67946. */
  67947. removeVelocityGradient(gradient: number): GPUParticleSystem;
  67948. /**
  67949. * Adds a new limit velocity gradient
  67950. * @param gradient defines the gradient to use (between 0 and 1)
  67951. * @param factor defines the limit velocity value to affect to the specified gradient
  67952. * @returns the current particle system
  67953. */
  67954. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  67955. /**
  67956. * Remove a specific limit velocity gradient
  67957. * @param gradient defines the gradient to remove
  67958. * @returns the current particle system
  67959. */
  67960. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  67961. /**
  67962. * Adds a new drag gradient
  67963. * @param gradient defines the gradient to use (between 0 and 1)
  67964. * @param factor defines the drag value to affect to the specified gradient
  67965. * @returns the current particle system
  67966. */
  67967. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  67968. /**
  67969. * Remove a specific drag gradient
  67970. * @param gradient defines the gradient to remove
  67971. * @returns the current particle system
  67972. */
  67973. removeDragGradient(gradient: number): GPUParticleSystem;
  67974. /**
  67975. * Not supported by GPUParticleSystem
  67976. * @param gradient defines the gradient to use (between 0 and 1)
  67977. * @param factor defines the emit rate value to affect to the specified gradient
  67978. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67979. * @returns the current particle system
  67980. */
  67981. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67982. /**
  67983. * Not supported by GPUParticleSystem
  67984. * @param gradient defines the gradient to remove
  67985. * @returns the current particle system
  67986. */
  67987. removeEmitRateGradient(gradient: number): IParticleSystem;
  67988. /**
  67989. * Not supported by GPUParticleSystem
  67990. * @param gradient defines the gradient to use (between 0 and 1)
  67991. * @param factor defines the start size value to affect to the specified gradient
  67992. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  67993. * @returns the current particle system
  67994. */
  67995. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  67996. /**
  67997. * Not supported by GPUParticleSystem
  67998. * @param gradient defines the gradient to remove
  67999. * @returns the current particle system
  68000. */
  68001. removeStartSizeGradient(gradient: number): IParticleSystem;
  68002. /**
  68003. * Not supported by GPUParticleSystem
  68004. * @param gradient defines the gradient to use (between 0 and 1)
  68005. * @param min defines the color remap minimal range
  68006. * @param max defines the color remap maximal range
  68007. * @returns the current particle system
  68008. */
  68009. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68010. /**
  68011. * Not supported by GPUParticleSystem
  68012. * @param gradient defines the gradient to remove
  68013. * @returns the current particle system
  68014. */
  68015. removeColorRemapGradient(): IParticleSystem;
  68016. /**
  68017. * Not supported by GPUParticleSystem
  68018. * @param gradient defines the gradient to use (between 0 and 1)
  68019. * @param min defines the alpha remap minimal range
  68020. * @param max defines the alpha remap maximal range
  68021. * @returns the current particle system
  68022. */
  68023. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68024. /**
  68025. * Not supported by GPUParticleSystem
  68026. * @param gradient defines the gradient to remove
  68027. * @returns the current particle system
  68028. */
  68029. removeAlphaRemapGradient(): IParticleSystem;
  68030. /**
  68031. * Not supported by GPUParticleSystem
  68032. * @param gradient defines the gradient to use (between 0 and 1)
  68033. * @param color defines the color to affect to the specified gradient
  68034. * @returns the current particle system
  68035. */
  68036. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68037. /**
  68038. * Not supported by GPUParticleSystem
  68039. * @param gradient defines the gradient to remove
  68040. * @returns the current particle system
  68041. */
  68042. removeRampGradient(): IParticleSystem;
  68043. /**
  68044. * Not supported by GPUParticleSystem
  68045. * @returns the list of ramp gradients
  68046. */
  68047. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68048. /**
  68049. * Not supported by GPUParticleSystem
  68050. * Gets or sets a boolean indicating that ramp gradients must be used
  68051. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68052. */
  68053. get useRampGradients(): boolean;
  68054. set useRampGradients(value: boolean);
  68055. /**
  68056. * Not supported by GPUParticleSystem
  68057. * @param gradient defines the gradient to use (between 0 and 1)
  68058. * @param factor defines the life time factor to affect to the specified gradient
  68059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68060. * @returns the current particle system
  68061. */
  68062. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68063. /**
  68064. * Not supported by GPUParticleSystem
  68065. * @param gradient defines the gradient to remove
  68066. * @returns the current particle system
  68067. */
  68068. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68069. /**
  68070. * Instantiates a GPU particle system.
  68071. * 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.
  68072. * @param name The name of the particle system
  68073. * @param options The options used to create the system
  68074. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68075. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68076. * @param customEffect a custom effect used to change the way particles are rendered by default
  68077. */
  68078. constructor(name: string, options: Partial<{
  68079. capacity: number;
  68080. randomTextureSize: number;
  68081. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68082. protected _reset(): void;
  68083. private _createUpdateVAO;
  68084. private _createRenderVAO;
  68085. private _initialize;
  68086. /** @hidden */
  68087. _recreateUpdateEffect(): void;
  68088. private _getEffect;
  68089. /**
  68090. * Fill the defines array according to the current settings of the particle system
  68091. * @param defines Array to be updated
  68092. * @param blendMode blend mode to take into account when updating the array
  68093. */
  68094. fillDefines(defines: Array<string>, blendMode?: number): void;
  68095. /**
  68096. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68097. * @param uniforms Uniforms array to fill
  68098. * @param attributes Attributes array to fill
  68099. * @param samplers Samplers array to fill
  68100. */
  68101. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68102. /** @hidden */
  68103. _recreateRenderEffect(): Effect;
  68104. /**
  68105. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68106. * @param preWarm defines if we are in the pre-warmimg phase
  68107. */
  68108. animate(preWarm?: boolean): void;
  68109. private _createFactorGradientTexture;
  68110. private _createSizeGradientTexture;
  68111. private _createAngularSpeedGradientTexture;
  68112. private _createVelocityGradientTexture;
  68113. private _createLimitVelocityGradientTexture;
  68114. private _createDragGradientTexture;
  68115. private _createColorGradientTexture;
  68116. /**
  68117. * Renders the particle system in its current state
  68118. * @param preWarm defines if the system should only update the particles but not render them
  68119. * @returns the current number of particles
  68120. */
  68121. render(preWarm?: boolean): number;
  68122. /**
  68123. * Rebuilds the particle system
  68124. */
  68125. rebuild(): void;
  68126. private _releaseBuffers;
  68127. private _releaseVAOs;
  68128. /**
  68129. * Disposes the particle system and free the associated resources
  68130. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68131. */
  68132. dispose(disposeTexture?: boolean): void;
  68133. /**
  68134. * Clones the particle system.
  68135. * @param name The name of the cloned object
  68136. * @param newEmitter The new emitter to use
  68137. * @returns the cloned particle system
  68138. */
  68139. clone(name: string, newEmitter: any): GPUParticleSystem;
  68140. /**
  68141. * Serializes the particle system to a JSON object
  68142. * @param serializeTexture defines if the texture must be serialized as well
  68143. * @returns the JSON object
  68144. */
  68145. serialize(serializeTexture?: boolean): any;
  68146. /**
  68147. * Parses a JSON object to create a GPU particle system.
  68148. * @param parsedParticleSystem The JSON object to parse
  68149. * @param sceneOrEngine The scene or the engine to create the particle system in
  68150. * @param rootUrl The root url to use to load external dependencies like texture
  68151. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68152. * @returns the parsed GPU particle system
  68153. */
  68154. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68155. }
  68156. }
  68157. declare module BABYLON {
  68158. /**
  68159. * Represents a set of particle systems working together to create a specific effect
  68160. */
  68161. export class ParticleSystemSet implements IDisposable {
  68162. /**
  68163. * Gets or sets base Assets URL
  68164. */
  68165. static BaseAssetsUrl: string;
  68166. private _emitterCreationOptions;
  68167. private _emitterNode;
  68168. /**
  68169. * Gets the particle system list
  68170. */
  68171. systems: IParticleSystem[];
  68172. /**
  68173. * Gets the emitter node used with this set
  68174. */
  68175. get emitterNode(): Nullable<TransformNode>;
  68176. /**
  68177. * Creates a new emitter mesh as a sphere
  68178. * @param options defines the options used to create the sphere
  68179. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68180. * @param scene defines the hosting scene
  68181. */
  68182. setEmitterAsSphere(options: {
  68183. diameter: number;
  68184. segments: number;
  68185. color: Color3;
  68186. }, renderingGroupId: number, scene: Scene): void;
  68187. /**
  68188. * Starts all particle systems of the set
  68189. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68190. */
  68191. start(emitter?: AbstractMesh): void;
  68192. /**
  68193. * Release all associated resources
  68194. */
  68195. dispose(): void;
  68196. /**
  68197. * Serialize the set into a JSON compatible object
  68198. * @param serializeTexture defines if the texture must be serialized as well
  68199. * @returns a JSON compatible representation of the set
  68200. */
  68201. serialize(serializeTexture?: boolean): any;
  68202. /**
  68203. * Parse a new ParticleSystemSet from a serialized source
  68204. * @param data defines a JSON compatible representation of the set
  68205. * @param scene defines the hosting scene
  68206. * @param gpu defines if we want GPU particles or CPU particles
  68207. * @returns a new ParticleSystemSet
  68208. */
  68209. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68210. }
  68211. }
  68212. declare module BABYLON {
  68213. /**
  68214. * This class is made for on one-liner static method to help creating particle system set.
  68215. */
  68216. export class ParticleHelper {
  68217. /**
  68218. * Gets or sets base Assets URL
  68219. */
  68220. static BaseAssetsUrl: string;
  68221. /** Define the Url to load snippets */
  68222. static SnippetUrl: string;
  68223. /**
  68224. * Create a default particle system that you can tweak
  68225. * @param emitter defines the emitter to use
  68226. * @param capacity defines the system capacity (default is 500 particles)
  68227. * @param scene defines the hosting scene
  68228. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68229. * @returns the new Particle system
  68230. */
  68231. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68232. /**
  68233. * This is the main static method (one-liner) of this helper to create different particle systems
  68234. * @param type This string represents the type to the particle system to create
  68235. * @param scene The scene where the particle system should live
  68236. * @param gpu If the system will use gpu
  68237. * @returns the ParticleSystemSet created
  68238. */
  68239. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68240. /**
  68241. * Static function used to export a particle system to a ParticleSystemSet variable.
  68242. * Please note that the emitter shape is not exported
  68243. * @param systems defines the particle systems to export
  68244. * @returns the created particle system set
  68245. */
  68246. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68247. /**
  68248. * Creates a particle system from a snippet saved in a remote file
  68249. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68250. * @param url defines the url to load from
  68251. * @param scene defines the hosting scene
  68252. * @param gpu If the system will use gpu
  68253. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68254. * @returns a promise that will resolve to the new particle system
  68255. */
  68256. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68257. /**
  68258. * Creates a particle system from a snippet saved by the particle system editor
  68259. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68260. * @param scene defines the hosting scene
  68261. * @param gpu If the system will use gpu
  68262. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68263. * @returns a promise that will resolve to the new particle system
  68264. */
  68265. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68266. }
  68267. }
  68268. declare module BABYLON {
  68269. interface Engine {
  68270. /**
  68271. * Create an effect to use with particle systems.
  68272. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68273. * the particle system for which you want to create a custom effect in the last parameter
  68274. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68275. * @param uniformsNames defines a list of attribute names
  68276. * @param samplers defines an array of string used to represent textures
  68277. * @param defines defines the string containing the defines to use to compile the shaders
  68278. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68279. * @param onCompiled defines a function to call when the effect creation is successful
  68280. * @param onError defines a function to call when the effect creation has failed
  68281. * @param particleSystem the particle system you want to create the effect for
  68282. * @returns the new Effect
  68283. */
  68284. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68285. }
  68286. interface Mesh {
  68287. /**
  68288. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68289. * @returns an array of IParticleSystem
  68290. */
  68291. getEmittedParticleSystems(): IParticleSystem[];
  68292. /**
  68293. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68294. * @returns an array of IParticleSystem
  68295. */
  68296. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68297. }
  68298. }
  68299. declare module BABYLON {
  68300. /** Defines the 4 color options */
  68301. export enum PointColor {
  68302. /** color value */
  68303. Color = 2,
  68304. /** uv value */
  68305. UV = 1,
  68306. /** random value */
  68307. Random = 0,
  68308. /** stated value */
  68309. Stated = 3
  68310. }
  68311. /**
  68312. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68313. * 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.
  68314. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68315. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68316. *
  68317. * Full documentation here : TO BE ENTERED
  68318. */
  68319. export class PointsCloudSystem implements IDisposable {
  68320. /**
  68321. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68322. * Example : var p = SPS.particles[i];
  68323. */
  68324. particles: CloudPoint[];
  68325. /**
  68326. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68327. */
  68328. nbParticles: number;
  68329. /**
  68330. * This a counter for your own usage. It's not set by any SPS functions.
  68331. */
  68332. counter: number;
  68333. /**
  68334. * The PCS name. This name is also given to the underlying mesh.
  68335. */
  68336. name: string;
  68337. /**
  68338. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68339. */
  68340. mesh: Mesh;
  68341. /**
  68342. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68343. * Please read :
  68344. */
  68345. vars: any;
  68346. /**
  68347. * @hidden
  68348. */
  68349. _size: number;
  68350. private _scene;
  68351. private _promises;
  68352. private _positions;
  68353. private _indices;
  68354. private _normals;
  68355. private _colors;
  68356. private _uvs;
  68357. private _indices32;
  68358. private _positions32;
  68359. private _colors32;
  68360. private _uvs32;
  68361. private _updatable;
  68362. private _isVisibilityBoxLocked;
  68363. private _alwaysVisible;
  68364. private _groups;
  68365. private _groupCounter;
  68366. private _computeParticleColor;
  68367. private _computeParticleTexture;
  68368. private _computeParticleRotation;
  68369. private _computeBoundingBox;
  68370. private _isReady;
  68371. /**
  68372. * Creates a PCS (Points Cloud System) object
  68373. * @param name (String) is the PCS name, this will be the underlying mesh name
  68374. * @param pointSize (number) is the size for each point
  68375. * @param scene (Scene) is the scene in which the PCS is added
  68376. * @param options defines the options of the PCS e.g.
  68377. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68378. */
  68379. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68380. updatable?: boolean;
  68381. });
  68382. /**
  68383. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68384. * If no points were added to the PCS, the returned mesh is just a single point.
  68385. * @returns a promise for the created mesh
  68386. */
  68387. buildMeshAsync(): Promise<Mesh>;
  68388. /**
  68389. * @hidden
  68390. */
  68391. private _buildMesh;
  68392. private _addParticle;
  68393. private _randomUnitVector;
  68394. private _getColorIndicesForCoord;
  68395. private _setPointsColorOrUV;
  68396. private _colorFromTexture;
  68397. private _calculateDensity;
  68398. /**
  68399. * Adds points to the PCS in random positions within a unit sphere
  68400. * @param nb (positive integer) the number of particles to be created from this model
  68401. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68402. * @returns the number of groups in the system
  68403. */
  68404. addPoints(nb: number, pointFunction?: any): number;
  68405. /**
  68406. * Adds points to the PCS from the surface of the model shape
  68407. * @param mesh is any Mesh object that will be used as a surface model for the points
  68408. * @param nb (positive integer) the number of particles to be created from this model
  68409. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68410. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68411. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68412. * @returns the number of groups in the system
  68413. */
  68414. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68415. /**
  68416. * Adds points to the PCS inside the model shape
  68417. * @param mesh is any Mesh object that will be used as a surface model for the points
  68418. * @param nb (positive integer) the number of particles to be created from this model
  68419. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68420. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68421. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68422. * @returns the number of groups in the system
  68423. */
  68424. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68425. /**
  68426. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68427. * This method calls `updateParticle()` for each particle of the SPS.
  68428. * For an animated SPS, it is usually called within the render loop.
  68429. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68430. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68431. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68432. * @returns the PCS.
  68433. */
  68434. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68435. /**
  68436. * Disposes the PCS.
  68437. */
  68438. dispose(): void;
  68439. /**
  68440. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68441. * doc :
  68442. * @returns the PCS.
  68443. */
  68444. refreshVisibleSize(): PointsCloudSystem;
  68445. /**
  68446. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68447. * @param size the size (float) of the visibility box
  68448. * note : this doesn't lock the PCS mesh bounding box.
  68449. * doc :
  68450. */
  68451. setVisibilityBox(size: number): void;
  68452. /**
  68453. * Gets whether the PCS is always visible or not
  68454. * doc :
  68455. */
  68456. get isAlwaysVisible(): boolean;
  68457. /**
  68458. * Sets the PCS as always visible or not
  68459. * doc :
  68460. */
  68461. set isAlwaysVisible(val: boolean);
  68462. /**
  68463. * Tells to `setParticles()` to compute the particle rotations or not
  68464. * Default value : false. The PCS is faster when it's set to false
  68465. * Note : particle rotations are only applied to parent particles
  68466. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68467. */
  68468. set computeParticleRotation(val: boolean);
  68469. /**
  68470. * Tells to `setParticles()` to compute the particle colors or not.
  68471. * Default value : true. The PCS is faster when it's set to false.
  68472. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68473. */
  68474. set computeParticleColor(val: boolean);
  68475. set computeParticleTexture(val: boolean);
  68476. /**
  68477. * Gets if `setParticles()` computes the particle colors or not.
  68478. * Default value : false. The PCS is faster when it's set to false.
  68479. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68480. */
  68481. get computeParticleColor(): boolean;
  68482. /**
  68483. * Gets if `setParticles()` computes the particle textures or not.
  68484. * Default value : false. The PCS is faster when it's set to false.
  68485. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68486. */
  68487. get computeParticleTexture(): boolean;
  68488. /**
  68489. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68490. */
  68491. set computeBoundingBox(val: boolean);
  68492. /**
  68493. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68494. */
  68495. get computeBoundingBox(): boolean;
  68496. /**
  68497. * This function does nothing. It may be overwritten to set all the particle first values.
  68498. * The PCS doesn't call this function, you may have to call it by your own.
  68499. * doc :
  68500. */
  68501. initParticles(): void;
  68502. /**
  68503. * This function does nothing. It may be overwritten to recycle a particle
  68504. * The PCS doesn't call this function, you can to call it
  68505. * doc :
  68506. * @param particle The particle to recycle
  68507. * @returns the recycled particle
  68508. */
  68509. recycleParticle(particle: CloudPoint): CloudPoint;
  68510. /**
  68511. * Updates a particle : this function should be overwritten by the user.
  68512. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68513. * doc :
  68514. * @example : just set a particle position or velocity and recycle conditions
  68515. * @param particle The particle to update
  68516. * @returns the updated particle
  68517. */
  68518. updateParticle(particle: CloudPoint): CloudPoint;
  68519. /**
  68520. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68521. * This does nothing and may be overwritten by the user.
  68522. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68523. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68524. * @param update the boolean update value actually passed to setParticles()
  68525. */
  68526. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68527. /**
  68528. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68529. * This will be passed three parameters.
  68530. * This does nothing and may be overwritten by the user.
  68531. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68532. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68533. * @param update the boolean update value actually passed to setParticles()
  68534. */
  68535. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68536. }
  68537. }
  68538. declare module BABYLON {
  68539. /**
  68540. * Represents one particle of a points cloud system.
  68541. */
  68542. export class CloudPoint {
  68543. /**
  68544. * particle global index
  68545. */
  68546. idx: number;
  68547. /**
  68548. * The color of the particle
  68549. */
  68550. color: Nullable<Color4>;
  68551. /**
  68552. * The world space position of the particle.
  68553. */
  68554. position: Vector3;
  68555. /**
  68556. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68557. */
  68558. rotation: Vector3;
  68559. /**
  68560. * The world space rotation quaternion of the particle.
  68561. */
  68562. rotationQuaternion: Nullable<Quaternion>;
  68563. /**
  68564. * The uv of the particle.
  68565. */
  68566. uv: Nullable<Vector2>;
  68567. /**
  68568. * The current speed of the particle.
  68569. */
  68570. velocity: Vector3;
  68571. /**
  68572. * The pivot point in the particle local space.
  68573. */
  68574. pivot: Vector3;
  68575. /**
  68576. * Must the particle be translated from its pivot point in its local space ?
  68577. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68578. * Default : false
  68579. */
  68580. translateFromPivot: boolean;
  68581. /**
  68582. * Index of this particle in the global "positions" array (Internal use)
  68583. * @hidden
  68584. */
  68585. _pos: number;
  68586. /**
  68587. * @hidden Index of this particle in the global "indices" array (Internal use)
  68588. */
  68589. _ind: number;
  68590. /**
  68591. * Group this particle belongs to
  68592. */
  68593. _group: PointsGroup;
  68594. /**
  68595. * Group id of this particle
  68596. */
  68597. groupId: number;
  68598. /**
  68599. * Index of the particle in its group id (Internal use)
  68600. */
  68601. idxInGroup: number;
  68602. /**
  68603. * @hidden Particle BoundingInfo object (Internal use)
  68604. */
  68605. _boundingInfo: BoundingInfo;
  68606. /**
  68607. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68608. */
  68609. _pcs: PointsCloudSystem;
  68610. /**
  68611. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68612. */
  68613. _stillInvisible: boolean;
  68614. /**
  68615. * @hidden Last computed particle rotation matrix
  68616. */
  68617. _rotationMatrix: number[];
  68618. /**
  68619. * Parent particle Id, if any.
  68620. * Default null.
  68621. */
  68622. parentId: Nullable<number>;
  68623. /**
  68624. * @hidden Internal global position in the PCS.
  68625. */
  68626. _globalPosition: Vector3;
  68627. /**
  68628. * Creates a Point Cloud object.
  68629. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68630. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68631. * @param group (PointsGroup) is the group the particle belongs to
  68632. * @param groupId (integer) is the group identifier in the PCS.
  68633. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68634. * @param pcs defines the PCS it is associated to
  68635. */
  68636. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68637. /**
  68638. * get point size
  68639. */
  68640. get size(): Vector3;
  68641. /**
  68642. * Set point size
  68643. */
  68644. set size(scale: Vector3);
  68645. /**
  68646. * Legacy support, changed quaternion to rotationQuaternion
  68647. */
  68648. get quaternion(): Nullable<Quaternion>;
  68649. /**
  68650. * Legacy support, changed quaternion to rotationQuaternion
  68651. */
  68652. set quaternion(q: Nullable<Quaternion>);
  68653. /**
  68654. * Returns a boolean. True if the particle intersects a mesh, else false
  68655. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68656. * @param target is the object (point or mesh) what the intersection is computed against
  68657. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68658. * @returns true if it intersects
  68659. */
  68660. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68661. /**
  68662. * get the rotation matrix of the particle
  68663. * @hidden
  68664. */
  68665. getRotationMatrix(m: Matrix): void;
  68666. }
  68667. /**
  68668. * Represents a group of points in a points cloud system
  68669. * * PCS internal tool, don't use it manually.
  68670. */
  68671. export class PointsGroup {
  68672. /**
  68673. * The group id
  68674. * @hidden
  68675. */
  68676. groupID: number;
  68677. /**
  68678. * image data for group (internal use)
  68679. * @hidden
  68680. */
  68681. _groupImageData: Nullable<ArrayBufferView>;
  68682. /**
  68683. * Image Width (internal use)
  68684. * @hidden
  68685. */
  68686. _groupImgWidth: number;
  68687. /**
  68688. * Image Height (internal use)
  68689. * @hidden
  68690. */
  68691. _groupImgHeight: number;
  68692. /**
  68693. * Custom position function (internal use)
  68694. * @hidden
  68695. */
  68696. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  68697. /**
  68698. * density per facet for surface points
  68699. * @hidden
  68700. */
  68701. _groupDensity: number[];
  68702. /**
  68703. * Only when points are colored by texture carries pointer to texture list array
  68704. * @hidden
  68705. */
  68706. _textureNb: number;
  68707. /**
  68708. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  68709. * PCS internal tool, don't use it manually.
  68710. * @hidden
  68711. */
  68712. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  68713. }
  68714. }
  68715. declare module BABYLON {
  68716. interface Scene {
  68717. /** @hidden (Backing field) */
  68718. _physicsEngine: Nullable<IPhysicsEngine>;
  68719. /** @hidden */
  68720. _physicsTimeAccumulator: number;
  68721. /**
  68722. * Gets the current physics engine
  68723. * @returns a IPhysicsEngine or null if none attached
  68724. */
  68725. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  68726. /**
  68727. * Enables physics to the current scene
  68728. * @param gravity defines the scene's gravity for the physics engine
  68729. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  68730. * @return a boolean indicating if the physics engine was initialized
  68731. */
  68732. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  68733. /**
  68734. * Disables and disposes the physics engine associated with the scene
  68735. */
  68736. disablePhysicsEngine(): void;
  68737. /**
  68738. * Gets a boolean indicating if there is an active physics engine
  68739. * @returns a boolean indicating if there is an active physics engine
  68740. */
  68741. isPhysicsEnabled(): boolean;
  68742. /**
  68743. * Deletes a physics compound impostor
  68744. * @param compound defines the compound to delete
  68745. */
  68746. deleteCompoundImpostor(compound: any): void;
  68747. /**
  68748. * An event triggered when physic simulation is about to be run
  68749. */
  68750. onBeforePhysicsObservable: Observable<Scene>;
  68751. /**
  68752. * An event triggered when physic simulation has been done
  68753. */
  68754. onAfterPhysicsObservable: Observable<Scene>;
  68755. }
  68756. interface AbstractMesh {
  68757. /** @hidden */
  68758. _physicsImpostor: Nullable<PhysicsImpostor>;
  68759. /**
  68760. * Gets or sets impostor used for physic simulation
  68761. * @see https://doc.babylonjs.com/features/physics_engine
  68762. */
  68763. physicsImpostor: Nullable<PhysicsImpostor>;
  68764. /**
  68765. * Gets the current physics impostor
  68766. * @see https://doc.babylonjs.com/features/physics_engine
  68767. * @returns a physics impostor or null
  68768. */
  68769. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  68770. /** Apply a physic impulse to the mesh
  68771. * @param force defines the force to apply
  68772. * @param contactPoint defines where to apply the force
  68773. * @returns the current mesh
  68774. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  68775. */
  68776. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  68777. /**
  68778. * Creates a physic joint between two meshes
  68779. * @param otherMesh defines the other mesh to use
  68780. * @param pivot1 defines the pivot to use on this mesh
  68781. * @param pivot2 defines the pivot to use on the other mesh
  68782. * @param options defines additional options (can be plugin dependent)
  68783. * @returns the current mesh
  68784. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  68785. */
  68786. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  68787. /** @hidden */
  68788. _disposePhysicsObserver: Nullable<Observer<Node>>;
  68789. }
  68790. /**
  68791. * Defines the physics engine scene component responsible to manage a physics engine
  68792. */
  68793. export class PhysicsEngineSceneComponent implements ISceneComponent {
  68794. /**
  68795. * The component name helpful to identify the component in the list of scene components.
  68796. */
  68797. readonly name: string;
  68798. /**
  68799. * The scene the component belongs to.
  68800. */
  68801. scene: Scene;
  68802. /**
  68803. * Creates a new instance of the component for the given scene
  68804. * @param scene Defines the scene to register the component in
  68805. */
  68806. constructor(scene: Scene);
  68807. /**
  68808. * Registers the component in a given scene
  68809. */
  68810. register(): void;
  68811. /**
  68812. * Rebuilds the elements related to this component in case of
  68813. * context lost for instance.
  68814. */
  68815. rebuild(): void;
  68816. /**
  68817. * Disposes the component and the associated ressources
  68818. */
  68819. dispose(): void;
  68820. }
  68821. }
  68822. declare module BABYLON {
  68823. /**
  68824. * A helper for physics simulations
  68825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  68826. */
  68827. export class PhysicsHelper {
  68828. private _scene;
  68829. private _physicsEngine;
  68830. /**
  68831. * Initializes the Physics helper
  68832. * @param scene Babylon.js scene
  68833. */
  68834. constructor(scene: Scene);
  68835. /**
  68836. * Applies a radial explosion impulse
  68837. * @param origin the origin of the explosion
  68838. * @param radiusOrEventOptions the radius or the options of radial explosion
  68839. * @param strength the explosion strength
  68840. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68841. * @returns A physics radial explosion event, or null
  68842. */
  68843. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68844. /**
  68845. * Applies a radial explosion force
  68846. * @param origin the origin of the explosion
  68847. * @param radiusOrEventOptions the radius or the options of radial explosion
  68848. * @param strength the explosion strength
  68849. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68850. * @returns A physics radial explosion event, or null
  68851. */
  68852. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  68853. /**
  68854. * Creates a gravitational field
  68855. * @param origin the origin of the explosion
  68856. * @param radiusOrEventOptions the radius or the options of radial explosion
  68857. * @param strength the explosion strength
  68858. * @param falloff possible options: Constant & Linear. Defaults to Constant
  68859. * @returns A physics gravitational field event, or null
  68860. */
  68861. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  68862. /**
  68863. * Creates a physics updraft event
  68864. * @param origin the origin of the updraft
  68865. * @param radiusOrEventOptions the radius or the options of the updraft
  68866. * @param strength the strength of the updraft
  68867. * @param height the height of the updraft
  68868. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  68869. * @returns A physics updraft event, or null
  68870. */
  68871. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  68872. /**
  68873. * Creates a physics vortex event
  68874. * @param origin the of the vortex
  68875. * @param radiusOrEventOptions the radius or the options of the vortex
  68876. * @param strength the strength of the vortex
  68877. * @param height the height of the vortex
  68878. * @returns a Physics vortex event, or null
  68879. * A physics vortex event or null
  68880. */
  68881. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  68882. }
  68883. /**
  68884. * Represents a physics radial explosion event
  68885. */
  68886. class PhysicsRadialExplosionEvent {
  68887. private _scene;
  68888. private _options;
  68889. private _sphere;
  68890. private _dataFetched;
  68891. /**
  68892. * Initializes a radial explosioin event
  68893. * @param _scene BabylonJS scene
  68894. * @param _options The options for the vortex event
  68895. */
  68896. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  68897. /**
  68898. * Returns the data related to the radial explosion event (sphere).
  68899. * @returns The radial explosion event data
  68900. */
  68901. getData(): PhysicsRadialExplosionEventData;
  68902. /**
  68903. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  68904. * @param impostor A physics imposter
  68905. * @param origin the origin of the explosion
  68906. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  68907. */
  68908. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  68909. /**
  68910. * Triggers affecterd impostors callbacks
  68911. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  68912. */
  68913. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  68914. /**
  68915. * Disposes the sphere.
  68916. * @param force Specifies if the sphere should be disposed by force
  68917. */
  68918. dispose(force?: boolean): void;
  68919. /*** Helpers ***/
  68920. private _prepareSphere;
  68921. private _intersectsWithSphere;
  68922. }
  68923. /**
  68924. * Represents a gravitational field event
  68925. */
  68926. class PhysicsGravitationalFieldEvent {
  68927. private _physicsHelper;
  68928. private _scene;
  68929. private _origin;
  68930. private _options;
  68931. private _tickCallback;
  68932. private _sphere;
  68933. private _dataFetched;
  68934. /**
  68935. * Initializes the physics gravitational field event
  68936. * @param _physicsHelper A physics helper
  68937. * @param _scene BabylonJS scene
  68938. * @param _origin The origin position of the gravitational field event
  68939. * @param _options The options for the vortex event
  68940. */
  68941. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  68942. /**
  68943. * Returns the data related to the gravitational field event (sphere).
  68944. * @returns A gravitational field event
  68945. */
  68946. getData(): PhysicsGravitationalFieldEventData;
  68947. /**
  68948. * Enables the gravitational field.
  68949. */
  68950. enable(): void;
  68951. /**
  68952. * Disables the gravitational field.
  68953. */
  68954. disable(): void;
  68955. /**
  68956. * Disposes the sphere.
  68957. * @param force The force to dispose from the gravitational field event
  68958. */
  68959. dispose(force?: boolean): void;
  68960. private _tick;
  68961. }
  68962. /**
  68963. * Represents a physics updraft event
  68964. */
  68965. class PhysicsUpdraftEvent {
  68966. private _scene;
  68967. private _origin;
  68968. private _options;
  68969. private _physicsEngine;
  68970. private _originTop;
  68971. private _originDirection;
  68972. private _tickCallback;
  68973. private _cylinder;
  68974. private _cylinderPosition;
  68975. private _dataFetched;
  68976. /**
  68977. * Initializes the physics updraft event
  68978. * @param _scene BabylonJS scene
  68979. * @param _origin The origin position of the updraft
  68980. * @param _options The options for the updraft event
  68981. */
  68982. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  68983. /**
  68984. * Returns the data related to the updraft event (cylinder).
  68985. * @returns A physics updraft event
  68986. */
  68987. getData(): PhysicsUpdraftEventData;
  68988. /**
  68989. * Enables the updraft.
  68990. */
  68991. enable(): void;
  68992. /**
  68993. * Disables the updraft.
  68994. */
  68995. disable(): void;
  68996. /**
  68997. * Disposes the cylinder.
  68998. * @param force Specifies if the updraft should be disposed by force
  68999. */
  69000. dispose(force?: boolean): void;
  69001. private getImpostorHitData;
  69002. private _tick;
  69003. /*** Helpers ***/
  69004. private _prepareCylinder;
  69005. private _intersectsWithCylinder;
  69006. }
  69007. /**
  69008. * Represents a physics vortex event
  69009. */
  69010. class PhysicsVortexEvent {
  69011. private _scene;
  69012. private _origin;
  69013. private _options;
  69014. private _physicsEngine;
  69015. private _originTop;
  69016. private _tickCallback;
  69017. private _cylinder;
  69018. private _cylinderPosition;
  69019. private _dataFetched;
  69020. /**
  69021. * Initializes the physics vortex event
  69022. * @param _scene The BabylonJS scene
  69023. * @param _origin The origin position of the vortex
  69024. * @param _options The options for the vortex event
  69025. */
  69026. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69027. /**
  69028. * Returns the data related to the vortex event (cylinder).
  69029. * @returns The physics vortex event data
  69030. */
  69031. getData(): PhysicsVortexEventData;
  69032. /**
  69033. * Enables the vortex.
  69034. */
  69035. enable(): void;
  69036. /**
  69037. * Disables the cortex.
  69038. */
  69039. disable(): void;
  69040. /**
  69041. * Disposes the sphere.
  69042. * @param force
  69043. */
  69044. dispose(force?: boolean): void;
  69045. private getImpostorHitData;
  69046. private _tick;
  69047. /*** Helpers ***/
  69048. private _prepareCylinder;
  69049. private _intersectsWithCylinder;
  69050. }
  69051. /**
  69052. * Options fot the radial explosion event
  69053. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69054. */
  69055. export class PhysicsRadialExplosionEventOptions {
  69056. /**
  69057. * The radius of the sphere for the radial explosion.
  69058. */
  69059. radius: number;
  69060. /**
  69061. * The strenth of the explosion.
  69062. */
  69063. strength: number;
  69064. /**
  69065. * The strenght of the force in correspondence to the distance of the affected object
  69066. */
  69067. falloff: PhysicsRadialImpulseFalloff;
  69068. /**
  69069. * Sphere options for the radial explosion.
  69070. */
  69071. sphere: {
  69072. segments: number;
  69073. diameter: number;
  69074. };
  69075. /**
  69076. * Sphere options for the radial explosion.
  69077. */
  69078. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69079. }
  69080. /**
  69081. * Options fot the updraft event
  69082. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69083. */
  69084. export class PhysicsUpdraftEventOptions {
  69085. /**
  69086. * The radius of the cylinder for the vortex
  69087. */
  69088. radius: number;
  69089. /**
  69090. * The strenth of the updraft.
  69091. */
  69092. strength: number;
  69093. /**
  69094. * The height of the cylinder for the updraft.
  69095. */
  69096. height: number;
  69097. /**
  69098. * The mode for the the updraft.
  69099. */
  69100. updraftMode: PhysicsUpdraftMode;
  69101. }
  69102. /**
  69103. * Options fot the vortex event
  69104. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69105. */
  69106. export class PhysicsVortexEventOptions {
  69107. /**
  69108. * The radius of the cylinder for the vortex
  69109. */
  69110. radius: number;
  69111. /**
  69112. * The strenth of the vortex.
  69113. */
  69114. strength: number;
  69115. /**
  69116. * The height of the cylinder for the vortex.
  69117. */
  69118. height: number;
  69119. /**
  69120. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69121. */
  69122. centripetalForceThreshold: number;
  69123. /**
  69124. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69125. */
  69126. centripetalForceMultiplier: number;
  69127. /**
  69128. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69129. */
  69130. centrifugalForceMultiplier: number;
  69131. /**
  69132. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69133. */
  69134. updraftForceMultiplier: number;
  69135. }
  69136. /**
  69137. * The strenght of the force in correspondence to the distance of the affected object
  69138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69139. */
  69140. export enum PhysicsRadialImpulseFalloff {
  69141. /** Defines that impulse is constant in strength across it's whole radius */
  69142. Constant = 0,
  69143. /** Defines that impulse gets weaker if it's further from the origin */
  69144. Linear = 1
  69145. }
  69146. /**
  69147. * The strength of the force in correspondence to the distance of the affected object
  69148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69149. */
  69150. export enum PhysicsUpdraftMode {
  69151. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69152. Center = 0,
  69153. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69154. Perpendicular = 1
  69155. }
  69156. /**
  69157. * Interface for a physics hit data
  69158. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69159. */
  69160. export interface PhysicsHitData {
  69161. /**
  69162. * The force applied at the contact point
  69163. */
  69164. force: Vector3;
  69165. /**
  69166. * The contact point
  69167. */
  69168. contactPoint: Vector3;
  69169. /**
  69170. * The distance from the origin to the contact point
  69171. */
  69172. distanceFromOrigin: number;
  69173. }
  69174. /**
  69175. * Interface for radial explosion event data
  69176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69177. */
  69178. export interface PhysicsRadialExplosionEventData {
  69179. /**
  69180. * A sphere used for the radial explosion event
  69181. */
  69182. sphere: Mesh;
  69183. }
  69184. /**
  69185. * Interface for gravitational field event data
  69186. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69187. */
  69188. export interface PhysicsGravitationalFieldEventData {
  69189. /**
  69190. * A sphere mesh used for the gravitational field event
  69191. */
  69192. sphere: Mesh;
  69193. }
  69194. /**
  69195. * Interface for updraft event data
  69196. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69197. */
  69198. export interface PhysicsUpdraftEventData {
  69199. /**
  69200. * A cylinder used for the updraft event
  69201. */
  69202. cylinder: Mesh;
  69203. }
  69204. /**
  69205. * Interface for vortex event data
  69206. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69207. */
  69208. export interface PhysicsVortexEventData {
  69209. /**
  69210. * A cylinder used for the vortex event
  69211. */
  69212. cylinder: Mesh;
  69213. }
  69214. /**
  69215. * Interface for an affected physics impostor
  69216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69217. */
  69218. export interface PhysicsAffectedImpostorWithData {
  69219. /**
  69220. * The impostor affected by the effect
  69221. */
  69222. impostor: PhysicsImpostor;
  69223. /**
  69224. * The data about the hit/horce from the explosion
  69225. */
  69226. hitData: PhysicsHitData;
  69227. }
  69228. }
  69229. declare module BABYLON {
  69230. /** @hidden */
  69231. export var blackAndWhitePixelShader: {
  69232. name: string;
  69233. shader: string;
  69234. };
  69235. }
  69236. declare module BABYLON {
  69237. /**
  69238. * Post process used to render in black and white
  69239. */
  69240. export class BlackAndWhitePostProcess extends PostProcess {
  69241. /**
  69242. * Linear about to convert he result to black and white (default: 1)
  69243. */
  69244. degree: number;
  69245. /**
  69246. * Gets a string identifying the name of the class
  69247. * @returns "BlackAndWhitePostProcess" string
  69248. */
  69249. getClassName(): string;
  69250. /**
  69251. * Creates a black and white post process
  69252. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69253. * @param name The name of the effect.
  69254. * @param options The required width/height ratio to downsize to before computing the render pass.
  69255. * @param camera The camera to apply the render pass to.
  69256. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69257. * @param engine The engine which the post process will be applied. (default: current engine)
  69258. * @param reusable If the post process can be reused on the same frame. (default: false)
  69259. */
  69260. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69261. /** @hidden */
  69262. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69263. }
  69264. }
  69265. declare module BABYLON {
  69266. /**
  69267. * This represents a set of one or more post processes in Babylon.
  69268. * A post process can be used to apply a shader to a texture after it is rendered.
  69269. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69270. */
  69271. export class PostProcessRenderEffect {
  69272. private _postProcesses;
  69273. private _getPostProcesses;
  69274. private _singleInstance;
  69275. private _cameras;
  69276. private _indicesForCamera;
  69277. /**
  69278. * Name of the effect
  69279. * @hidden
  69280. */
  69281. _name: string;
  69282. /**
  69283. * Instantiates a post process render effect.
  69284. * A post process can be used to apply a shader to a texture after it is rendered.
  69285. * @param engine The engine the effect is tied to
  69286. * @param name The name of the effect
  69287. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69288. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69289. */
  69290. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69291. /**
  69292. * Checks if all the post processes in the effect are supported.
  69293. */
  69294. get isSupported(): boolean;
  69295. /**
  69296. * Updates the current state of the effect
  69297. * @hidden
  69298. */
  69299. _update(): void;
  69300. /**
  69301. * Attaches the effect on cameras
  69302. * @param cameras The camera to attach to.
  69303. * @hidden
  69304. */
  69305. _attachCameras(cameras: Camera): void;
  69306. /**
  69307. * Attaches the effect on cameras
  69308. * @param cameras The camera to attach to.
  69309. * @hidden
  69310. */
  69311. _attachCameras(cameras: Camera[]): void;
  69312. /**
  69313. * Detaches the effect on cameras
  69314. * @param cameras The camera to detatch from.
  69315. * @hidden
  69316. */
  69317. _detachCameras(cameras: Camera): void;
  69318. /**
  69319. * Detatches the effect on cameras
  69320. * @param cameras The camera to detatch from.
  69321. * @hidden
  69322. */
  69323. _detachCameras(cameras: Camera[]): void;
  69324. /**
  69325. * Enables the effect on given cameras
  69326. * @param cameras The camera to enable.
  69327. * @hidden
  69328. */
  69329. _enable(cameras: Camera): void;
  69330. /**
  69331. * Enables the effect on given cameras
  69332. * @param cameras The camera to enable.
  69333. * @hidden
  69334. */
  69335. _enable(cameras: Nullable<Camera[]>): void;
  69336. /**
  69337. * Disables the effect on the given cameras
  69338. * @param cameras The camera to disable.
  69339. * @hidden
  69340. */
  69341. _disable(cameras: Camera): void;
  69342. /**
  69343. * Disables the effect on the given cameras
  69344. * @param cameras The camera to disable.
  69345. * @hidden
  69346. */
  69347. _disable(cameras: Nullable<Camera[]>): void;
  69348. /**
  69349. * Gets a list of the post processes contained in the effect.
  69350. * @param camera The camera to get the post processes on.
  69351. * @returns The list of the post processes in the effect.
  69352. */
  69353. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69354. }
  69355. }
  69356. declare module BABYLON {
  69357. /** @hidden */
  69358. export var extractHighlightsPixelShader: {
  69359. name: string;
  69360. shader: string;
  69361. };
  69362. }
  69363. declare module BABYLON {
  69364. /**
  69365. * 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.
  69366. */
  69367. export class ExtractHighlightsPostProcess extends PostProcess {
  69368. /**
  69369. * The luminance threshold, pixels below this value will be set to black.
  69370. */
  69371. threshold: number;
  69372. /** @hidden */
  69373. _exposure: number;
  69374. /**
  69375. * Post process which has the input texture to be used when performing highlight extraction
  69376. * @hidden
  69377. */
  69378. _inputPostProcess: Nullable<PostProcess>;
  69379. /**
  69380. * Gets a string identifying the name of the class
  69381. * @returns "ExtractHighlightsPostProcess" string
  69382. */
  69383. getClassName(): string;
  69384. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69385. }
  69386. }
  69387. declare module BABYLON {
  69388. /** @hidden */
  69389. export var bloomMergePixelShader: {
  69390. name: string;
  69391. shader: string;
  69392. };
  69393. }
  69394. declare module BABYLON {
  69395. /**
  69396. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69397. */
  69398. export class BloomMergePostProcess extends PostProcess {
  69399. /** Weight of the bloom to be added to the original input. */
  69400. weight: number;
  69401. /**
  69402. * Gets a string identifying the name of the class
  69403. * @returns "BloomMergePostProcess" string
  69404. */
  69405. getClassName(): string;
  69406. /**
  69407. * Creates a new instance of @see BloomMergePostProcess
  69408. * @param name The name of the effect.
  69409. * @param originalFromInput Post process which's input will be used for the merge.
  69410. * @param blurred Blurred highlights post process which's output will be used.
  69411. * @param weight Weight of the bloom to be added to the original input.
  69412. * @param options The required width/height ratio to downsize to before computing the render pass.
  69413. * @param camera The camera to apply the render pass to.
  69414. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69415. * @param engine The engine which the post process will be applied. (default: current engine)
  69416. * @param reusable If the post process can be reused on the same frame. (default: false)
  69417. * @param textureType Type of textures used when performing the post process. (default: 0)
  69418. * @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)
  69419. */
  69420. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69421. /** Weight of the bloom to be added to the original input. */
  69422. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69423. }
  69424. }
  69425. declare module BABYLON {
  69426. /**
  69427. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69428. */
  69429. export class BloomEffect extends PostProcessRenderEffect {
  69430. private bloomScale;
  69431. /**
  69432. * @hidden Internal
  69433. */
  69434. _effects: Array<PostProcess>;
  69435. /**
  69436. * @hidden Internal
  69437. */
  69438. _downscale: ExtractHighlightsPostProcess;
  69439. private _blurX;
  69440. private _blurY;
  69441. private _merge;
  69442. /**
  69443. * The luminance threshold to find bright areas of the image to bloom.
  69444. */
  69445. get threshold(): number;
  69446. set threshold(value: number);
  69447. /**
  69448. * The strength of the bloom.
  69449. */
  69450. get weight(): number;
  69451. set weight(value: number);
  69452. /**
  69453. * Specifies the size of the bloom blur kernel, relative to the final output size
  69454. */
  69455. get kernel(): number;
  69456. set kernel(value: number);
  69457. /**
  69458. * Creates a new instance of @see BloomEffect
  69459. * @param scene The scene the effect belongs to.
  69460. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69461. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69462. * @param bloomWeight The the strength of bloom.
  69463. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69464. * @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)
  69465. */
  69466. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69467. /**
  69468. * Disposes each of the internal effects for a given camera.
  69469. * @param camera The camera to dispose the effect on.
  69470. */
  69471. disposeEffects(camera: Camera): void;
  69472. /**
  69473. * @hidden Internal
  69474. */
  69475. _updateEffects(): void;
  69476. /**
  69477. * Internal
  69478. * @returns if all the contained post processes are ready.
  69479. * @hidden
  69480. */
  69481. _isReady(): boolean;
  69482. }
  69483. }
  69484. declare module BABYLON {
  69485. /** @hidden */
  69486. export var chromaticAberrationPixelShader: {
  69487. name: string;
  69488. shader: string;
  69489. };
  69490. }
  69491. declare module BABYLON {
  69492. /**
  69493. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69494. */
  69495. export class ChromaticAberrationPostProcess extends PostProcess {
  69496. /**
  69497. * The amount of seperation of rgb channels (default: 30)
  69498. */
  69499. aberrationAmount: number;
  69500. /**
  69501. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69502. */
  69503. radialIntensity: number;
  69504. /**
  69505. * 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))
  69506. */
  69507. direction: Vector2;
  69508. /**
  69509. * 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))
  69510. */
  69511. centerPosition: Vector2;
  69512. /** The width of the screen to apply the effect on */
  69513. screenWidth: number;
  69514. /** The height of the screen to apply the effect on */
  69515. screenHeight: number;
  69516. /**
  69517. * Gets a string identifying the name of the class
  69518. * @returns "ChromaticAberrationPostProcess" string
  69519. */
  69520. getClassName(): string;
  69521. /**
  69522. * Creates a new instance ChromaticAberrationPostProcess
  69523. * @param name The name of the effect.
  69524. * @param screenWidth The width of the screen to apply the effect on.
  69525. * @param screenHeight The height of the screen to apply the effect on.
  69526. * @param options The required width/height ratio to downsize to before computing the render pass.
  69527. * @param camera The camera to apply the render pass to.
  69528. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69529. * @param engine The engine which the post process will be applied. (default: current engine)
  69530. * @param reusable If the post process can be reused on the same frame. (default: false)
  69531. * @param textureType Type of textures used when performing the post process. (default: 0)
  69532. * @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)
  69533. */
  69534. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69535. /** @hidden */
  69536. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69537. }
  69538. }
  69539. declare module BABYLON {
  69540. /** @hidden */
  69541. export var circleOfConfusionPixelShader: {
  69542. name: string;
  69543. shader: string;
  69544. };
  69545. }
  69546. declare module BABYLON {
  69547. /**
  69548. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69549. */
  69550. export class CircleOfConfusionPostProcess extends PostProcess {
  69551. /**
  69552. * 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.
  69553. */
  69554. lensSize: number;
  69555. /**
  69556. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69557. */
  69558. fStop: number;
  69559. /**
  69560. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69561. */
  69562. focusDistance: number;
  69563. /**
  69564. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69565. */
  69566. focalLength: number;
  69567. /**
  69568. * Gets a string identifying the name of the class
  69569. * @returns "CircleOfConfusionPostProcess" string
  69570. */
  69571. getClassName(): string;
  69572. private _depthTexture;
  69573. /**
  69574. * Creates a new instance CircleOfConfusionPostProcess
  69575. * @param name The name of the effect.
  69576. * @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.
  69577. * @param options The required width/height ratio to downsize to before computing the render pass.
  69578. * @param camera The camera to apply the render pass to.
  69579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69580. * @param engine The engine which the post process will be applied. (default: current engine)
  69581. * @param reusable If the post process can be reused on the same frame. (default: false)
  69582. * @param textureType Type of textures used when performing the post process. (default: 0)
  69583. * @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)
  69584. */
  69585. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69586. /**
  69587. * 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.
  69588. */
  69589. set depthTexture(value: RenderTargetTexture);
  69590. }
  69591. }
  69592. declare module BABYLON {
  69593. /** @hidden */
  69594. export var colorCorrectionPixelShader: {
  69595. name: string;
  69596. shader: string;
  69597. };
  69598. }
  69599. declare module BABYLON {
  69600. /**
  69601. *
  69602. * This post-process allows the modification of rendered colors by using
  69603. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69604. *
  69605. * The object needs to be provided an url to a texture containing the color
  69606. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69607. * Use an image editing software to tweak the LUT to match your needs.
  69608. *
  69609. * For an example of a color LUT, see here:
  69610. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69611. * For explanations on color grading, see here:
  69612. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69613. *
  69614. */
  69615. export class ColorCorrectionPostProcess extends PostProcess {
  69616. private _colorTableTexture;
  69617. /**
  69618. * Gets the color table url used to create the LUT texture
  69619. */
  69620. colorTableUrl: string;
  69621. /**
  69622. * Gets a string identifying the name of the class
  69623. * @returns "ColorCorrectionPostProcess" string
  69624. */
  69625. getClassName(): string;
  69626. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69627. /** @hidden */
  69628. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69629. }
  69630. }
  69631. declare module BABYLON {
  69632. /** @hidden */
  69633. export var convolutionPixelShader: {
  69634. name: string;
  69635. shader: string;
  69636. };
  69637. }
  69638. declare module BABYLON {
  69639. /**
  69640. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69641. * input texture to perform effects such as edge detection or sharpening
  69642. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69643. */
  69644. export class ConvolutionPostProcess extends PostProcess {
  69645. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69646. kernel: number[];
  69647. /**
  69648. * Gets a string identifying the name of the class
  69649. * @returns "ConvolutionPostProcess" string
  69650. */
  69651. getClassName(): string;
  69652. /**
  69653. * Creates a new instance ConvolutionPostProcess
  69654. * @param name The name of the effect.
  69655. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69656. * @param options The required width/height ratio to downsize to before computing the render pass.
  69657. * @param camera The camera to apply the render pass to.
  69658. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69659. * @param engine The engine which the post process will be applied. (default: current engine)
  69660. * @param reusable If the post process can be reused on the same frame. (default: false)
  69661. * @param textureType Type of textures used when performing the post process. (default: 0)
  69662. */
  69663. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69664. /** @hidden */
  69665. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69666. /**
  69667. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69668. */
  69669. static EdgeDetect0Kernel: number[];
  69670. /**
  69671. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69672. */
  69673. static EdgeDetect1Kernel: number[];
  69674. /**
  69675. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69676. */
  69677. static EdgeDetect2Kernel: number[];
  69678. /**
  69679. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69680. */
  69681. static SharpenKernel: number[];
  69682. /**
  69683. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69684. */
  69685. static EmbossKernel: number[];
  69686. /**
  69687. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69688. */
  69689. static GaussianKernel: number[];
  69690. }
  69691. }
  69692. declare module BABYLON {
  69693. /**
  69694. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  69695. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  69696. * based on samples that have a large difference in distance than the center pixel.
  69697. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  69698. */
  69699. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  69700. /**
  69701. * The direction the blur should be applied
  69702. */
  69703. direction: Vector2;
  69704. /**
  69705. * Gets a string identifying the name of the class
  69706. * @returns "DepthOfFieldBlurPostProcess" string
  69707. */
  69708. getClassName(): string;
  69709. /**
  69710. * Creates a new instance CircleOfConfusionPostProcess
  69711. * @param name The name of the effect.
  69712. * @param scene The scene the effect belongs to.
  69713. * @param direction The direction the blur should be applied.
  69714. * @param kernel The size of the kernel used to blur.
  69715. * @param options The required width/height ratio to downsize to before computing the render pass.
  69716. * @param camera The camera to apply the render pass to.
  69717. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  69718. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  69719. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69720. * @param engine The engine which the post process will be applied. (default: current engine)
  69721. * @param reusable If the post process can be reused on the same frame. (default: false)
  69722. * @param textureType Type of textures used when performing the post process. (default: 0)
  69723. * @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)
  69724. */
  69725. 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);
  69726. }
  69727. }
  69728. declare module BABYLON {
  69729. /** @hidden */
  69730. export var depthOfFieldMergePixelShader: {
  69731. name: string;
  69732. shader: string;
  69733. };
  69734. }
  69735. declare module BABYLON {
  69736. /**
  69737. * Options to be set when merging outputs from the default pipeline.
  69738. */
  69739. export class DepthOfFieldMergePostProcessOptions {
  69740. /**
  69741. * The original image to merge on top of
  69742. */
  69743. originalFromInput: PostProcess;
  69744. /**
  69745. * Parameters to perform the merge of the depth of field effect
  69746. */
  69747. depthOfField?: {
  69748. circleOfConfusion: PostProcess;
  69749. blurSteps: Array<PostProcess>;
  69750. };
  69751. /**
  69752. * Parameters to perform the merge of bloom effect
  69753. */
  69754. bloom?: {
  69755. blurred: PostProcess;
  69756. weight: number;
  69757. };
  69758. }
  69759. /**
  69760. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69761. */
  69762. export class DepthOfFieldMergePostProcess extends PostProcess {
  69763. private blurSteps;
  69764. /**
  69765. * Gets a string identifying the name of the class
  69766. * @returns "DepthOfFieldMergePostProcess" string
  69767. */
  69768. getClassName(): string;
  69769. /**
  69770. * Creates a new instance of DepthOfFieldMergePostProcess
  69771. * @param name The name of the effect.
  69772. * @param originalFromInput Post process which's input will be used for the merge.
  69773. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  69774. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  69775. * @param options The required width/height ratio to downsize to before computing the render pass.
  69776. * @param camera The camera to apply the render pass to.
  69777. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69778. * @param engine The engine which the post process will be applied. (default: current engine)
  69779. * @param reusable If the post process can be reused on the same frame. (default: false)
  69780. * @param textureType Type of textures used when performing the post process. (default: 0)
  69781. * @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)
  69782. */
  69783. 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);
  69784. /**
  69785. * Updates the effect with the current post process compile time values and recompiles the shader.
  69786. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  69787. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  69788. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  69789. * @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
  69790. * @param onCompiled Called when the shader has been compiled.
  69791. * @param onError Called if there is an error when compiling a shader.
  69792. */
  69793. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  69794. }
  69795. }
  69796. declare module BABYLON {
  69797. /**
  69798. * Specifies the level of max blur that should be applied when using the depth of field effect
  69799. */
  69800. export enum DepthOfFieldEffectBlurLevel {
  69801. /**
  69802. * Subtle blur
  69803. */
  69804. Low = 0,
  69805. /**
  69806. * Medium blur
  69807. */
  69808. Medium = 1,
  69809. /**
  69810. * Large blur
  69811. */
  69812. High = 2
  69813. }
  69814. /**
  69815. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  69816. */
  69817. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  69818. private _circleOfConfusion;
  69819. /**
  69820. * @hidden Internal, blurs from high to low
  69821. */
  69822. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  69823. private _depthOfFieldBlurY;
  69824. private _dofMerge;
  69825. /**
  69826. * @hidden Internal post processes in depth of field effect
  69827. */
  69828. _effects: Array<PostProcess>;
  69829. /**
  69830. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  69831. */
  69832. set focalLength(value: number);
  69833. get focalLength(): number;
  69834. /**
  69835. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69836. */
  69837. set fStop(value: number);
  69838. get fStop(): number;
  69839. /**
  69840. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69841. */
  69842. set focusDistance(value: number);
  69843. get focusDistance(): number;
  69844. /**
  69845. * 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.
  69846. */
  69847. set lensSize(value: number);
  69848. get lensSize(): number;
  69849. /**
  69850. * Creates a new instance DepthOfFieldEffect
  69851. * @param scene The scene the effect belongs to.
  69852. * @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.
  69853. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69854. * @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)
  69855. */
  69856. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  69857. /**
  69858. * Get the current class name of the current effet
  69859. * @returns "DepthOfFieldEffect"
  69860. */
  69861. getClassName(): string;
  69862. /**
  69863. * 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.
  69864. */
  69865. set depthTexture(value: RenderTargetTexture);
  69866. /**
  69867. * Disposes each of the internal effects for a given camera.
  69868. * @param camera The camera to dispose the effect on.
  69869. */
  69870. disposeEffects(camera: Camera): void;
  69871. /**
  69872. * @hidden Internal
  69873. */
  69874. _updateEffects(): void;
  69875. /**
  69876. * Internal
  69877. * @returns if all the contained post processes are ready.
  69878. * @hidden
  69879. */
  69880. _isReady(): boolean;
  69881. }
  69882. }
  69883. declare module BABYLON {
  69884. /** @hidden */
  69885. export var displayPassPixelShader: {
  69886. name: string;
  69887. shader: string;
  69888. };
  69889. }
  69890. declare module BABYLON {
  69891. /**
  69892. * DisplayPassPostProcess which produces an output the same as it's input
  69893. */
  69894. export class DisplayPassPostProcess extends PostProcess {
  69895. /**
  69896. * Gets a string identifying the name of the class
  69897. * @returns "DisplayPassPostProcess" string
  69898. */
  69899. getClassName(): string;
  69900. /**
  69901. * Creates the DisplayPassPostProcess
  69902. * @param name The name of the effect.
  69903. * @param options The required width/height ratio to downsize to before computing the render pass.
  69904. * @param camera The camera to apply the render pass to.
  69905. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69906. * @param engine The engine which the post process will be applied. (default: current engine)
  69907. * @param reusable If the post process can be reused on the same frame. (default: false)
  69908. */
  69909. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69910. /** @hidden */
  69911. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  69912. }
  69913. }
  69914. declare module BABYLON {
  69915. /** @hidden */
  69916. export var filterPixelShader: {
  69917. name: string;
  69918. shader: string;
  69919. };
  69920. }
  69921. declare module BABYLON {
  69922. /**
  69923. * Applies a kernel filter to the image
  69924. */
  69925. export class FilterPostProcess extends PostProcess {
  69926. /** The matrix to be applied to the image */
  69927. kernelMatrix: Matrix;
  69928. /**
  69929. * Gets a string identifying the name of the class
  69930. * @returns "FilterPostProcess" string
  69931. */
  69932. getClassName(): string;
  69933. /**
  69934. *
  69935. * @param name The name of the effect.
  69936. * @param kernelMatrix The matrix to be applied to the image
  69937. * @param options The required width/height ratio to downsize to before computing the render pass.
  69938. * @param camera The camera to apply the render pass to.
  69939. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69940. * @param engine The engine which the post process will be applied. (default: current engine)
  69941. * @param reusable If the post process can be reused on the same frame. (default: false)
  69942. */
  69943. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69944. /** @hidden */
  69945. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  69946. }
  69947. }
  69948. declare module BABYLON {
  69949. /** @hidden */
  69950. export var fxaaPixelShader: {
  69951. name: string;
  69952. shader: string;
  69953. };
  69954. }
  69955. declare module BABYLON {
  69956. /** @hidden */
  69957. export var fxaaVertexShader: {
  69958. name: string;
  69959. shader: string;
  69960. };
  69961. }
  69962. declare module BABYLON {
  69963. /**
  69964. * Fxaa post process
  69965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  69966. */
  69967. export class FxaaPostProcess extends PostProcess {
  69968. /**
  69969. * Gets a string identifying the name of the class
  69970. * @returns "FxaaPostProcess" string
  69971. */
  69972. getClassName(): string;
  69973. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69974. private _getDefines;
  69975. /** @hidden */
  69976. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  69977. }
  69978. }
  69979. declare module BABYLON {
  69980. /** @hidden */
  69981. export var grainPixelShader: {
  69982. name: string;
  69983. shader: string;
  69984. };
  69985. }
  69986. declare module BABYLON {
  69987. /**
  69988. * The GrainPostProcess adds noise to the image at mid luminance levels
  69989. */
  69990. export class GrainPostProcess extends PostProcess {
  69991. /**
  69992. * The intensity of the grain added (default: 30)
  69993. */
  69994. intensity: number;
  69995. /**
  69996. * If the grain should be randomized on every frame
  69997. */
  69998. animated: boolean;
  69999. /**
  70000. * Gets a string identifying the name of the class
  70001. * @returns "GrainPostProcess" string
  70002. */
  70003. getClassName(): string;
  70004. /**
  70005. * Creates a new instance of @see GrainPostProcess
  70006. * @param name The name of the effect.
  70007. * @param options The required width/height ratio to downsize to before computing the render pass.
  70008. * @param camera The camera to apply the render pass to.
  70009. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70010. * @param engine The engine which the post process will be applied. (default: current engine)
  70011. * @param reusable If the post process can be reused on the same frame. (default: false)
  70012. * @param textureType Type of textures used when performing the post process. (default: 0)
  70013. * @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)
  70014. */
  70015. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70016. /** @hidden */
  70017. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70018. }
  70019. }
  70020. declare module BABYLON {
  70021. /** @hidden */
  70022. export var highlightsPixelShader: {
  70023. name: string;
  70024. shader: string;
  70025. };
  70026. }
  70027. declare module BABYLON {
  70028. /**
  70029. * Extracts highlights from the image
  70030. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70031. */
  70032. export class HighlightsPostProcess extends PostProcess {
  70033. /**
  70034. * Gets a string identifying the name of the class
  70035. * @returns "HighlightsPostProcess" string
  70036. */
  70037. getClassName(): string;
  70038. /**
  70039. * Extracts highlights from the image
  70040. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70041. * @param name The name of the effect.
  70042. * @param options The required width/height ratio to downsize to before computing the render pass.
  70043. * @param camera The camera to apply the render pass to.
  70044. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70045. * @param engine The engine which the post process will be applied. (default: current engine)
  70046. * @param reusable If the post process can be reused on the same frame. (default: false)
  70047. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70048. */
  70049. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70050. }
  70051. }
  70052. declare module BABYLON {
  70053. /** @hidden */
  70054. export var mrtFragmentDeclaration: {
  70055. name: string;
  70056. shader: string;
  70057. };
  70058. }
  70059. declare module BABYLON {
  70060. /** @hidden */
  70061. export var geometryPixelShader: {
  70062. name: string;
  70063. shader: string;
  70064. };
  70065. }
  70066. declare module BABYLON {
  70067. /** @hidden */
  70068. export var geometryVertexShader: {
  70069. name: string;
  70070. shader: string;
  70071. };
  70072. }
  70073. declare module BABYLON {
  70074. /** @hidden */
  70075. interface ISavedTransformationMatrix {
  70076. world: Matrix;
  70077. viewProjection: Matrix;
  70078. }
  70079. /**
  70080. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  70081. */
  70082. export class GeometryBufferRenderer {
  70083. /**
  70084. * Constant used to retrieve the position texture index in the G-Buffer textures array
  70085. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  70086. */
  70087. static readonly POSITION_TEXTURE_TYPE: number;
  70088. /**
  70089. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  70090. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  70091. */
  70092. static readonly VELOCITY_TEXTURE_TYPE: number;
  70093. /**
  70094. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  70095. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  70096. */
  70097. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  70098. /**
  70099. * Dictionary used to store the previous transformation matrices of each rendered mesh
  70100. * in order to compute objects velocities when enableVelocity is set to "true"
  70101. * @hidden
  70102. */
  70103. _previousTransformationMatrices: {
  70104. [index: number]: ISavedTransformationMatrix;
  70105. };
  70106. /**
  70107. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  70108. * in order to compute objects velocities when enableVelocity is set to "true"
  70109. * @hidden
  70110. */
  70111. _previousBonesTransformationMatrices: {
  70112. [index: number]: Float32Array;
  70113. };
  70114. /**
  70115. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  70116. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  70117. */
  70118. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  70119. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  70120. renderTransparentMeshes: boolean;
  70121. private _scene;
  70122. private _resizeObserver;
  70123. private _multiRenderTarget;
  70124. private _ratio;
  70125. private _enablePosition;
  70126. private _enableVelocity;
  70127. private _enableReflectivity;
  70128. private _positionIndex;
  70129. private _velocityIndex;
  70130. private _reflectivityIndex;
  70131. protected _effect: Effect;
  70132. protected _cachedDefines: string;
  70133. /**
  70134. * Set the render list (meshes to be rendered) used in the G buffer.
  70135. */
  70136. set renderList(meshes: Mesh[]);
  70137. /**
  70138. * Gets wether or not G buffer are supported by the running hardware.
  70139. * This requires draw buffer supports
  70140. */
  70141. get isSupported(): boolean;
  70142. /**
  70143. * Returns the index of the given texture type in the G-Buffer textures array
  70144. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  70145. * @returns the index of the given texture type in the G-Buffer textures array
  70146. */
  70147. getTextureIndex(textureType: number): number;
  70148. /**
  70149. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  70150. */
  70151. get enablePosition(): boolean;
  70152. /**
  70153. * Sets whether or not objects positions are enabled for the G buffer.
  70154. */
  70155. set enablePosition(enable: boolean);
  70156. /**
  70157. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  70158. */
  70159. get enableVelocity(): boolean;
  70160. /**
  70161. * Sets wether or not objects velocities are enabled for the G buffer.
  70162. */
  70163. set enableVelocity(enable: boolean);
  70164. /**
  70165. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  70166. */
  70167. get enableReflectivity(): boolean;
  70168. /**
  70169. * Sets wether or not objects roughness are enabled for the G buffer.
  70170. */
  70171. set enableReflectivity(enable: boolean);
  70172. /**
  70173. * Gets the scene associated with the buffer.
  70174. */
  70175. get scene(): Scene;
  70176. /**
  70177. * Gets the ratio used by the buffer during its creation.
  70178. * How big is the buffer related to the main canvas.
  70179. */
  70180. get ratio(): number;
  70181. /** @hidden */
  70182. static _SceneComponentInitialization: (scene: Scene) => void;
  70183. /**
  70184. * Creates a new G Buffer for the scene
  70185. * @param scene The scene the buffer belongs to
  70186. * @param ratio How big is the buffer related to the main canvas.
  70187. */
  70188. constructor(scene: Scene, ratio?: number);
  70189. /**
  70190. * Checks wether everything is ready to render a submesh to the G buffer.
  70191. * @param subMesh the submesh to check readiness for
  70192. * @param useInstances is the mesh drawn using instance or not
  70193. * @returns true if ready otherwise false
  70194. */
  70195. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70196. /**
  70197. * Gets the current underlying G Buffer.
  70198. * @returns the buffer
  70199. */
  70200. getGBuffer(): MultiRenderTarget;
  70201. /**
  70202. * Gets the number of samples used to render the buffer (anti aliasing).
  70203. */
  70204. get samples(): number;
  70205. /**
  70206. * Sets the number of samples used to render the buffer (anti aliasing).
  70207. */
  70208. set samples(value: number);
  70209. /**
  70210. * Disposes the renderer and frees up associated resources.
  70211. */
  70212. dispose(): void;
  70213. protected _createRenderTargets(): void;
  70214. private _copyBonesTransformationMatrices;
  70215. }
  70216. }
  70217. declare module BABYLON {
  70218. /**
  70219. * Contains all parameters needed for the prepass to perform
  70220. * motion blur
  70221. */
  70222. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70223. /**
  70224. * Is motion blur enabled
  70225. */
  70226. enabled: boolean;
  70227. /**
  70228. * Name of the configuration
  70229. */
  70230. name: string;
  70231. /**
  70232. * Textures that should be present in the MRT for this effect to work
  70233. */
  70234. readonly texturesRequired: number[];
  70235. }
  70236. }
  70237. declare module BABYLON {
  70238. interface Scene {
  70239. /** @hidden (Backing field) */
  70240. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70241. /**
  70242. * Gets or Sets the current geometry buffer associated to the scene.
  70243. */
  70244. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70245. /**
  70246. * Enables a GeometryBufferRender and associates it with the scene
  70247. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70248. * @returns the GeometryBufferRenderer
  70249. */
  70250. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70251. /**
  70252. * Disables the GeometryBufferRender associated with the scene
  70253. */
  70254. disableGeometryBufferRenderer(): void;
  70255. }
  70256. /**
  70257. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70258. * in several rendering techniques.
  70259. */
  70260. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70261. /**
  70262. * The component name helpful to identify the component in the list of scene components.
  70263. */
  70264. readonly name: string;
  70265. /**
  70266. * The scene the component belongs to.
  70267. */
  70268. scene: Scene;
  70269. /**
  70270. * Creates a new instance of the component for the given scene
  70271. * @param scene Defines the scene to register the component in
  70272. */
  70273. constructor(scene: Scene);
  70274. /**
  70275. * Registers the component in a given scene
  70276. */
  70277. register(): void;
  70278. /**
  70279. * Rebuilds the elements related to this component in case of
  70280. * context lost for instance.
  70281. */
  70282. rebuild(): void;
  70283. /**
  70284. * Disposes the component and the associated ressources
  70285. */
  70286. dispose(): void;
  70287. private _gatherRenderTargets;
  70288. }
  70289. }
  70290. declare module BABYLON {
  70291. /** @hidden */
  70292. export var motionBlurPixelShader: {
  70293. name: string;
  70294. shader: string;
  70295. };
  70296. }
  70297. declare module BABYLON {
  70298. /**
  70299. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70300. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70301. * As an example, all you have to do is to create the post-process:
  70302. * var mb = new BABYLON.MotionBlurPostProcess(
  70303. * 'mb', // The name of the effect.
  70304. * scene, // The scene containing the objects to blur according to their velocity.
  70305. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70306. * camera // The camera to apply the render pass to.
  70307. * );
  70308. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70309. */
  70310. export class MotionBlurPostProcess extends PostProcess {
  70311. /**
  70312. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70313. */
  70314. motionStrength: number;
  70315. /**
  70316. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70317. */
  70318. get motionBlurSamples(): number;
  70319. /**
  70320. * Sets the number of iterations to be used for motion blur quality
  70321. */
  70322. set motionBlurSamples(samples: number);
  70323. private _motionBlurSamples;
  70324. private _forceGeometryBuffer;
  70325. private _geometryBufferRenderer;
  70326. private _prePassRenderer;
  70327. /**
  70328. * Gets a string identifying the name of the class
  70329. * @returns "MotionBlurPostProcess" string
  70330. */
  70331. getClassName(): string;
  70332. /**
  70333. * Creates a new instance MotionBlurPostProcess
  70334. * @param name The name of the effect.
  70335. * @param scene The scene containing the objects to blur according to their velocity.
  70336. * @param options The required width/height ratio to downsize to before computing the render pass.
  70337. * @param camera The camera to apply the render pass to.
  70338. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70339. * @param engine The engine which the post process will be applied. (default: current engine)
  70340. * @param reusable If the post process can be reused on the same frame. (default: false)
  70341. * @param textureType Type of textures used when performing the post process. (default: 0)
  70342. * @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)
  70343. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70344. */
  70345. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70346. /**
  70347. * Excludes the given skinned mesh from computing bones velocities.
  70348. * 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.
  70349. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70350. */
  70351. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70352. /**
  70353. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70354. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70355. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70356. */
  70357. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70358. /**
  70359. * Disposes the post process.
  70360. * @param camera The camera to dispose the post process on.
  70361. */
  70362. dispose(camera?: Camera): void;
  70363. /** @hidden */
  70364. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70365. }
  70366. }
  70367. declare module BABYLON {
  70368. /** @hidden */
  70369. export var refractionPixelShader: {
  70370. name: string;
  70371. shader: string;
  70372. };
  70373. }
  70374. declare module BABYLON {
  70375. /**
  70376. * Post process which applies a refractin texture
  70377. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70378. */
  70379. export class RefractionPostProcess extends PostProcess {
  70380. private _refTexture;
  70381. private _ownRefractionTexture;
  70382. /** the base color of the refraction (used to taint the rendering) */
  70383. color: Color3;
  70384. /** simulated refraction depth */
  70385. depth: number;
  70386. /** the coefficient of the base color (0 to remove base color tainting) */
  70387. colorLevel: number;
  70388. /** Gets the url used to load the refraction texture */
  70389. refractionTextureUrl: string;
  70390. /**
  70391. * Gets or sets the refraction texture
  70392. * Please note that you are responsible for disposing the texture if you set it manually
  70393. */
  70394. get refractionTexture(): Texture;
  70395. set refractionTexture(value: Texture);
  70396. /**
  70397. * Gets a string identifying the name of the class
  70398. * @returns "RefractionPostProcess" string
  70399. */
  70400. getClassName(): string;
  70401. /**
  70402. * Initializes the RefractionPostProcess
  70403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70404. * @param name The name of the effect.
  70405. * @param refractionTextureUrl Url of the refraction texture to use
  70406. * @param color the base color of the refraction (used to taint the rendering)
  70407. * @param depth simulated refraction depth
  70408. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70409. * @param camera The camera to apply the render pass to.
  70410. * @param options The required width/height ratio to downsize to before computing the render pass.
  70411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70412. * @param engine The engine which the post process will be applied. (default: current engine)
  70413. * @param reusable If the post process can be reused on the same frame. (default: false)
  70414. */
  70415. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70416. /**
  70417. * Disposes of the post process
  70418. * @param camera Camera to dispose post process on
  70419. */
  70420. dispose(camera: Camera): void;
  70421. /** @hidden */
  70422. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70423. }
  70424. }
  70425. declare module BABYLON {
  70426. /** @hidden */
  70427. export var sharpenPixelShader: {
  70428. name: string;
  70429. shader: string;
  70430. };
  70431. }
  70432. declare module BABYLON {
  70433. /**
  70434. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70435. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70436. */
  70437. export class SharpenPostProcess extends PostProcess {
  70438. /**
  70439. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70440. */
  70441. colorAmount: number;
  70442. /**
  70443. * How much sharpness should be applied (default: 0.3)
  70444. */
  70445. edgeAmount: number;
  70446. /**
  70447. * Gets a string identifying the name of the class
  70448. * @returns "SharpenPostProcess" string
  70449. */
  70450. getClassName(): string;
  70451. /**
  70452. * Creates a new instance ConvolutionPostProcess
  70453. * @param name The name of the effect.
  70454. * @param options The required width/height ratio to downsize to before computing the render pass.
  70455. * @param camera The camera to apply the render pass to.
  70456. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70457. * @param engine The engine which the post process will be applied. (default: current engine)
  70458. * @param reusable If the post process can be reused on the same frame. (default: false)
  70459. * @param textureType Type of textures used when performing the post process. (default: 0)
  70460. * @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)
  70461. */
  70462. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70463. /** @hidden */
  70464. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70465. }
  70466. }
  70467. declare module BABYLON {
  70468. /**
  70469. * PostProcessRenderPipeline
  70470. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70471. */
  70472. export class PostProcessRenderPipeline {
  70473. private engine;
  70474. private _renderEffects;
  70475. private _renderEffectsForIsolatedPass;
  70476. /**
  70477. * List of inspectable custom properties (used by the Inspector)
  70478. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70479. */
  70480. inspectableCustomProperties: IInspectable[];
  70481. /**
  70482. * @hidden
  70483. */
  70484. protected _cameras: Camera[];
  70485. /** @hidden */
  70486. _name: string;
  70487. /**
  70488. * Gets pipeline name
  70489. */
  70490. get name(): string;
  70491. /** Gets the list of attached cameras */
  70492. get cameras(): Camera[];
  70493. /**
  70494. * Initializes a PostProcessRenderPipeline
  70495. * @param engine engine to add the pipeline to
  70496. * @param name name of the pipeline
  70497. */
  70498. constructor(engine: Engine, name: string);
  70499. /**
  70500. * Gets the class name
  70501. * @returns "PostProcessRenderPipeline"
  70502. */
  70503. getClassName(): string;
  70504. /**
  70505. * If all the render effects in the pipeline are supported
  70506. */
  70507. get isSupported(): boolean;
  70508. /**
  70509. * Adds an effect to the pipeline
  70510. * @param renderEffect the effect to add
  70511. */
  70512. addEffect(renderEffect: PostProcessRenderEffect): void;
  70513. /** @hidden */
  70514. _rebuild(): void;
  70515. /** @hidden */
  70516. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70517. /** @hidden */
  70518. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70519. /** @hidden */
  70520. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70521. /** @hidden */
  70522. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70523. /** @hidden */
  70524. _attachCameras(cameras: Camera, unique: boolean): void;
  70525. /** @hidden */
  70526. _attachCameras(cameras: Camera[], unique: boolean): void;
  70527. /** @hidden */
  70528. _detachCameras(cameras: Camera): void;
  70529. /** @hidden */
  70530. _detachCameras(cameras: Nullable<Camera[]>): void;
  70531. /** @hidden */
  70532. _update(): void;
  70533. /** @hidden */
  70534. _reset(): void;
  70535. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70536. /**
  70537. * Sets the required values to the prepass renderer.
  70538. * @param prePassRenderer defines the prepass renderer to setup.
  70539. * @returns true if the pre pass is needed.
  70540. */
  70541. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70542. /**
  70543. * Disposes of the pipeline
  70544. */
  70545. dispose(): void;
  70546. }
  70547. }
  70548. declare module BABYLON {
  70549. /**
  70550. * PostProcessRenderPipelineManager class
  70551. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70552. */
  70553. export class PostProcessRenderPipelineManager {
  70554. private _renderPipelines;
  70555. /**
  70556. * Initializes a PostProcessRenderPipelineManager
  70557. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70558. */
  70559. constructor();
  70560. /**
  70561. * Gets the list of supported render pipelines
  70562. */
  70563. get supportedPipelines(): PostProcessRenderPipeline[];
  70564. /**
  70565. * Adds a pipeline to the manager
  70566. * @param renderPipeline The pipeline to add
  70567. */
  70568. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70569. /**
  70570. * Attaches a camera to the pipeline
  70571. * @param renderPipelineName The name of the pipeline to attach to
  70572. * @param cameras the camera to attach
  70573. * @param unique if the camera can be attached multiple times to the pipeline
  70574. */
  70575. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70576. /**
  70577. * Detaches a camera from the pipeline
  70578. * @param renderPipelineName The name of the pipeline to detach from
  70579. * @param cameras the camera to detach
  70580. */
  70581. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70582. /**
  70583. * Enables an effect by name on a pipeline
  70584. * @param renderPipelineName the name of the pipeline to enable the effect in
  70585. * @param renderEffectName the name of the effect to enable
  70586. * @param cameras the cameras that the effect should be enabled on
  70587. */
  70588. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70589. /**
  70590. * Disables an effect by name on a pipeline
  70591. * @param renderPipelineName the name of the pipeline to disable the effect in
  70592. * @param renderEffectName the name of the effect to disable
  70593. * @param cameras the cameras that the effect should be disabled on
  70594. */
  70595. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70596. /**
  70597. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70598. */
  70599. update(): void;
  70600. /** @hidden */
  70601. _rebuild(): void;
  70602. /**
  70603. * Disposes of the manager and pipelines
  70604. */
  70605. dispose(): void;
  70606. }
  70607. }
  70608. declare module BABYLON {
  70609. interface Scene {
  70610. /** @hidden (Backing field) */
  70611. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70612. /**
  70613. * Gets the postprocess render pipeline manager
  70614. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70615. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70616. */
  70617. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70618. }
  70619. /**
  70620. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70621. */
  70622. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70623. /**
  70624. * The component name helpfull to identify the component in the list of scene components.
  70625. */
  70626. readonly name: string;
  70627. /**
  70628. * The scene the component belongs to.
  70629. */
  70630. scene: Scene;
  70631. /**
  70632. * Creates a new instance of the component for the given scene
  70633. * @param scene Defines the scene to register the component in
  70634. */
  70635. constructor(scene: Scene);
  70636. /**
  70637. * Registers the component in a given scene
  70638. */
  70639. register(): void;
  70640. /**
  70641. * Rebuilds the elements related to this component in case of
  70642. * context lost for instance.
  70643. */
  70644. rebuild(): void;
  70645. /**
  70646. * Disposes the component and the associated ressources
  70647. */
  70648. dispose(): void;
  70649. private _gatherRenderTargets;
  70650. }
  70651. }
  70652. declare module BABYLON {
  70653. /**
  70654. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70655. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70656. */
  70657. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70658. private _scene;
  70659. private _camerasToBeAttached;
  70660. /**
  70661. * ID of the sharpen post process,
  70662. */
  70663. private readonly SharpenPostProcessId;
  70664. /**
  70665. * @ignore
  70666. * ID of the image processing post process;
  70667. */
  70668. readonly ImageProcessingPostProcessId: string;
  70669. /**
  70670. * @ignore
  70671. * ID of the Fast Approximate Anti-Aliasing post process;
  70672. */
  70673. readonly FxaaPostProcessId: string;
  70674. /**
  70675. * ID of the chromatic aberration post process,
  70676. */
  70677. private readonly ChromaticAberrationPostProcessId;
  70678. /**
  70679. * ID of the grain post process
  70680. */
  70681. private readonly GrainPostProcessId;
  70682. /**
  70683. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70684. */
  70685. sharpen: SharpenPostProcess;
  70686. private _sharpenEffect;
  70687. private bloom;
  70688. /**
  70689. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70690. */
  70691. depthOfField: DepthOfFieldEffect;
  70692. /**
  70693. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70694. */
  70695. fxaa: FxaaPostProcess;
  70696. /**
  70697. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70698. */
  70699. imageProcessing: ImageProcessingPostProcess;
  70700. /**
  70701. * Chromatic aberration post process which will shift rgb colors in the image
  70702. */
  70703. chromaticAberration: ChromaticAberrationPostProcess;
  70704. private _chromaticAberrationEffect;
  70705. /**
  70706. * Grain post process which add noise to the image
  70707. */
  70708. grain: GrainPostProcess;
  70709. private _grainEffect;
  70710. /**
  70711. * Glow post process which adds a glow to emissive areas of the image
  70712. */
  70713. private _glowLayer;
  70714. /**
  70715. * Animations which can be used to tweak settings over a period of time
  70716. */
  70717. animations: Animation[];
  70718. private _imageProcessingConfigurationObserver;
  70719. private _sharpenEnabled;
  70720. private _bloomEnabled;
  70721. private _depthOfFieldEnabled;
  70722. private _depthOfFieldBlurLevel;
  70723. private _fxaaEnabled;
  70724. private _imageProcessingEnabled;
  70725. private _defaultPipelineTextureType;
  70726. private _bloomScale;
  70727. private _chromaticAberrationEnabled;
  70728. private _grainEnabled;
  70729. private _buildAllowed;
  70730. /**
  70731. * Gets active scene
  70732. */
  70733. get scene(): Scene;
  70734. /**
  70735. * Enable or disable the sharpen process from the pipeline
  70736. */
  70737. set sharpenEnabled(enabled: boolean);
  70738. get sharpenEnabled(): boolean;
  70739. private _resizeObserver;
  70740. private _hardwareScaleLevel;
  70741. private _bloomKernel;
  70742. /**
  70743. * Specifies the size of the bloom blur kernel, relative to the final output size
  70744. */
  70745. get bloomKernel(): number;
  70746. set bloomKernel(value: number);
  70747. /**
  70748. * Specifies the weight of the bloom in the final rendering
  70749. */
  70750. private _bloomWeight;
  70751. /**
  70752. * Specifies the luma threshold for the area that will be blurred by the bloom
  70753. */
  70754. private _bloomThreshold;
  70755. private _hdr;
  70756. /**
  70757. * The strength of the bloom.
  70758. */
  70759. set bloomWeight(value: number);
  70760. get bloomWeight(): number;
  70761. /**
  70762. * The strength of the bloom.
  70763. */
  70764. set bloomThreshold(value: number);
  70765. get bloomThreshold(): number;
  70766. /**
  70767. * The scale of the bloom, lower value will provide better performance.
  70768. */
  70769. set bloomScale(value: number);
  70770. get bloomScale(): number;
  70771. /**
  70772. * Enable or disable the bloom from the pipeline
  70773. */
  70774. set bloomEnabled(enabled: boolean);
  70775. get bloomEnabled(): boolean;
  70776. private _rebuildBloom;
  70777. /**
  70778. * If the depth of field is enabled.
  70779. */
  70780. get depthOfFieldEnabled(): boolean;
  70781. set depthOfFieldEnabled(enabled: boolean);
  70782. /**
  70783. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70784. */
  70785. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70786. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70787. /**
  70788. * If the anti aliasing is enabled.
  70789. */
  70790. set fxaaEnabled(enabled: boolean);
  70791. get fxaaEnabled(): boolean;
  70792. private _samples;
  70793. /**
  70794. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70795. */
  70796. set samples(sampleCount: number);
  70797. get samples(): number;
  70798. /**
  70799. * If image processing is enabled.
  70800. */
  70801. set imageProcessingEnabled(enabled: boolean);
  70802. get imageProcessingEnabled(): boolean;
  70803. /**
  70804. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70805. */
  70806. set glowLayerEnabled(enabled: boolean);
  70807. get glowLayerEnabled(): boolean;
  70808. /**
  70809. * Gets the glow layer (or null if not defined)
  70810. */
  70811. get glowLayer(): Nullable<GlowLayer>;
  70812. /**
  70813. * Enable or disable the chromaticAberration process from the pipeline
  70814. */
  70815. set chromaticAberrationEnabled(enabled: boolean);
  70816. get chromaticAberrationEnabled(): boolean;
  70817. /**
  70818. * Enable or disable the grain process from the pipeline
  70819. */
  70820. set grainEnabled(enabled: boolean);
  70821. get grainEnabled(): boolean;
  70822. /**
  70823. * @constructor
  70824. * @param name - The rendering pipeline name (default: "")
  70825. * @param hdr - If high dynamic range textures should be used (default: true)
  70826. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70827. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70828. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70829. */
  70830. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70831. /**
  70832. * Get the class name
  70833. * @returns "DefaultRenderingPipeline"
  70834. */
  70835. getClassName(): string;
  70836. /**
  70837. * Force the compilation of the entire pipeline.
  70838. */
  70839. prepare(): void;
  70840. private _hasCleared;
  70841. private _prevPostProcess;
  70842. private _prevPrevPostProcess;
  70843. private _setAutoClearAndTextureSharing;
  70844. private _depthOfFieldSceneObserver;
  70845. private _buildPipeline;
  70846. private _disposePostProcesses;
  70847. /**
  70848. * Adds a camera to the pipeline
  70849. * @param camera the camera to be added
  70850. */
  70851. addCamera(camera: Camera): void;
  70852. /**
  70853. * Removes a camera from the pipeline
  70854. * @param camera the camera to remove
  70855. */
  70856. removeCamera(camera: Camera): void;
  70857. /**
  70858. * Dispose of the pipeline and stop all post processes
  70859. */
  70860. dispose(): void;
  70861. /**
  70862. * Serialize the rendering pipeline (Used when exporting)
  70863. * @returns the serialized object
  70864. */
  70865. serialize(): any;
  70866. /**
  70867. * Parse the serialized pipeline
  70868. * @param source Source pipeline.
  70869. * @param scene The scene to load the pipeline to.
  70870. * @param rootUrl The URL of the serialized pipeline.
  70871. * @returns An instantiated pipeline from the serialized object.
  70872. */
  70873. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  70874. }
  70875. }
  70876. declare module BABYLON {
  70877. /** @hidden */
  70878. export var lensHighlightsPixelShader: {
  70879. name: string;
  70880. shader: string;
  70881. };
  70882. }
  70883. declare module BABYLON {
  70884. /** @hidden */
  70885. export var depthOfFieldPixelShader: {
  70886. name: string;
  70887. shader: string;
  70888. };
  70889. }
  70890. declare module BABYLON {
  70891. /**
  70892. * BABYLON.JS Chromatic Aberration GLSL Shader
  70893. * Author: Olivier Guyot
  70894. * Separates very slightly R, G and B colors on the edges of the screen
  70895. * Inspired by Francois Tarlier & Martins Upitis
  70896. */
  70897. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  70898. /**
  70899. * @ignore
  70900. * The chromatic aberration PostProcess id in the pipeline
  70901. */
  70902. LensChromaticAberrationEffect: string;
  70903. /**
  70904. * @ignore
  70905. * The highlights enhancing PostProcess id in the pipeline
  70906. */
  70907. HighlightsEnhancingEffect: string;
  70908. /**
  70909. * @ignore
  70910. * The depth-of-field PostProcess id in the pipeline
  70911. */
  70912. LensDepthOfFieldEffect: string;
  70913. private _scene;
  70914. private _depthTexture;
  70915. private _grainTexture;
  70916. private _chromaticAberrationPostProcess;
  70917. private _highlightsPostProcess;
  70918. private _depthOfFieldPostProcess;
  70919. private _edgeBlur;
  70920. private _grainAmount;
  70921. private _chromaticAberration;
  70922. private _distortion;
  70923. private _highlightsGain;
  70924. private _highlightsThreshold;
  70925. private _dofDistance;
  70926. private _dofAperture;
  70927. private _dofDarken;
  70928. private _dofPentagon;
  70929. private _blurNoise;
  70930. /**
  70931. * @constructor
  70932. *
  70933. * Effect parameters are as follow:
  70934. * {
  70935. * chromatic_aberration: number; // from 0 to x (1 for realism)
  70936. * edge_blur: number; // from 0 to x (1 for realism)
  70937. * distortion: number; // from 0 to x (1 for realism)
  70938. * grain_amount: number; // from 0 to 1
  70939. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  70940. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  70941. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  70942. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  70943. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  70944. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  70945. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  70946. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  70947. * }
  70948. * Note: if an effect parameter is unset, effect is disabled
  70949. *
  70950. * @param name The rendering pipeline name
  70951. * @param parameters - An object containing all parameters (see above)
  70952. * @param scene The scene linked to this pipeline
  70953. * @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)
  70954. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70955. */
  70956. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  70957. /**
  70958. * Get the class name
  70959. * @returns "LensRenderingPipeline"
  70960. */
  70961. getClassName(): string;
  70962. /**
  70963. * Gets associated scene
  70964. */
  70965. get scene(): Scene;
  70966. /**
  70967. * Gets or sets the edge blur
  70968. */
  70969. get edgeBlur(): number;
  70970. set edgeBlur(value: number);
  70971. /**
  70972. * Gets or sets the grain amount
  70973. */
  70974. get grainAmount(): number;
  70975. set grainAmount(value: number);
  70976. /**
  70977. * Gets or sets the chromatic aberration amount
  70978. */
  70979. get chromaticAberration(): number;
  70980. set chromaticAberration(value: number);
  70981. /**
  70982. * Gets or sets the depth of field aperture
  70983. */
  70984. get dofAperture(): number;
  70985. set dofAperture(value: number);
  70986. /**
  70987. * Gets or sets the edge distortion
  70988. */
  70989. get edgeDistortion(): number;
  70990. set edgeDistortion(value: number);
  70991. /**
  70992. * Gets or sets the depth of field distortion
  70993. */
  70994. get dofDistortion(): number;
  70995. set dofDistortion(value: number);
  70996. /**
  70997. * Gets or sets the darken out of focus amount
  70998. */
  70999. get darkenOutOfFocus(): number;
  71000. set darkenOutOfFocus(value: number);
  71001. /**
  71002. * Gets or sets a boolean indicating if blur noise is enabled
  71003. */
  71004. get blurNoise(): boolean;
  71005. set blurNoise(value: boolean);
  71006. /**
  71007. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71008. */
  71009. get pentagonBokeh(): boolean;
  71010. set pentagonBokeh(value: boolean);
  71011. /**
  71012. * Gets or sets the highlight grain amount
  71013. */
  71014. get highlightsGain(): number;
  71015. set highlightsGain(value: number);
  71016. /**
  71017. * Gets or sets the highlight threshold
  71018. */
  71019. get highlightsThreshold(): number;
  71020. set highlightsThreshold(value: number);
  71021. /**
  71022. * Sets the amount of blur at the edges
  71023. * @param amount blur amount
  71024. */
  71025. setEdgeBlur(amount: number): void;
  71026. /**
  71027. * Sets edge blur to 0
  71028. */
  71029. disableEdgeBlur(): void;
  71030. /**
  71031. * Sets the amout of grain
  71032. * @param amount Amount of grain
  71033. */
  71034. setGrainAmount(amount: number): void;
  71035. /**
  71036. * Set grain amount to 0
  71037. */
  71038. disableGrain(): void;
  71039. /**
  71040. * Sets the chromatic aberration amount
  71041. * @param amount amount of chromatic aberration
  71042. */
  71043. setChromaticAberration(amount: number): void;
  71044. /**
  71045. * Sets chromatic aberration amount to 0
  71046. */
  71047. disableChromaticAberration(): void;
  71048. /**
  71049. * Sets the EdgeDistortion amount
  71050. * @param amount amount of EdgeDistortion
  71051. */
  71052. setEdgeDistortion(amount: number): void;
  71053. /**
  71054. * Sets edge distortion to 0
  71055. */
  71056. disableEdgeDistortion(): void;
  71057. /**
  71058. * Sets the FocusDistance amount
  71059. * @param amount amount of FocusDistance
  71060. */
  71061. setFocusDistance(amount: number): void;
  71062. /**
  71063. * Disables depth of field
  71064. */
  71065. disableDepthOfField(): void;
  71066. /**
  71067. * Sets the Aperture amount
  71068. * @param amount amount of Aperture
  71069. */
  71070. setAperture(amount: number): void;
  71071. /**
  71072. * Sets the DarkenOutOfFocus amount
  71073. * @param amount amount of DarkenOutOfFocus
  71074. */
  71075. setDarkenOutOfFocus(amount: number): void;
  71076. private _pentagonBokehIsEnabled;
  71077. /**
  71078. * Creates a pentagon bokeh effect
  71079. */
  71080. enablePentagonBokeh(): void;
  71081. /**
  71082. * Disables the pentagon bokeh effect
  71083. */
  71084. disablePentagonBokeh(): void;
  71085. /**
  71086. * Enables noise blur
  71087. */
  71088. enableNoiseBlur(): void;
  71089. /**
  71090. * Disables noise blur
  71091. */
  71092. disableNoiseBlur(): void;
  71093. /**
  71094. * Sets the HighlightsGain amount
  71095. * @param amount amount of HighlightsGain
  71096. */
  71097. setHighlightsGain(amount: number): void;
  71098. /**
  71099. * Sets the HighlightsThreshold amount
  71100. * @param amount amount of HighlightsThreshold
  71101. */
  71102. setHighlightsThreshold(amount: number): void;
  71103. /**
  71104. * Disables highlights
  71105. */
  71106. disableHighlights(): void;
  71107. /**
  71108. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71109. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71110. */
  71111. dispose(disableDepthRender?: boolean): void;
  71112. private _createChromaticAberrationPostProcess;
  71113. private _createHighlightsPostProcess;
  71114. private _createDepthOfFieldPostProcess;
  71115. private _createGrainTexture;
  71116. }
  71117. }
  71118. declare module BABYLON {
  71119. /**
  71120. * Contains all parameters needed for the prepass to perform
  71121. * screen space subsurface scattering
  71122. */
  71123. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71124. /**
  71125. * Is subsurface enabled
  71126. */
  71127. enabled: boolean;
  71128. /**
  71129. * Name of the configuration
  71130. */
  71131. name: string;
  71132. /**
  71133. * Textures that should be present in the MRT for this effect to work
  71134. */
  71135. readonly texturesRequired: number[];
  71136. }
  71137. }
  71138. declare module BABYLON {
  71139. /** @hidden */
  71140. export var ssao2PixelShader: {
  71141. name: string;
  71142. shader: string;
  71143. };
  71144. }
  71145. declare module BABYLON {
  71146. /** @hidden */
  71147. export var ssaoCombinePixelShader: {
  71148. name: string;
  71149. shader: string;
  71150. };
  71151. }
  71152. declare module BABYLON {
  71153. /**
  71154. * Render pipeline to produce ssao effect
  71155. */
  71156. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71157. /**
  71158. * @ignore
  71159. * The PassPostProcess id in the pipeline that contains the original scene color
  71160. */
  71161. SSAOOriginalSceneColorEffect: string;
  71162. /**
  71163. * @ignore
  71164. * The SSAO PostProcess id in the pipeline
  71165. */
  71166. SSAORenderEffect: string;
  71167. /**
  71168. * @ignore
  71169. * The horizontal blur PostProcess id in the pipeline
  71170. */
  71171. SSAOBlurHRenderEffect: string;
  71172. /**
  71173. * @ignore
  71174. * The vertical blur PostProcess id in the pipeline
  71175. */
  71176. SSAOBlurVRenderEffect: string;
  71177. /**
  71178. * @ignore
  71179. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71180. */
  71181. SSAOCombineRenderEffect: string;
  71182. /**
  71183. * The output strength of the SSAO post-process. Default value is 1.0.
  71184. */
  71185. totalStrength: number;
  71186. /**
  71187. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71188. */
  71189. maxZ: number;
  71190. /**
  71191. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71192. */
  71193. minZAspect: number;
  71194. private _samples;
  71195. /**
  71196. * Number of samples used for the SSAO calculations. Default value is 8
  71197. */
  71198. set samples(n: number);
  71199. get samples(): number;
  71200. private _textureSamples;
  71201. /**
  71202. * Number of samples to use for antialiasing
  71203. */
  71204. set textureSamples(n: number);
  71205. get textureSamples(): number;
  71206. /**
  71207. * Force rendering the geometry through geometry buffer
  71208. */
  71209. private _forceGeometryBuffer;
  71210. /**
  71211. * Ratio object used for SSAO ratio and blur ratio
  71212. */
  71213. private _ratio;
  71214. /**
  71215. * Dynamically generated sphere sampler.
  71216. */
  71217. private _sampleSphere;
  71218. /**
  71219. * Blur filter offsets
  71220. */
  71221. private _samplerOffsets;
  71222. private _expensiveBlur;
  71223. /**
  71224. * If bilateral blur should be used
  71225. */
  71226. set expensiveBlur(b: boolean);
  71227. get expensiveBlur(): boolean;
  71228. /**
  71229. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71230. */
  71231. radius: number;
  71232. /**
  71233. * The base color of the SSAO post-process
  71234. * The final result is "base + ssao" between [0, 1]
  71235. */
  71236. base: number;
  71237. /**
  71238. * Support test.
  71239. */
  71240. static get IsSupported(): boolean;
  71241. private _scene;
  71242. private _randomTexture;
  71243. private _originalColorPostProcess;
  71244. private _ssaoPostProcess;
  71245. private _blurHPostProcess;
  71246. private _blurVPostProcess;
  71247. private _ssaoCombinePostProcess;
  71248. private _prePassRenderer;
  71249. /**
  71250. * Gets active scene
  71251. */
  71252. get scene(): Scene;
  71253. /**
  71254. * @constructor
  71255. * @param name The rendering pipeline name
  71256. * @param scene The scene linked to this pipeline
  71257. * @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 }
  71258. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71259. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71260. */
  71261. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71262. /**
  71263. * Get the class name
  71264. * @returns "SSAO2RenderingPipeline"
  71265. */
  71266. getClassName(): string;
  71267. /**
  71268. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71269. */
  71270. dispose(disableGeometryBufferRenderer?: boolean): void;
  71271. private _createBlurPostProcess;
  71272. /** @hidden */
  71273. _rebuild(): void;
  71274. private _bits;
  71275. private _radicalInverse_VdC;
  71276. private _hammersley;
  71277. private _hemisphereSample_uniform;
  71278. private _generateHemisphere;
  71279. private _getDefinesForSSAO;
  71280. private _createSSAOPostProcess;
  71281. private _createSSAOCombinePostProcess;
  71282. private _createRandomTexture;
  71283. /**
  71284. * Serialize the rendering pipeline (Used when exporting)
  71285. * @returns the serialized object
  71286. */
  71287. serialize(): any;
  71288. /**
  71289. * Parse the serialized pipeline
  71290. * @param source Source pipeline.
  71291. * @param scene The scene to load the pipeline to.
  71292. * @param rootUrl The URL of the serialized pipeline.
  71293. * @returns An instantiated pipeline from the serialized object.
  71294. */
  71295. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71296. }
  71297. }
  71298. declare module BABYLON {
  71299. /** @hidden */
  71300. export var ssaoPixelShader: {
  71301. name: string;
  71302. shader: string;
  71303. };
  71304. }
  71305. declare module BABYLON {
  71306. /**
  71307. * Render pipeline to produce ssao effect
  71308. */
  71309. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71310. /**
  71311. * @ignore
  71312. * The PassPostProcess id in the pipeline that contains the original scene color
  71313. */
  71314. SSAOOriginalSceneColorEffect: string;
  71315. /**
  71316. * @ignore
  71317. * The SSAO PostProcess id in the pipeline
  71318. */
  71319. SSAORenderEffect: string;
  71320. /**
  71321. * @ignore
  71322. * The horizontal blur PostProcess id in the pipeline
  71323. */
  71324. SSAOBlurHRenderEffect: string;
  71325. /**
  71326. * @ignore
  71327. * The vertical blur PostProcess id in the pipeline
  71328. */
  71329. SSAOBlurVRenderEffect: string;
  71330. /**
  71331. * @ignore
  71332. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71333. */
  71334. SSAOCombineRenderEffect: string;
  71335. /**
  71336. * The output strength of the SSAO post-process. Default value is 1.0.
  71337. */
  71338. totalStrength: number;
  71339. /**
  71340. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71341. */
  71342. radius: number;
  71343. /**
  71344. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71345. * Must not be equal to fallOff and superior to fallOff.
  71346. * Default value is 0.0075
  71347. */
  71348. area: number;
  71349. /**
  71350. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71351. * Must not be equal to area and inferior to area.
  71352. * Default value is 0.000001
  71353. */
  71354. fallOff: number;
  71355. /**
  71356. * The base color of the SSAO post-process
  71357. * The final result is "base + ssao" between [0, 1]
  71358. */
  71359. base: number;
  71360. private _scene;
  71361. private _depthTexture;
  71362. private _randomTexture;
  71363. private _originalColorPostProcess;
  71364. private _ssaoPostProcess;
  71365. private _blurHPostProcess;
  71366. private _blurVPostProcess;
  71367. private _ssaoCombinePostProcess;
  71368. private _firstUpdate;
  71369. /**
  71370. * Gets active scene
  71371. */
  71372. get scene(): Scene;
  71373. /**
  71374. * @constructor
  71375. * @param name - The rendering pipeline name
  71376. * @param scene - The scene linked to this pipeline
  71377. * @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 }
  71378. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71379. */
  71380. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71381. /**
  71382. * Get the class name
  71383. * @returns "SSAORenderingPipeline"
  71384. */
  71385. getClassName(): string;
  71386. /**
  71387. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71388. */
  71389. dispose(disableDepthRender?: boolean): void;
  71390. private _createBlurPostProcess;
  71391. /** @hidden */
  71392. _rebuild(): void;
  71393. private _createSSAOPostProcess;
  71394. private _createSSAOCombinePostProcess;
  71395. private _createRandomTexture;
  71396. }
  71397. }
  71398. declare module BABYLON {
  71399. /**
  71400. * Contains all parameters needed for the prepass to perform
  71401. * screen space reflections
  71402. */
  71403. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71404. /**
  71405. * Is ssr enabled
  71406. */
  71407. enabled: boolean;
  71408. /**
  71409. * Name of the configuration
  71410. */
  71411. name: string;
  71412. /**
  71413. * Textures that should be present in the MRT for this effect to work
  71414. */
  71415. readonly texturesRequired: number[];
  71416. }
  71417. }
  71418. declare module BABYLON {
  71419. /** @hidden */
  71420. export var screenSpaceReflectionPixelShader: {
  71421. name: string;
  71422. shader: string;
  71423. };
  71424. }
  71425. declare module BABYLON {
  71426. /**
  71427. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71428. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71429. */
  71430. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71431. /**
  71432. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71433. */
  71434. threshold: number;
  71435. /**
  71436. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71437. */
  71438. strength: number;
  71439. /**
  71440. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71441. */
  71442. reflectionSpecularFalloffExponent: number;
  71443. /**
  71444. * 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]
  71445. */
  71446. step: number;
  71447. /**
  71448. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71449. */
  71450. roughnessFactor: number;
  71451. private _forceGeometryBuffer;
  71452. private _geometryBufferRenderer;
  71453. private _prePassRenderer;
  71454. private _enableSmoothReflections;
  71455. private _reflectionSamples;
  71456. private _smoothSteps;
  71457. /**
  71458. * Gets a string identifying the name of the class
  71459. * @returns "ScreenSpaceReflectionPostProcess" string
  71460. */
  71461. getClassName(): string;
  71462. /**
  71463. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71464. * @param name The name of the effect.
  71465. * @param scene The scene containing the objects to calculate reflections.
  71466. * @param options The required width/height ratio to downsize to before computing the render pass.
  71467. * @param camera The camera to apply the render pass to.
  71468. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71469. * @param engine The engine which the post process will be applied. (default: current engine)
  71470. * @param reusable If the post process can be reused on the same frame. (default: false)
  71471. * @param textureType Type of textures used when performing the post process. (default: 0)
  71472. * @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)
  71473. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71474. */
  71475. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71476. /**
  71477. * Gets wether or not smoothing reflections is enabled.
  71478. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71479. */
  71480. get enableSmoothReflections(): boolean;
  71481. /**
  71482. * Sets wether or not smoothing reflections is enabled.
  71483. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71484. */
  71485. set enableSmoothReflections(enabled: boolean);
  71486. /**
  71487. * Gets the number of samples taken while computing reflections. More samples count is high,
  71488. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71489. */
  71490. get reflectionSamples(): number;
  71491. /**
  71492. * Sets the number of samples taken while computing reflections. More samples count is high,
  71493. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71494. */
  71495. set reflectionSamples(samples: number);
  71496. /**
  71497. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71498. * more the post-process will require GPU power and can generate a drop in FPS.
  71499. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71500. */
  71501. get smoothSteps(): number;
  71502. set smoothSteps(steps: number);
  71503. private _updateEffectDefines;
  71504. /** @hidden */
  71505. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71506. }
  71507. }
  71508. declare module BABYLON {
  71509. /** @hidden */
  71510. export var standardPixelShader: {
  71511. name: string;
  71512. shader: string;
  71513. };
  71514. }
  71515. declare module BABYLON {
  71516. /**
  71517. * Standard rendering pipeline
  71518. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71519. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71520. */
  71521. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71522. /**
  71523. * Public members
  71524. */
  71525. /**
  71526. * Post-process which contains the original scene color before the pipeline applies all the effects
  71527. */
  71528. originalPostProcess: Nullable<PostProcess>;
  71529. /**
  71530. * Post-process used to down scale an image x4
  71531. */
  71532. downSampleX4PostProcess: Nullable<PostProcess>;
  71533. /**
  71534. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71535. */
  71536. brightPassPostProcess: Nullable<PostProcess>;
  71537. /**
  71538. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71539. */
  71540. blurHPostProcesses: PostProcess[];
  71541. /**
  71542. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71543. */
  71544. blurVPostProcesses: PostProcess[];
  71545. /**
  71546. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71547. */
  71548. textureAdderPostProcess: Nullable<PostProcess>;
  71549. /**
  71550. * Post-process used to create volumetric lighting effect
  71551. */
  71552. volumetricLightPostProcess: Nullable<PostProcess>;
  71553. /**
  71554. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71555. */
  71556. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71557. /**
  71558. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71559. */
  71560. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71561. /**
  71562. * Post-process used to merge the volumetric light effect and the real scene color
  71563. */
  71564. volumetricLightMergePostProces: Nullable<PostProcess>;
  71565. /**
  71566. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71567. */
  71568. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71569. /**
  71570. * Base post-process used to calculate the average luminance of the final image for HDR
  71571. */
  71572. luminancePostProcess: Nullable<PostProcess>;
  71573. /**
  71574. * Post-processes used to create down sample post-processes in order to get
  71575. * the average luminance of the final image for HDR
  71576. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71577. */
  71578. luminanceDownSamplePostProcesses: PostProcess[];
  71579. /**
  71580. * Post-process used to create a HDR effect (light adaptation)
  71581. */
  71582. hdrPostProcess: Nullable<PostProcess>;
  71583. /**
  71584. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71585. */
  71586. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71587. /**
  71588. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71589. */
  71590. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71591. /**
  71592. * Post-process used to merge the final HDR post-process and the real scene color
  71593. */
  71594. hdrFinalPostProcess: Nullable<PostProcess>;
  71595. /**
  71596. * Post-process used to create a lens flare effect
  71597. */
  71598. lensFlarePostProcess: Nullable<PostProcess>;
  71599. /**
  71600. * Post-process that merges the result of the lens flare post-process and the real scene color
  71601. */
  71602. lensFlareComposePostProcess: Nullable<PostProcess>;
  71603. /**
  71604. * Post-process used to create a motion blur effect
  71605. */
  71606. motionBlurPostProcess: Nullable<PostProcess>;
  71607. /**
  71608. * Post-process used to create a depth of field effect
  71609. */
  71610. depthOfFieldPostProcess: Nullable<PostProcess>;
  71611. /**
  71612. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71613. */
  71614. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71615. /**
  71616. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71617. */
  71618. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71619. /**
  71620. * Represents the brightness threshold in order to configure the illuminated surfaces
  71621. */
  71622. brightThreshold: number;
  71623. /**
  71624. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71625. */
  71626. blurWidth: number;
  71627. /**
  71628. * Sets if the blur for highlighted surfaces must be only horizontal
  71629. */
  71630. horizontalBlur: boolean;
  71631. /**
  71632. * Gets the overall exposure used by the pipeline
  71633. */
  71634. get exposure(): number;
  71635. /**
  71636. * Sets the overall exposure used by the pipeline
  71637. */
  71638. set exposure(value: number);
  71639. /**
  71640. * Texture used typically to simulate "dirty" on camera lens
  71641. */
  71642. lensTexture: Nullable<Texture>;
  71643. /**
  71644. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71645. */
  71646. volumetricLightCoefficient: number;
  71647. /**
  71648. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71649. */
  71650. volumetricLightPower: number;
  71651. /**
  71652. * Used the set the blur intensity to smooth the volumetric lights
  71653. */
  71654. volumetricLightBlurScale: number;
  71655. /**
  71656. * Light (spot or directional) used to generate the volumetric lights rays
  71657. * The source light must have a shadow generate so the pipeline can get its
  71658. * depth map
  71659. */
  71660. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71661. /**
  71662. * For eye adaptation, represents the minimum luminance the eye can see
  71663. */
  71664. hdrMinimumLuminance: number;
  71665. /**
  71666. * For eye adaptation, represents the decrease luminance speed
  71667. */
  71668. hdrDecreaseRate: number;
  71669. /**
  71670. * For eye adaptation, represents the increase luminance speed
  71671. */
  71672. hdrIncreaseRate: number;
  71673. /**
  71674. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71675. */
  71676. get hdrAutoExposure(): boolean;
  71677. /**
  71678. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71679. */
  71680. set hdrAutoExposure(value: boolean);
  71681. /**
  71682. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71683. */
  71684. lensColorTexture: Nullable<Texture>;
  71685. /**
  71686. * The overall strengh for the lens flare effect
  71687. */
  71688. lensFlareStrength: number;
  71689. /**
  71690. * Dispersion coefficient for lens flare ghosts
  71691. */
  71692. lensFlareGhostDispersal: number;
  71693. /**
  71694. * Main lens flare halo width
  71695. */
  71696. lensFlareHaloWidth: number;
  71697. /**
  71698. * Based on the lens distortion effect, defines how much the lens flare result
  71699. * is distorted
  71700. */
  71701. lensFlareDistortionStrength: number;
  71702. /**
  71703. * Configures the blur intensity used for for lens flare (halo)
  71704. */
  71705. lensFlareBlurWidth: number;
  71706. /**
  71707. * Lens star texture must be used to simulate rays on the flares and is available
  71708. * in the documentation
  71709. */
  71710. lensStarTexture: Nullable<Texture>;
  71711. /**
  71712. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71713. * flare effect by taking account of the dirt texture
  71714. */
  71715. lensFlareDirtTexture: Nullable<Texture>;
  71716. /**
  71717. * Represents the focal length for the depth of field effect
  71718. */
  71719. depthOfFieldDistance: number;
  71720. /**
  71721. * Represents the blur intensity for the blurred part of the depth of field effect
  71722. */
  71723. depthOfFieldBlurWidth: number;
  71724. /**
  71725. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71726. */
  71727. get motionStrength(): number;
  71728. /**
  71729. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71730. */
  71731. set motionStrength(strength: number);
  71732. /**
  71733. * Gets wether or not the motion blur post-process is object based or screen based.
  71734. */
  71735. get objectBasedMotionBlur(): boolean;
  71736. /**
  71737. * Sets wether or not the motion blur post-process should be object based or screen based
  71738. */
  71739. set objectBasedMotionBlur(value: boolean);
  71740. /**
  71741. * List of animations for the pipeline (IAnimatable implementation)
  71742. */
  71743. animations: Animation[];
  71744. /**
  71745. * Private members
  71746. */
  71747. private _scene;
  71748. private _currentDepthOfFieldSource;
  71749. private _basePostProcess;
  71750. private _fixedExposure;
  71751. private _currentExposure;
  71752. private _hdrAutoExposure;
  71753. private _hdrCurrentLuminance;
  71754. private _motionStrength;
  71755. private _isObjectBasedMotionBlur;
  71756. private _floatTextureType;
  71757. private _camerasToBeAttached;
  71758. private _ratio;
  71759. private _bloomEnabled;
  71760. private _depthOfFieldEnabled;
  71761. private _vlsEnabled;
  71762. private _lensFlareEnabled;
  71763. private _hdrEnabled;
  71764. private _motionBlurEnabled;
  71765. private _fxaaEnabled;
  71766. private _screenSpaceReflectionsEnabled;
  71767. private _motionBlurSamples;
  71768. private _volumetricLightStepsCount;
  71769. private _samples;
  71770. /**
  71771. * @ignore
  71772. * Specifies if the bloom pipeline is enabled
  71773. */
  71774. get BloomEnabled(): boolean;
  71775. set BloomEnabled(enabled: boolean);
  71776. /**
  71777. * @ignore
  71778. * Specifies if the depth of field pipeline is enabed
  71779. */
  71780. get DepthOfFieldEnabled(): boolean;
  71781. set DepthOfFieldEnabled(enabled: boolean);
  71782. /**
  71783. * @ignore
  71784. * Specifies if the lens flare pipeline is enabed
  71785. */
  71786. get LensFlareEnabled(): boolean;
  71787. set LensFlareEnabled(enabled: boolean);
  71788. /**
  71789. * @ignore
  71790. * Specifies if the HDR pipeline is enabled
  71791. */
  71792. get HDREnabled(): boolean;
  71793. set HDREnabled(enabled: boolean);
  71794. /**
  71795. * @ignore
  71796. * Specifies if the volumetric lights scattering effect is enabled
  71797. */
  71798. get VLSEnabled(): boolean;
  71799. set VLSEnabled(enabled: boolean);
  71800. /**
  71801. * @ignore
  71802. * Specifies if the motion blur effect is enabled
  71803. */
  71804. get MotionBlurEnabled(): boolean;
  71805. set MotionBlurEnabled(enabled: boolean);
  71806. /**
  71807. * Specifies if anti-aliasing is enabled
  71808. */
  71809. get fxaaEnabled(): boolean;
  71810. set fxaaEnabled(enabled: boolean);
  71811. /**
  71812. * Specifies if screen space reflections are enabled.
  71813. */
  71814. get screenSpaceReflectionsEnabled(): boolean;
  71815. set screenSpaceReflectionsEnabled(enabled: boolean);
  71816. /**
  71817. * Specifies the number of steps used to calculate the volumetric lights
  71818. * Typically in interval [50, 200]
  71819. */
  71820. get volumetricLightStepsCount(): number;
  71821. set volumetricLightStepsCount(count: number);
  71822. /**
  71823. * Specifies the number of samples used for the motion blur effect
  71824. * Typically in interval [16, 64]
  71825. */
  71826. get motionBlurSamples(): number;
  71827. set motionBlurSamples(samples: number);
  71828. /**
  71829. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71830. */
  71831. get samples(): number;
  71832. set samples(sampleCount: number);
  71833. /**
  71834. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71835. * @constructor
  71836. * @param name The rendering pipeline name
  71837. * @param scene The scene linked to this pipeline
  71838. * @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)
  71839. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71840. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71841. */
  71842. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71843. private _buildPipeline;
  71844. private _createDownSampleX4PostProcess;
  71845. private _createBrightPassPostProcess;
  71846. private _createBlurPostProcesses;
  71847. private _createTextureAdderPostProcess;
  71848. private _createVolumetricLightPostProcess;
  71849. private _createLuminancePostProcesses;
  71850. private _createHdrPostProcess;
  71851. private _createLensFlarePostProcess;
  71852. private _createDepthOfFieldPostProcess;
  71853. private _createMotionBlurPostProcess;
  71854. private _getDepthTexture;
  71855. private _disposePostProcesses;
  71856. /**
  71857. * Dispose of the pipeline and stop all post processes
  71858. */
  71859. dispose(): void;
  71860. /**
  71861. * Serialize the rendering pipeline (Used when exporting)
  71862. * @returns the serialized object
  71863. */
  71864. serialize(): any;
  71865. /**
  71866. * Parse the serialized pipeline
  71867. * @param source Source pipeline.
  71868. * @param scene The scene to load the pipeline to.
  71869. * @param rootUrl The URL of the serialized pipeline.
  71870. * @returns An instantiated pipeline from the serialized object.
  71871. */
  71872. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  71873. /**
  71874. * Luminance steps
  71875. */
  71876. static LuminanceSteps: number;
  71877. }
  71878. }
  71879. declare module BABYLON {
  71880. /** @hidden */
  71881. export var stereoscopicInterlacePixelShader: {
  71882. name: string;
  71883. shader: string;
  71884. };
  71885. }
  71886. declare module BABYLON {
  71887. /**
  71888. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  71889. */
  71890. export class StereoscopicInterlacePostProcessI extends PostProcess {
  71891. private _stepSize;
  71892. private _passedProcess;
  71893. /**
  71894. * Gets a string identifying the name of the class
  71895. * @returns "StereoscopicInterlacePostProcessI" string
  71896. */
  71897. getClassName(): string;
  71898. /**
  71899. * Initializes a StereoscopicInterlacePostProcessI
  71900. * @param name The name of the effect.
  71901. * @param rigCameras The rig cameras to be appled to the post process
  71902. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  71903. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  71904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71905. * @param engine The engine which the post process will be applied. (default: current engine)
  71906. * @param reusable If the post process can be reused on the same frame. (default: false)
  71907. */
  71908. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71909. }
  71910. /**
  71911. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  71912. */
  71913. export class StereoscopicInterlacePostProcess extends PostProcess {
  71914. private _stepSize;
  71915. private _passedProcess;
  71916. /**
  71917. * Gets a string identifying the name of the class
  71918. * @returns "StereoscopicInterlacePostProcess" string
  71919. */
  71920. getClassName(): string;
  71921. /**
  71922. * Initializes a StereoscopicInterlacePostProcess
  71923. * @param name The name of the effect.
  71924. * @param rigCameras The rig cameras to be appled to the post process
  71925. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  71926. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71927. * @param engine The engine which the post process will be applied. (default: current engine)
  71928. * @param reusable If the post process can be reused on the same frame. (default: false)
  71929. */
  71930. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71931. }
  71932. }
  71933. declare module BABYLON {
  71934. /** @hidden */
  71935. export var tonemapPixelShader: {
  71936. name: string;
  71937. shader: string;
  71938. };
  71939. }
  71940. declare module BABYLON {
  71941. /** Defines operator used for tonemapping */
  71942. export enum TonemappingOperator {
  71943. /** Hable */
  71944. Hable = 0,
  71945. /** Reinhard */
  71946. Reinhard = 1,
  71947. /** HejiDawson */
  71948. HejiDawson = 2,
  71949. /** Photographic */
  71950. Photographic = 3
  71951. }
  71952. /**
  71953. * Defines a post process to apply tone mapping
  71954. */
  71955. export class TonemapPostProcess extends PostProcess {
  71956. private _operator;
  71957. /** Defines the required exposure adjustement */
  71958. exposureAdjustment: number;
  71959. /**
  71960. * Gets a string identifying the name of the class
  71961. * @returns "TonemapPostProcess" string
  71962. */
  71963. getClassName(): string;
  71964. /**
  71965. * Creates a new TonemapPostProcess
  71966. * @param name defines the name of the postprocess
  71967. * @param _operator defines the operator to use
  71968. * @param exposureAdjustment defines the required exposure adjustement
  71969. * @param camera defines the camera to use (can be null)
  71970. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  71971. * @param engine defines the hosting engine (can be ignore if camera is set)
  71972. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  71973. */
  71974. constructor(name: string, _operator: TonemappingOperator,
  71975. /** Defines the required exposure adjustement */
  71976. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  71977. }
  71978. }
  71979. declare module BABYLON {
  71980. /** @hidden */
  71981. export var volumetricLightScatteringPixelShader: {
  71982. name: string;
  71983. shader: string;
  71984. };
  71985. }
  71986. declare module BABYLON {
  71987. /** @hidden */
  71988. export var volumetricLightScatteringPassVertexShader: {
  71989. name: string;
  71990. shader: string;
  71991. };
  71992. }
  71993. declare module BABYLON {
  71994. /** @hidden */
  71995. export var volumetricLightScatteringPassPixelShader: {
  71996. name: string;
  71997. shader: string;
  71998. };
  71999. }
  72000. declare module BABYLON {
  72001. /**
  72002. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72003. */
  72004. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72005. private _volumetricLightScatteringPass;
  72006. private _volumetricLightScatteringRTT;
  72007. private _viewPort;
  72008. private _screenCoordinates;
  72009. private _cachedDefines;
  72010. /**
  72011. * If not undefined, the mesh position is computed from the attached node position
  72012. */
  72013. attachedNode: {
  72014. position: Vector3;
  72015. };
  72016. /**
  72017. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72018. */
  72019. customMeshPosition: Vector3;
  72020. /**
  72021. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72022. */
  72023. useCustomMeshPosition: boolean;
  72024. /**
  72025. * If the post-process should inverse the light scattering direction
  72026. */
  72027. invert: boolean;
  72028. /**
  72029. * The internal mesh used by the post-process
  72030. */
  72031. mesh: Mesh;
  72032. /**
  72033. * @hidden
  72034. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72035. */
  72036. get useDiffuseColor(): boolean;
  72037. set useDiffuseColor(useDiffuseColor: boolean);
  72038. /**
  72039. * Array containing the excluded meshes not rendered in the internal pass
  72040. */
  72041. excludedMeshes: AbstractMesh[];
  72042. /**
  72043. * Controls the overall intensity of the post-process
  72044. */
  72045. exposure: number;
  72046. /**
  72047. * Dissipates each sample's contribution in range [0, 1]
  72048. */
  72049. decay: number;
  72050. /**
  72051. * Controls the overall intensity of each sample
  72052. */
  72053. weight: number;
  72054. /**
  72055. * Controls the density of each sample
  72056. */
  72057. density: number;
  72058. /**
  72059. * @constructor
  72060. * @param name The post-process name
  72061. * @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)
  72062. * @param camera The camera that the post-process will be attached to
  72063. * @param mesh The mesh used to create the light scattering
  72064. * @param samples The post-process quality, default 100
  72065. * @param samplingModeThe post-process filtering mode
  72066. * @param engine The babylon engine
  72067. * @param reusable If the post-process is reusable
  72068. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72069. */
  72070. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72071. /**
  72072. * Returns the string "VolumetricLightScatteringPostProcess"
  72073. * @returns "VolumetricLightScatteringPostProcess"
  72074. */
  72075. getClassName(): string;
  72076. private _isReady;
  72077. /**
  72078. * Sets the new light position for light scattering effect
  72079. * @param position The new custom light position
  72080. */
  72081. setCustomMeshPosition(position: Vector3): void;
  72082. /**
  72083. * Returns the light position for light scattering effect
  72084. * @return Vector3 The custom light position
  72085. */
  72086. getCustomMeshPosition(): Vector3;
  72087. /**
  72088. * Disposes the internal assets and detaches the post-process from the camera
  72089. */
  72090. dispose(camera: Camera): void;
  72091. /**
  72092. * Returns the render target texture used by the post-process
  72093. * @return the render target texture used by the post-process
  72094. */
  72095. getPass(): RenderTargetTexture;
  72096. private _meshExcluded;
  72097. private _createPass;
  72098. private _updateMeshScreenCoordinates;
  72099. /**
  72100. * Creates a default mesh for the Volumeric Light Scattering post-process
  72101. * @param name The mesh name
  72102. * @param scene The scene where to create the mesh
  72103. * @return the default mesh
  72104. */
  72105. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72106. }
  72107. }
  72108. declare module BABYLON {
  72109. /** @hidden */
  72110. export var screenSpaceCurvaturePixelShader: {
  72111. name: string;
  72112. shader: string;
  72113. };
  72114. }
  72115. declare module BABYLON {
  72116. /**
  72117. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72118. */
  72119. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72120. /**
  72121. * Defines how much ridge the curvature effect displays.
  72122. */
  72123. ridge: number;
  72124. /**
  72125. * Defines how much valley the curvature effect displays.
  72126. */
  72127. valley: number;
  72128. private _geometryBufferRenderer;
  72129. /**
  72130. * Gets a string identifying the name of the class
  72131. * @returns "ScreenSpaceCurvaturePostProcess" string
  72132. */
  72133. getClassName(): string;
  72134. /**
  72135. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72136. * @param name The name of the effect.
  72137. * @param scene The scene containing the objects to blur according to their velocity.
  72138. * @param options The required width/height ratio to downsize to before computing the render pass.
  72139. * @param camera The camera to apply the render pass to.
  72140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72141. * @param engine The engine which the post process will be applied. (default: current engine)
  72142. * @param reusable If the post process can be reused on the same frame. (default: false)
  72143. * @param textureType Type of textures used when performing the post process. (default: 0)
  72144. * @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)
  72145. */
  72146. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72147. /**
  72148. * Support test.
  72149. */
  72150. static get IsSupported(): boolean;
  72151. /** @hidden */
  72152. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72153. }
  72154. }
  72155. declare module BABYLON {
  72156. interface Scene {
  72157. /** @hidden (Backing field) */
  72158. _boundingBoxRenderer: BoundingBoxRenderer;
  72159. /** @hidden (Backing field) */
  72160. _forceShowBoundingBoxes: boolean;
  72161. /**
  72162. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72163. */
  72164. forceShowBoundingBoxes: boolean;
  72165. /**
  72166. * Gets the bounding box renderer associated with the scene
  72167. * @returns a BoundingBoxRenderer
  72168. */
  72169. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72170. }
  72171. interface AbstractMesh {
  72172. /** @hidden (Backing field) */
  72173. _showBoundingBox: boolean;
  72174. /**
  72175. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72176. */
  72177. showBoundingBox: boolean;
  72178. }
  72179. /**
  72180. * Component responsible of rendering the bounding box of the meshes in a scene.
  72181. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72182. */
  72183. export class BoundingBoxRenderer implements ISceneComponent {
  72184. /**
  72185. * The component name helpfull to identify the component in the list of scene components.
  72186. */
  72187. readonly name: string;
  72188. /**
  72189. * The scene the component belongs to.
  72190. */
  72191. scene: Scene;
  72192. /**
  72193. * Color of the bounding box lines placed in front of an object
  72194. */
  72195. frontColor: Color3;
  72196. /**
  72197. * Color of the bounding box lines placed behind an object
  72198. */
  72199. backColor: Color3;
  72200. /**
  72201. * Defines if the renderer should show the back lines or not
  72202. */
  72203. showBackLines: boolean;
  72204. /**
  72205. * Observable raised before rendering a bounding box
  72206. */
  72207. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72208. /**
  72209. * Observable raised after rendering a bounding box
  72210. */
  72211. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72212. /**
  72213. * @hidden
  72214. */
  72215. renderList: SmartArray<BoundingBox>;
  72216. private _colorShader;
  72217. private _vertexBuffers;
  72218. private _indexBuffer;
  72219. private _fillIndexBuffer;
  72220. private _fillIndexData;
  72221. /**
  72222. * Instantiates a new bounding box renderer in a scene.
  72223. * @param scene the scene the renderer renders in
  72224. */
  72225. constructor(scene: Scene);
  72226. /**
  72227. * Registers the component in a given scene
  72228. */
  72229. register(): void;
  72230. private _evaluateSubMesh;
  72231. private _activeMesh;
  72232. private _prepareRessources;
  72233. private _createIndexBuffer;
  72234. /**
  72235. * Rebuilds the elements related to this component in case of
  72236. * context lost for instance.
  72237. */
  72238. rebuild(): void;
  72239. /**
  72240. * @hidden
  72241. */
  72242. reset(): void;
  72243. /**
  72244. * Render the bounding boxes of a specific rendering group
  72245. * @param renderingGroupId defines the rendering group to render
  72246. */
  72247. render(renderingGroupId: number): void;
  72248. /**
  72249. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72250. * @param mesh Define the mesh to render the occlusion bounding box for
  72251. */
  72252. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72253. /**
  72254. * Dispose and release the resources attached to this renderer.
  72255. */
  72256. dispose(): void;
  72257. }
  72258. }
  72259. declare module BABYLON {
  72260. interface Scene {
  72261. /** @hidden (Backing field) */
  72262. _depthRenderer: {
  72263. [id: string]: DepthRenderer;
  72264. };
  72265. /**
  72266. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72267. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72268. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72269. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72270. * @returns the created depth renderer
  72271. */
  72272. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72273. /**
  72274. * Disables a depth renderer for a given camera
  72275. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72276. */
  72277. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72278. }
  72279. /**
  72280. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72281. * in several rendering techniques.
  72282. */
  72283. export class DepthRendererSceneComponent implements ISceneComponent {
  72284. /**
  72285. * The component name helpfull to identify the component in the list of scene components.
  72286. */
  72287. readonly name: string;
  72288. /**
  72289. * The scene the component belongs to.
  72290. */
  72291. scene: Scene;
  72292. /**
  72293. * Creates a new instance of the component for the given scene
  72294. * @param scene Defines the scene to register the component in
  72295. */
  72296. constructor(scene: Scene);
  72297. /**
  72298. * Registers the component in a given scene
  72299. */
  72300. register(): void;
  72301. /**
  72302. * Rebuilds the elements related to this component in case of
  72303. * context lost for instance.
  72304. */
  72305. rebuild(): void;
  72306. /**
  72307. * Disposes the component and the associated ressources
  72308. */
  72309. dispose(): void;
  72310. private _gatherRenderTargets;
  72311. private _gatherActiveCameraRenderTargets;
  72312. }
  72313. }
  72314. declare module BABYLON {
  72315. interface AbstractScene {
  72316. /** @hidden (Backing field) */
  72317. _prePassRenderer: Nullable<PrePassRenderer>;
  72318. /**
  72319. * Gets or Sets the current prepass renderer associated to the scene.
  72320. */
  72321. prePassRenderer: Nullable<PrePassRenderer>;
  72322. /**
  72323. * Enables the prepass and associates it with the scene
  72324. * @returns the PrePassRenderer
  72325. */
  72326. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72327. /**
  72328. * Disables the prepass associated with the scene
  72329. */
  72330. disablePrePassRenderer(): void;
  72331. }
  72332. /**
  72333. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72334. * in several rendering techniques.
  72335. */
  72336. export class PrePassRendererSceneComponent implements ISceneComponent {
  72337. /**
  72338. * The component name helpful to identify the component in the list of scene components.
  72339. */
  72340. readonly name: string;
  72341. /**
  72342. * The scene the component belongs to.
  72343. */
  72344. scene: Scene;
  72345. /**
  72346. * Creates a new instance of the component for the given scene
  72347. * @param scene Defines the scene to register the component in
  72348. */
  72349. constructor(scene: Scene);
  72350. /**
  72351. * Registers the component in a given scene
  72352. */
  72353. register(): void;
  72354. private _beforeCameraDraw;
  72355. private _afterCameraDraw;
  72356. private _beforeClearStage;
  72357. /**
  72358. * Rebuilds the elements related to this component in case of
  72359. * context lost for instance.
  72360. */
  72361. rebuild(): void;
  72362. /**
  72363. * Disposes the component and the associated ressources
  72364. */
  72365. dispose(): void;
  72366. }
  72367. }
  72368. declare module BABYLON {
  72369. /** @hidden */
  72370. export var fibonacci: {
  72371. name: string;
  72372. shader: string;
  72373. };
  72374. }
  72375. declare module BABYLON {
  72376. /** @hidden */
  72377. export var diffusionProfile: {
  72378. name: string;
  72379. shader: string;
  72380. };
  72381. }
  72382. declare module BABYLON {
  72383. /** @hidden */
  72384. export var subSurfaceScatteringPixelShader: {
  72385. name: string;
  72386. shader: string;
  72387. };
  72388. }
  72389. declare module BABYLON {
  72390. /**
  72391. * Sub surface scattering post process
  72392. */
  72393. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72394. /**
  72395. * Gets a string identifying the name of the class
  72396. * @returns "SubSurfaceScatteringPostProcess" string
  72397. */
  72398. getClassName(): string;
  72399. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72400. }
  72401. }
  72402. declare module BABYLON {
  72403. /**
  72404. * Contains all parameters needed for the prepass to perform
  72405. * screen space subsurface scattering
  72406. */
  72407. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72408. /** @hidden */
  72409. static _SceneComponentInitialization: (scene: Scene) => void;
  72410. private _ssDiffusionS;
  72411. private _ssFilterRadii;
  72412. private _ssDiffusionD;
  72413. /**
  72414. * Post process to attach for screen space subsurface scattering
  72415. */
  72416. postProcess: SubSurfaceScatteringPostProcess;
  72417. /**
  72418. * Diffusion profile color for subsurface scattering
  72419. */
  72420. get ssDiffusionS(): number[];
  72421. /**
  72422. * Diffusion profile max color channel value for subsurface scattering
  72423. */
  72424. get ssDiffusionD(): number[];
  72425. /**
  72426. * Diffusion profile filter radius for subsurface scattering
  72427. */
  72428. get ssFilterRadii(): number[];
  72429. /**
  72430. * Is subsurface enabled
  72431. */
  72432. enabled: boolean;
  72433. /**
  72434. * Name of the configuration
  72435. */
  72436. name: string;
  72437. /**
  72438. * Diffusion profile colors for subsurface scattering
  72439. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72440. * See ...
  72441. * Note that you can only store up to 5 of them
  72442. */
  72443. ssDiffusionProfileColors: Color3[];
  72444. /**
  72445. * Defines the ratio real world => scene units.
  72446. * Used for subsurface scattering
  72447. */
  72448. metersPerUnit: number;
  72449. /**
  72450. * Textures that should be present in the MRT for this effect to work
  72451. */
  72452. readonly texturesRequired: number[];
  72453. private _scene;
  72454. /**
  72455. * Builds a subsurface configuration object
  72456. * @param scene The scene
  72457. */
  72458. constructor(scene: Scene);
  72459. /**
  72460. * Adds a new diffusion profile.
  72461. * Useful for more realistic subsurface scattering on diverse materials.
  72462. * @param color The color of the diffusion profile. Should be the average color of the material.
  72463. * @return The index of the diffusion profile for the material subsurface configuration
  72464. */
  72465. addDiffusionProfile(color: Color3): number;
  72466. /**
  72467. * Creates the sss post process
  72468. * @return The created post process
  72469. */
  72470. createPostProcess(): SubSurfaceScatteringPostProcess;
  72471. /**
  72472. * Deletes all diffusion profiles.
  72473. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72474. */
  72475. clearAllDiffusionProfiles(): void;
  72476. /**
  72477. * Disposes this object
  72478. */
  72479. dispose(): void;
  72480. /**
  72481. * @hidden
  72482. * https://zero-radiance.github.io/post/sampling-diffusion/
  72483. *
  72484. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72485. * ------------------------------------------------------------------------------------
  72486. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72487. * PDF[r, phi, s] = r * R[r, phi, s]
  72488. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72489. * ------------------------------------------------------------------------------------
  72490. * We importance sample the color channel with the widest scattering distance.
  72491. */
  72492. getDiffusionProfileParameters(color: Color3): number;
  72493. /**
  72494. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72495. * 'u' is the random number (the value of the CDF): [0, 1).
  72496. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72497. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72498. */
  72499. private _sampleBurleyDiffusionProfile;
  72500. }
  72501. }
  72502. declare module BABYLON {
  72503. interface AbstractScene {
  72504. /** @hidden (Backing field) */
  72505. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72506. /**
  72507. * Gets or Sets the current prepass renderer associated to the scene.
  72508. */
  72509. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72510. /**
  72511. * Enables the subsurface effect for prepass
  72512. * @returns the SubSurfaceConfiguration
  72513. */
  72514. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72515. /**
  72516. * Disables the subsurface effect for prepass
  72517. */
  72518. disableSubSurfaceForPrePass(): void;
  72519. }
  72520. /**
  72521. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72522. * in several rendering techniques.
  72523. */
  72524. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72525. /**
  72526. * The component name helpful to identify the component in the list of scene components.
  72527. */
  72528. readonly name: string;
  72529. /**
  72530. * The scene the component belongs to.
  72531. */
  72532. scene: Scene;
  72533. /**
  72534. * Creates a new instance of the component for the given scene
  72535. * @param scene Defines the scene to register the component in
  72536. */
  72537. constructor(scene: Scene);
  72538. /**
  72539. * Registers the component in a given scene
  72540. */
  72541. register(): void;
  72542. /**
  72543. * Serializes the component data to the specified json object
  72544. * @param serializationObject The object to serialize to
  72545. */
  72546. serialize(serializationObject: any): void;
  72547. /**
  72548. * Adds all the elements from the container to the scene
  72549. * @param container the container holding the elements
  72550. */
  72551. addFromContainer(container: AbstractScene): void;
  72552. /**
  72553. * Removes all the elements in the container from the scene
  72554. * @param container contains the elements to remove
  72555. * @param dispose if the removed element should be disposed (default: false)
  72556. */
  72557. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72558. /**
  72559. * Rebuilds the elements related to this component in case of
  72560. * context lost for instance.
  72561. */
  72562. rebuild(): void;
  72563. /**
  72564. * Disposes the component and the associated ressources
  72565. */
  72566. dispose(): void;
  72567. }
  72568. }
  72569. declare module BABYLON {
  72570. /** @hidden */
  72571. export var outlinePixelShader: {
  72572. name: string;
  72573. shader: string;
  72574. };
  72575. }
  72576. declare module BABYLON {
  72577. /** @hidden */
  72578. export var outlineVertexShader: {
  72579. name: string;
  72580. shader: string;
  72581. };
  72582. }
  72583. declare module BABYLON {
  72584. interface Scene {
  72585. /** @hidden */
  72586. _outlineRenderer: OutlineRenderer;
  72587. /**
  72588. * Gets the outline renderer associated with the scene
  72589. * @returns a OutlineRenderer
  72590. */
  72591. getOutlineRenderer(): OutlineRenderer;
  72592. }
  72593. interface AbstractMesh {
  72594. /** @hidden (Backing field) */
  72595. _renderOutline: boolean;
  72596. /**
  72597. * Gets or sets a boolean indicating if the outline must be rendered as well
  72598. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72599. */
  72600. renderOutline: boolean;
  72601. /** @hidden (Backing field) */
  72602. _renderOverlay: boolean;
  72603. /**
  72604. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72605. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72606. */
  72607. renderOverlay: boolean;
  72608. }
  72609. /**
  72610. * This class is responsible to draw bothe outline/overlay of meshes.
  72611. * It should not be used directly but through the available method on mesh.
  72612. */
  72613. export class OutlineRenderer implements ISceneComponent {
  72614. /**
  72615. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72616. */
  72617. private static _StencilReference;
  72618. /**
  72619. * The name of the component. Each component must have a unique name.
  72620. */
  72621. name: string;
  72622. /**
  72623. * The scene the component belongs to.
  72624. */
  72625. scene: Scene;
  72626. /**
  72627. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72628. */
  72629. zOffset: number;
  72630. private _engine;
  72631. private _effect;
  72632. private _cachedDefines;
  72633. private _savedDepthWrite;
  72634. /**
  72635. * Instantiates a new outline renderer. (There could be only one per scene).
  72636. * @param scene Defines the scene it belongs to
  72637. */
  72638. constructor(scene: Scene);
  72639. /**
  72640. * Register the component to one instance of a scene.
  72641. */
  72642. register(): void;
  72643. /**
  72644. * Rebuilds the elements related to this component in case of
  72645. * context lost for instance.
  72646. */
  72647. rebuild(): void;
  72648. /**
  72649. * Disposes the component and the associated ressources.
  72650. */
  72651. dispose(): void;
  72652. /**
  72653. * Renders the outline in the canvas.
  72654. * @param subMesh Defines the sumesh to render
  72655. * @param batch Defines the batch of meshes in case of instances
  72656. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72657. */
  72658. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72659. /**
  72660. * Returns whether or not the outline renderer is ready for a given submesh.
  72661. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72662. * @param subMesh Defines the submesh to check readyness for
  72663. * @param useInstances Defines wheter wee are trying to render instances or not
  72664. * @returns true if ready otherwise false
  72665. */
  72666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72667. private _beforeRenderingMesh;
  72668. private _afterRenderingMesh;
  72669. }
  72670. }
  72671. declare module BABYLON {
  72672. /**
  72673. * Defines the basic options interface of a Sprite Frame Source Size.
  72674. */
  72675. export interface ISpriteJSONSpriteSourceSize {
  72676. /**
  72677. * number of the original width of the Frame
  72678. */
  72679. w: number;
  72680. /**
  72681. * number of the original height of the Frame
  72682. */
  72683. h: number;
  72684. }
  72685. /**
  72686. * Defines the basic options interface of a Sprite Frame Data.
  72687. */
  72688. export interface ISpriteJSONSpriteFrameData {
  72689. /**
  72690. * number of the x offset of the Frame
  72691. */
  72692. x: number;
  72693. /**
  72694. * number of the y offset of the Frame
  72695. */
  72696. y: number;
  72697. /**
  72698. * number of the width of the Frame
  72699. */
  72700. w: number;
  72701. /**
  72702. * number of the height of the Frame
  72703. */
  72704. h: number;
  72705. }
  72706. /**
  72707. * Defines the basic options interface of a JSON Sprite.
  72708. */
  72709. export interface ISpriteJSONSprite {
  72710. /**
  72711. * string name of the Frame
  72712. */
  72713. filename: string;
  72714. /**
  72715. * ISpriteJSONSpriteFrame basic object of the frame data
  72716. */
  72717. frame: ISpriteJSONSpriteFrameData;
  72718. /**
  72719. * boolean to flag is the frame was rotated.
  72720. */
  72721. rotated: boolean;
  72722. /**
  72723. * boolean to flag is the frame was trimmed.
  72724. */
  72725. trimmed: boolean;
  72726. /**
  72727. * ISpriteJSONSpriteFrame basic object of the source data
  72728. */
  72729. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72730. /**
  72731. * ISpriteJSONSpriteFrame basic object of the source data
  72732. */
  72733. sourceSize: ISpriteJSONSpriteSourceSize;
  72734. }
  72735. /**
  72736. * Defines the basic options interface of a JSON atlas.
  72737. */
  72738. export interface ISpriteJSONAtlas {
  72739. /**
  72740. * Array of objects that contain the frame data.
  72741. */
  72742. frames: Array<ISpriteJSONSprite>;
  72743. /**
  72744. * object basic object containing the sprite meta data.
  72745. */
  72746. meta?: object;
  72747. }
  72748. }
  72749. declare module BABYLON {
  72750. /** @hidden */
  72751. export var spriteMapPixelShader: {
  72752. name: string;
  72753. shader: string;
  72754. };
  72755. }
  72756. declare module BABYLON {
  72757. /** @hidden */
  72758. export var spriteMapVertexShader: {
  72759. name: string;
  72760. shader: string;
  72761. };
  72762. }
  72763. declare module BABYLON {
  72764. /**
  72765. * Defines the basic options interface of a SpriteMap
  72766. */
  72767. export interface ISpriteMapOptions {
  72768. /**
  72769. * Vector2 of the number of cells in the grid.
  72770. */
  72771. stageSize?: Vector2;
  72772. /**
  72773. * Vector2 of the size of the output plane in World Units.
  72774. */
  72775. outputSize?: Vector2;
  72776. /**
  72777. * Vector3 of the position of the output plane in World Units.
  72778. */
  72779. outputPosition?: Vector3;
  72780. /**
  72781. * Vector3 of the rotation of the output plane.
  72782. */
  72783. outputRotation?: Vector3;
  72784. /**
  72785. * number of layers that the system will reserve in resources.
  72786. */
  72787. layerCount?: number;
  72788. /**
  72789. * number of max animation frames a single cell will reserve in resources.
  72790. */
  72791. maxAnimationFrames?: number;
  72792. /**
  72793. * number cell index of the base tile when the system compiles.
  72794. */
  72795. baseTile?: number;
  72796. /**
  72797. * boolean flip the sprite after its been repositioned by the framing data.
  72798. */
  72799. flipU?: boolean;
  72800. /**
  72801. * Vector3 scalar of the global RGB values of the SpriteMap.
  72802. */
  72803. colorMultiply?: Vector3;
  72804. }
  72805. /**
  72806. * Defines the IDisposable interface in order to be cleanable from resources.
  72807. */
  72808. export interface ISpriteMap extends IDisposable {
  72809. /**
  72810. * String name of the SpriteMap.
  72811. */
  72812. name: string;
  72813. /**
  72814. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72815. */
  72816. atlasJSON: ISpriteJSONAtlas;
  72817. /**
  72818. * Texture of the SpriteMap.
  72819. */
  72820. spriteSheet: Texture;
  72821. /**
  72822. * The parameters to initialize the SpriteMap with.
  72823. */
  72824. options: ISpriteMapOptions;
  72825. }
  72826. /**
  72827. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72828. */
  72829. export class SpriteMap implements ISpriteMap {
  72830. /** The Name of the spriteMap */
  72831. name: string;
  72832. /** The JSON file with the frame and meta data */
  72833. atlasJSON: ISpriteJSONAtlas;
  72834. /** The systems Sprite Sheet Texture */
  72835. spriteSheet: Texture;
  72836. /** Arguments passed with the Constructor */
  72837. options: ISpriteMapOptions;
  72838. /** Public Sprite Storage array, parsed from atlasJSON */
  72839. sprites: Array<ISpriteJSONSprite>;
  72840. /** Returns the Number of Sprites in the System */
  72841. get spriteCount(): number;
  72842. /** Returns the Position of Output Plane*/
  72843. get position(): Vector3;
  72844. /** Returns the Position of Output Plane*/
  72845. set position(v: Vector3);
  72846. /** Returns the Rotation of Output Plane*/
  72847. get rotation(): Vector3;
  72848. /** Returns the Rotation of Output Plane*/
  72849. set rotation(v: Vector3);
  72850. /** Sets the AnimationMap*/
  72851. get animationMap(): RawTexture;
  72852. /** Sets the AnimationMap*/
  72853. set animationMap(v: RawTexture);
  72854. /** Scene that the SpriteMap was created in */
  72855. private _scene;
  72856. /** Texture Buffer of Float32 that holds tile frame data*/
  72857. private _frameMap;
  72858. /** Texture Buffers of Float32 that holds tileMap data*/
  72859. private _tileMaps;
  72860. /** Texture Buffer of Float32 that holds Animation Data*/
  72861. private _animationMap;
  72862. /** Custom ShaderMaterial Central to the System*/
  72863. private _material;
  72864. /** Custom ShaderMaterial Central to the System*/
  72865. private _output;
  72866. /** Systems Time Ticker*/
  72867. private _time;
  72868. /**
  72869. * Creates a new SpriteMap
  72870. * @param name defines the SpriteMaps Name
  72871. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  72872. * @param spriteSheet is the Texture that the Sprites are on.
  72873. * @param options a basic deployment configuration
  72874. * @param scene The Scene that the map is deployed on
  72875. */
  72876. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  72877. /**
  72878. * Returns tileID location
  72879. * @returns Vector2 the cell position ID
  72880. */
  72881. getTileID(): Vector2;
  72882. /**
  72883. * Gets the UV location of the mouse over the SpriteMap.
  72884. * @returns Vector2 the UV position of the mouse interaction
  72885. */
  72886. getMousePosition(): Vector2;
  72887. /**
  72888. * Creates the "frame" texture Buffer
  72889. * -------------------------------------
  72890. * Structure of frames
  72891. * "filename": "Falling-Water-2.png",
  72892. * "frame": {"x":69,"y":103,"w":24,"h":32},
  72893. * "rotated": true,
  72894. * "trimmed": true,
  72895. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  72896. * "sourceSize": {"w":32,"h":32}
  72897. * @returns RawTexture of the frameMap
  72898. */
  72899. private _createFrameBuffer;
  72900. /**
  72901. * Creates the tileMap texture Buffer
  72902. * @param buffer normally and array of numbers, or a false to generate from scratch
  72903. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  72904. * @returns RawTexture of the tileMap
  72905. */
  72906. private _createTileBuffer;
  72907. /**
  72908. * Modifies the data of the tileMaps
  72909. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  72910. * @param pos is the iVector2 Coordinates of the Tile
  72911. * @param tile The SpriteIndex of the new Tile
  72912. */
  72913. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  72914. /**
  72915. * Creates the animationMap texture Buffer
  72916. * @param buffer normally and array of numbers, or a false to generate from scratch
  72917. * @returns RawTexture of the animationMap
  72918. */
  72919. private _createTileAnimationBuffer;
  72920. /**
  72921. * Modifies the data of the animationMap
  72922. * @param cellID is the Index of the Sprite
  72923. * @param _frame is the target Animation frame
  72924. * @param toCell is the Target Index of the next frame of the animation
  72925. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  72926. * @param speed is a global scalar of the time variable on the map.
  72927. */
  72928. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  72929. /**
  72930. * Exports the .tilemaps file
  72931. */
  72932. saveTileMaps(): void;
  72933. /**
  72934. * Imports the .tilemaps file
  72935. * @param url of the .tilemaps file
  72936. */
  72937. loadTileMaps(url: string): void;
  72938. /**
  72939. * Release associated resources
  72940. */
  72941. dispose(): void;
  72942. }
  72943. }
  72944. declare module BABYLON {
  72945. /**
  72946. * Class used to manage multiple sprites of different sizes on the same spritesheet
  72947. * @see https://doc.babylonjs.com/babylon101/sprites
  72948. */
  72949. export class SpritePackedManager extends SpriteManager {
  72950. /** defines the packed manager's name */
  72951. name: string;
  72952. /**
  72953. * Creates a new sprite manager from a packed sprite sheet
  72954. * @param name defines the manager's name
  72955. * @param imgUrl defines the sprite sheet url
  72956. * @param capacity defines the maximum allowed number of sprites
  72957. * @param scene defines the hosting scene
  72958. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  72959. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  72960. * @param samplingMode defines the smapling mode to use with spritesheet
  72961. * @param fromPacked set to true; do not alter
  72962. */
  72963. constructor(
  72964. /** defines the packed manager's name */
  72965. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  72966. }
  72967. }
  72968. declare module BABYLON {
  72969. /**
  72970. * Defines the list of states available for a task inside a AssetsManager
  72971. */
  72972. export enum AssetTaskState {
  72973. /**
  72974. * Initialization
  72975. */
  72976. INIT = 0,
  72977. /**
  72978. * Running
  72979. */
  72980. RUNNING = 1,
  72981. /**
  72982. * Done
  72983. */
  72984. DONE = 2,
  72985. /**
  72986. * Error
  72987. */
  72988. ERROR = 3
  72989. }
  72990. /**
  72991. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  72992. */
  72993. export abstract class AbstractAssetTask {
  72994. /**
  72995. * Task name
  72996. */ name: string;
  72997. /**
  72998. * Callback called when the task is successful
  72999. */
  73000. onSuccess: (task: any) => void;
  73001. /**
  73002. * Callback called when the task is not successful
  73003. */
  73004. onError: (task: any, message?: string, exception?: any) => void;
  73005. /**
  73006. * Creates a new AssetsManager
  73007. * @param name defines the name of the task
  73008. */
  73009. constructor(
  73010. /**
  73011. * Task name
  73012. */ name: string);
  73013. private _isCompleted;
  73014. private _taskState;
  73015. private _errorObject;
  73016. /**
  73017. * Get if the task is completed
  73018. */
  73019. get isCompleted(): boolean;
  73020. /**
  73021. * Gets the current state of the task
  73022. */
  73023. get taskState(): AssetTaskState;
  73024. /**
  73025. * Gets the current error object (if task is in error)
  73026. */
  73027. get errorObject(): {
  73028. message?: string;
  73029. exception?: any;
  73030. };
  73031. /**
  73032. * Internal only
  73033. * @hidden
  73034. */
  73035. _setErrorObject(message?: string, exception?: any): void;
  73036. /**
  73037. * Execute the current task
  73038. * @param scene defines the scene where you want your assets to be loaded
  73039. * @param onSuccess is a callback called when the task is successfully executed
  73040. * @param onError is a callback called if an error occurs
  73041. */
  73042. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73043. /**
  73044. * Execute the current task
  73045. * @param scene defines the scene where you want your assets to be loaded
  73046. * @param onSuccess is a callback called when the task is successfully executed
  73047. * @param onError is a callback called if an error occurs
  73048. */
  73049. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73050. /**
  73051. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73052. * This can be used with failed tasks that have the reason for failure fixed.
  73053. */
  73054. reset(): void;
  73055. private onErrorCallback;
  73056. private onDoneCallback;
  73057. }
  73058. /**
  73059. * Define the interface used by progress events raised during assets loading
  73060. */
  73061. export interface IAssetsProgressEvent {
  73062. /**
  73063. * Defines the number of remaining tasks to process
  73064. */
  73065. remainingCount: number;
  73066. /**
  73067. * Defines the total number of tasks
  73068. */
  73069. totalCount: number;
  73070. /**
  73071. * Defines the task that was just processed
  73072. */
  73073. task: AbstractAssetTask;
  73074. }
  73075. /**
  73076. * Class used to share progress information about assets loading
  73077. */
  73078. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73079. /**
  73080. * Defines the number of remaining tasks to process
  73081. */
  73082. remainingCount: number;
  73083. /**
  73084. * Defines the total number of tasks
  73085. */
  73086. totalCount: number;
  73087. /**
  73088. * Defines the task that was just processed
  73089. */
  73090. task: AbstractAssetTask;
  73091. /**
  73092. * Creates a AssetsProgressEvent
  73093. * @param remainingCount defines the number of remaining tasks to process
  73094. * @param totalCount defines the total number of tasks
  73095. * @param task defines the task that was just processed
  73096. */
  73097. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73098. }
  73099. /**
  73100. * Define a task used by AssetsManager to load assets into a container
  73101. */
  73102. export class ContainerAssetTask extends AbstractAssetTask {
  73103. /**
  73104. * Defines the name of the task
  73105. */
  73106. name: string;
  73107. /**
  73108. * Defines the list of mesh's names you want to load
  73109. */
  73110. meshesNames: any;
  73111. /**
  73112. * Defines the root url to use as a base to load your meshes and associated resources
  73113. */
  73114. rootUrl: string;
  73115. /**
  73116. * Defines the filename or File of the scene to load from
  73117. */
  73118. sceneFilename: string | File;
  73119. /**
  73120. * Get the loaded asset container
  73121. */
  73122. loadedContainer: AssetContainer;
  73123. /**
  73124. * Gets the list of loaded meshes
  73125. */
  73126. loadedMeshes: Array<AbstractMesh>;
  73127. /**
  73128. * Gets the list of loaded particle systems
  73129. */
  73130. loadedParticleSystems: Array<IParticleSystem>;
  73131. /**
  73132. * Gets the list of loaded skeletons
  73133. */
  73134. loadedSkeletons: Array<Skeleton>;
  73135. /**
  73136. * Gets the list of loaded animation groups
  73137. */
  73138. loadedAnimationGroups: Array<AnimationGroup>;
  73139. /**
  73140. * Callback called when the task is successful
  73141. */
  73142. onSuccess: (task: ContainerAssetTask) => void;
  73143. /**
  73144. * Callback called when the task is successful
  73145. */
  73146. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73147. /**
  73148. * Creates a new ContainerAssetTask
  73149. * @param name defines the name of the task
  73150. * @param meshesNames defines the list of mesh's names you want to load
  73151. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73152. * @param sceneFilename defines the filename or File of the scene to load from
  73153. */
  73154. constructor(
  73155. /**
  73156. * Defines the name of the task
  73157. */
  73158. name: string,
  73159. /**
  73160. * Defines the list of mesh's names you want to load
  73161. */
  73162. meshesNames: any,
  73163. /**
  73164. * Defines the root url to use as a base to load your meshes and associated resources
  73165. */
  73166. rootUrl: string,
  73167. /**
  73168. * Defines the filename or File of the scene to load from
  73169. */
  73170. sceneFilename: string | File);
  73171. /**
  73172. * Execute the current task
  73173. * @param scene defines the scene where you want your assets to be loaded
  73174. * @param onSuccess is a callback called when the task is successfully executed
  73175. * @param onError is a callback called if an error occurs
  73176. */
  73177. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73178. }
  73179. /**
  73180. * Define a task used by AssetsManager to load meshes
  73181. */
  73182. export class MeshAssetTask extends AbstractAssetTask {
  73183. /**
  73184. * Defines the name of the task
  73185. */
  73186. name: string;
  73187. /**
  73188. * Defines the list of mesh's names you want to load
  73189. */
  73190. meshesNames: any;
  73191. /**
  73192. * Defines the root url to use as a base to load your meshes and associated resources
  73193. */
  73194. rootUrl: string;
  73195. /**
  73196. * Defines the filename or File of the scene to load from
  73197. */
  73198. sceneFilename: string | File;
  73199. /**
  73200. * Gets the list of loaded meshes
  73201. */
  73202. loadedMeshes: Array<AbstractMesh>;
  73203. /**
  73204. * Gets the list of loaded particle systems
  73205. */
  73206. loadedParticleSystems: Array<IParticleSystem>;
  73207. /**
  73208. * Gets the list of loaded skeletons
  73209. */
  73210. loadedSkeletons: Array<Skeleton>;
  73211. /**
  73212. * Gets the list of loaded animation groups
  73213. */
  73214. loadedAnimationGroups: Array<AnimationGroup>;
  73215. /**
  73216. * Callback called when the task is successful
  73217. */
  73218. onSuccess: (task: MeshAssetTask) => void;
  73219. /**
  73220. * Callback called when the task is successful
  73221. */
  73222. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73223. /**
  73224. * Creates a new MeshAssetTask
  73225. * @param name defines the name of the task
  73226. * @param meshesNames defines the list of mesh's names you want to load
  73227. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73228. * @param sceneFilename defines the filename or File of the scene to load from
  73229. */
  73230. constructor(
  73231. /**
  73232. * Defines the name of the task
  73233. */
  73234. name: string,
  73235. /**
  73236. * Defines the list of mesh's names you want to load
  73237. */
  73238. meshesNames: any,
  73239. /**
  73240. * Defines the root url to use as a base to load your meshes and associated resources
  73241. */
  73242. rootUrl: string,
  73243. /**
  73244. * Defines the filename or File of the scene to load from
  73245. */
  73246. sceneFilename: string | File);
  73247. /**
  73248. * Execute the current task
  73249. * @param scene defines the scene where you want your assets to be loaded
  73250. * @param onSuccess is a callback called when the task is successfully executed
  73251. * @param onError is a callback called if an error occurs
  73252. */
  73253. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73254. }
  73255. /**
  73256. * Define a task used by AssetsManager to load text content
  73257. */
  73258. export class TextFileAssetTask extends AbstractAssetTask {
  73259. /**
  73260. * Defines the name of the task
  73261. */
  73262. name: string;
  73263. /**
  73264. * Defines the location of the file to load
  73265. */
  73266. url: string;
  73267. /**
  73268. * Gets the loaded text string
  73269. */
  73270. text: string;
  73271. /**
  73272. * Callback called when the task is successful
  73273. */
  73274. onSuccess: (task: TextFileAssetTask) => void;
  73275. /**
  73276. * Callback called when the task is successful
  73277. */
  73278. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73279. /**
  73280. * Creates a new TextFileAssetTask object
  73281. * @param name defines the name of the task
  73282. * @param url defines the location of the file to load
  73283. */
  73284. constructor(
  73285. /**
  73286. * Defines the name of the task
  73287. */
  73288. name: string,
  73289. /**
  73290. * Defines the location of the file to load
  73291. */
  73292. url: string);
  73293. /**
  73294. * Execute the current task
  73295. * @param scene defines the scene where you want your assets to be loaded
  73296. * @param onSuccess is a callback called when the task is successfully executed
  73297. * @param onError is a callback called if an error occurs
  73298. */
  73299. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73300. }
  73301. /**
  73302. * Define a task used by AssetsManager to load binary data
  73303. */
  73304. export class BinaryFileAssetTask extends AbstractAssetTask {
  73305. /**
  73306. * Defines the name of the task
  73307. */
  73308. name: string;
  73309. /**
  73310. * Defines the location of the file to load
  73311. */
  73312. url: string;
  73313. /**
  73314. * Gets the lodaded data (as an array buffer)
  73315. */
  73316. data: ArrayBuffer;
  73317. /**
  73318. * Callback called when the task is successful
  73319. */
  73320. onSuccess: (task: BinaryFileAssetTask) => void;
  73321. /**
  73322. * Callback called when the task is successful
  73323. */
  73324. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73325. /**
  73326. * Creates a new BinaryFileAssetTask object
  73327. * @param name defines the name of the new task
  73328. * @param url defines the location of the file to load
  73329. */
  73330. constructor(
  73331. /**
  73332. * Defines the name of the task
  73333. */
  73334. name: string,
  73335. /**
  73336. * Defines the location of the file to load
  73337. */
  73338. url: string);
  73339. /**
  73340. * Execute the current task
  73341. * @param scene defines the scene where you want your assets to be loaded
  73342. * @param onSuccess is a callback called when the task is successfully executed
  73343. * @param onError is a callback called if an error occurs
  73344. */
  73345. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73346. }
  73347. /**
  73348. * Define a task used by AssetsManager to load images
  73349. */
  73350. export class ImageAssetTask extends AbstractAssetTask {
  73351. /**
  73352. * Defines the name of the task
  73353. */
  73354. name: string;
  73355. /**
  73356. * Defines the location of the image to load
  73357. */
  73358. url: string;
  73359. /**
  73360. * Gets the loaded images
  73361. */
  73362. image: HTMLImageElement;
  73363. /**
  73364. * Callback called when the task is successful
  73365. */
  73366. onSuccess: (task: ImageAssetTask) => void;
  73367. /**
  73368. * Callback called when the task is successful
  73369. */
  73370. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73371. /**
  73372. * Creates a new ImageAssetTask
  73373. * @param name defines the name of the task
  73374. * @param url defines the location of the image to load
  73375. */
  73376. constructor(
  73377. /**
  73378. * Defines the name of the task
  73379. */
  73380. name: string,
  73381. /**
  73382. * Defines the location of the image to load
  73383. */
  73384. url: string);
  73385. /**
  73386. * Execute the current task
  73387. * @param scene defines the scene where you want your assets to be loaded
  73388. * @param onSuccess is a callback called when the task is successfully executed
  73389. * @param onError is a callback called if an error occurs
  73390. */
  73391. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73392. }
  73393. /**
  73394. * Defines the interface used by texture loading tasks
  73395. */
  73396. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73397. /**
  73398. * Gets the loaded texture
  73399. */
  73400. texture: TEX;
  73401. }
  73402. /**
  73403. * Define a task used by AssetsManager to load 2D textures
  73404. */
  73405. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73406. /**
  73407. * Defines the name of the task
  73408. */
  73409. name: string;
  73410. /**
  73411. * Defines the location of the file to load
  73412. */
  73413. url: string;
  73414. /**
  73415. * Defines if mipmap should not be generated (default is false)
  73416. */
  73417. noMipmap?: boolean | undefined;
  73418. /**
  73419. * Defines if texture must be inverted on Y axis (default is true)
  73420. */
  73421. invertY: boolean;
  73422. /**
  73423. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73424. */
  73425. samplingMode: number;
  73426. /**
  73427. * Gets the loaded texture
  73428. */
  73429. texture: Texture;
  73430. /**
  73431. * Callback called when the task is successful
  73432. */
  73433. onSuccess: (task: TextureAssetTask) => void;
  73434. /**
  73435. * Callback called when the task is successful
  73436. */
  73437. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73438. /**
  73439. * Creates a new TextureAssetTask object
  73440. * @param name defines the name of the task
  73441. * @param url defines the location of the file to load
  73442. * @param noMipmap defines if mipmap should not be generated (default is false)
  73443. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73444. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73445. */
  73446. constructor(
  73447. /**
  73448. * Defines the name of the task
  73449. */
  73450. name: string,
  73451. /**
  73452. * Defines the location of the file to load
  73453. */
  73454. url: string,
  73455. /**
  73456. * Defines if mipmap should not be generated (default is false)
  73457. */
  73458. noMipmap?: boolean | undefined,
  73459. /**
  73460. * Defines if texture must be inverted on Y axis (default is true)
  73461. */
  73462. invertY?: boolean,
  73463. /**
  73464. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73465. */
  73466. samplingMode?: number);
  73467. /**
  73468. * Execute the current task
  73469. * @param scene defines the scene where you want your assets to be loaded
  73470. * @param onSuccess is a callback called when the task is successfully executed
  73471. * @param onError is a callback called if an error occurs
  73472. */
  73473. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73474. }
  73475. /**
  73476. * Define a task used by AssetsManager to load cube textures
  73477. */
  73478. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73479. /**
  73480. * Defines the name of the task
  73481. */
  73482. name: string;
  73483. /**
  73484. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73485. */
  73486. url: string;
  73487. /**
  73488. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73489. */
  73490. extensions?: string[] | undefined;
  73491. /**
  73492. * Defines if mipmaps should not be generated (default is false)
  73493. */
  73494. noMipmap?: boolean | undefined;
  73495. /**
  73496. * Defines the explicit list of files (undefined by default)
  73497. */
  73498. files?: string[] | undefined;
  73499. /**
  73500. * Gets the loaded texture
  73501. */
  73502. texture: CubeTexture;
  73503. /**
  73504. * Callback called when the task is successful
  73505. */
  73506. onSuccess: (task: CubeTextureAssetTask) => void;
  73507. /**
  73508. * Callback called when the task is successful
  73509. */
  73510. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73511. /**
  73512. * Creates a new CubeTextureAssetTask
  73513. * @param name defines the name of the task
  73514. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73515. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73516. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73517. * @param files defines the explicit list of files (undefined by default)
  73518. */
  73519. constructor(
  73520. /**
  73521. * Defines the name of the task
  73522. */
  73523. name: string,
  73524. /**
  73525. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73526. */
  73527. url: string,
  73528. /**
  73529. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73530. */
  73531. extensions?: string[] | undefined,
  73532. /**
  73533. * Defines if mipmaps should not be generated (default is false)
  73534. */
  73535. noMipmap?: boolean | undefined,
  73536. /**
  73537. * Defines the explicit list of files (undefined by default)
  73538. */
  73539. files?: string[] | undefined);
  73540. /**
  73541. * Execute the current task
  73542. * @param scene defines the scene where you want your assets to be loaded
  73543. * @param onSuccess is a callback called when the task is successfully executed
  73544. * @param onError is a callback called if an error occurs
  73545. */
  73546. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73547. }
  73548. /**
  73549. * Define a task used by AssetsManager to load HDR cube textures
  73550. */
  73551. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73552. /**
  73553. * Defines the name of the task
  73554. */
  73555. name: string;
  73556. /**
  73557. * Defines the location of the file to load
  73558. */
  73559. url: string;
  73560. /**
  73561. * Defines the desired size (the more it increases the longer the generation will be)
  73562. */
  73563. size: number;
  73564. /**
  73565. * Defines if mipmaps should not be generated (default is false)
  73566. */
  73567. noMipmap: boolean;
  73568. /**
  73569. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73570. */
  73571. generateHarmonics: boolean;
  73572. /**
  73573. * 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)
  73574. */
  73575. gammaSpace: boolean;
  73576. /**
  73577. * Internal Use Only
  73578. */
  73579. reserved: boolean;
  73580. /**
  73581. * Gets the loaded texture
  73582. */
  73583. texture: HDRCubeTexture;
  73584. /**
  73585. * Callback called when the task is successful
  73586. */
  73587. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73588. /**
  73589. * Callback called when the task is successful
  73590. */
  73591. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73592. /**
  73593. * Creates a new HDRCubeTextureAssetTask object
  73594. * @param name defines the name of the task
  73595. * @param url defines the location of the file to load
  73596. * @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.
  73597. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73598. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73599. * @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)
  73600. * @param reserved Internal use only
  73601. */
  73602. constructor(
  73603. /**
  73604. * Defines the name of the task
  73605. */
  73606. name: string,
  73607. /**
  73608. * Defines the location of the file to load
  73609. */
  73610. url: string,
  73611. /**
  73612. * Defines the desired size (the more it increases the longer the generation will be)
  73613. */
  73614. size: number,
  73615. /**
  73616. * Defines if mipmaps should not be generated (default is false)
  73617. */
  73618. noMipmap?: boolean,
  73619. /**
  73620. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73621. */
  73622. generateHarmonics?: boolean,
  73623. /**
  73624. * 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)
  73625. */
  73626. gammaSpace?: boolean,
  73627. /**
  73628. * Internal Use Only
  73629. */
  73630. reserved?: boolean);
  73631. /**
  73632. * Execute the current task
  73633. * @param scene defines the scene where you want your assets to be loaded
  73634. * @param onSuccess is a callback called when the task is successfully executed
  73635. * @param onError is a callback called if an error occurs
  73636. */
  73637. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73638. }
  73639. /**
  73640. * Define a task used by AssetsManager to load Equirectangular cube textures
  73641. */
  73642. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73643. /**
  73644. * Defines the name of the task
  73645. */
  73646. name: string;
  73647. /**
  73648. * Defines the location of the file to load
  73649. */
  73650. url: string;
  73651. /**
  73652. * Defines the desired size (the more it increases the longer the generation will be)
  73653. */
  73654. size: number;
  73655. /**
  73656. * Defines if mipmaps should not be generated (default is false)
  73657. */
  73658. noMipmap: boolean;
  73659. /**
  73660. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73661. * but the standard material would require them in Gamma space) (default is true)
  73662. */
  73663. gammaSpace: boolean;
  73664. /**
  73665. * Gets the loaded texture
  73666. */
  73667. texture: EquiRectangularCubeTexture;
  73668. /**
  73669. * Callback called when the task is successful
  73670. */
  73671. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73672. /**
  73673. * Callback called when the task is successful
  73674. */
  73675. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73676. /**
  73677. * Creates a new EquiRectangularCubeTextureAssetTask object
  73678. * @param name defines the name of the task
  73679. * @param url defines the location of the file to load
  73680. * @param size defines the desired size (the more it increases the longer the generation will be)
  73681. * If the size is omitted this implies you are using a preprocessed cubemap.
  73682. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73683. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73684. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73685. * (default is true)
  73686. */
  73687. constructor(
  73688. /**
  73689. * Defines the name of the task
  73690. */
  73691. name: string,
  73692. /**
  73693. * Defines the location of the file to load
  73694. */
  73695. url: string,
  73696. /**
  73697. * Defines the desired size (the more it increases the longer the generation will be)
  73698. */
  73699. size: number,
  73700. /**
  73701. * Defines if mipmaps should not be generated (default is false)
  73702. */
  73703. noMipmap?: boolean,
  73704. /**
  73705. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73706. * but the standard material would require them in Gamma space) (default is true)
  73707. */
  73708. gammaSpace?: boolean);
  73709. /**
  73710. * Execute the current task
  73711. * @param scene defines the scene where you want your assets to be loaded
  73712. * @param onSuccess is a callback called when the task is successfully executed
  73713. * @param onError is a callback called if an error occurs
  73714. */
  73715. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73716. }
  73717. /**
  73718. * This class can be used to easily import assets into a scene
  73719. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73720. */
  73721. export class AssetsManager {
  73722. private _scene;
  73723. private _isLoading;
  73724. protected _tasks: AbstractAssetTask[];
  73725. protected _waitingTasksCount: number;
  73726. protected _totalTasksCount: number;
  73727. /**
  73728. * Callback called when all tasks are processed
  73729. */
  73730. onFinish: (tasks: AbstractAssetTask[]) => void;
  73731. /**
  73732. * Callback called when a task is successful
  73733. */
  73734. onTaskSuccess: (task: AbstractAssetTask) => void;
  73735. /**
  73736. * Callback called when a task had an error
  73737. */
  73738. onTaskError: (task: AbstractAssetTask) => void;
  73739. /**
  73740. * Callback called when a task is done (whatever the result is)
  73741. */
  73742. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73743. /**
  73744. * Observable called when all tasks are processed
  73745. */
  73746. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73747. /**
  73748. * Observable called when a task had an error
  73749. */
  73750. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73751. /**
  73752. * Observable called when all tasks were executed
  73753. */
  73754. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73755. /**
  73756. * Observable called when a task is done (whatever the result is)
  73757. */
  73758. onProgressObservable: Observable<IAssetsProgressEvent>;
  73759. /**
  73760. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73761. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73762. */
  73763. useDefaultLoadingScreen: boolean;
  73764. /**
  73765. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73766. * when all assets have been downloaded.
  73767. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73768. */
  73769. autoHideLoadingUI: boolean;
  73770. /**
  73771. * Creates a new AssetsManager
  73772. * @param scene defines the scene to work on
  73773. */
  73774. constructor(scene: Scene);
  73775. /**
  73776. * Add a ContainerAssetTask to the list of active tasks
  73777. * @param taskName defines the name of the new task
  73778. * @param meshesNames defines the name of meshes to load
  73779. * @param rootUrl defines the root url to use to locate files
  73780. * @param sceneFilename defines the filename of the scene file
  73781. * @returns a new ContainerAssetTask object
  73782. */
  73783. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73784. /**
  73785. * Add a MeshAssetTask to the list of active tasks
  73786. * @param taskName defines the name of the new task
  73787. * @param meshesNames defines the name of meshes to load
  73788. * @param rootUrl defines the root url to use to locate files
  73789. * @param sceneFilename defines the filename of the scene file
  73790. * @returns a new MeshAssetTask object
  73791. */
  73792. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73793. /**
  73794. * Add a TextFileAssetTask to the list of active tasks
  73795. * @param taskName defines the name of the new task
  73796. * @param url defines the url of the file to load
  73797. * @returns a new TextFileAssetTask object
  73798. */
  73799. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73800. /**
  73801. * Add a BinaryFileAssetTask to the list of active tasks
  73802. * @param taskName defines the name of the new task
  73803. * @param url defines the url of the file to load
  73804. * @returns a new BinaryFileAssetTask object
  73805. */
  73806. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73807. /**
  73808. * Add a ImageAssetTask to the list of active tasks
  73809. * @param taskName defines the name of the new task
  73810. * @param url defines the url of the file to load
  73811. * @returns a new ImageAssetTask object
  73812. */
  73813. addImageTask(taskName: string, url: string): ImageAssetTask;
  73814. /**
  73815. * Add a TextureAssetTask to the list of active tasks
  73816. * @param taskName defines the name of the new task
  73817. * @param url defines the url of the file to load
  73818. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73819. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73820. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73821. * @returns a new TextureAssetTask object
  73822. */
  73823. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73824. /**
  73825. * Add a CubeTextureAssetTask to the list of active tasks
  73826. * @param taskName defines the name of the new task
  73827. * @param url defines the url of the file to load
  73828. * @param extensions defines the extension to use to load the cube map (can be null)
  73829. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73830. * @param files defines the list of files to load (can be null)
  73831. * @returns a new CubeTextureAssetTask object
  73832. */
  73833. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73834. /**
  73835. *
  73836. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73837. * @param taskName defines the name of the new task
  73838. * @param url defines the url of the file to load
  73839. * @param size defines the size you want for the cubemap (can be null)
  73840. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73841. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73842. * @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)
  73843. * @param reserved Internal use only
  73844. * @returns a new HDRCubeTextureAssetTask object
  73845. */
  73846. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73847. /**
  73848. *
  73849. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73850. * @param taskName defines the name of the new task
  73851. * @param url defines the url of the file to load
  73852. * @param size defines the size you want for the cubemap (can be null)
  73853. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73854. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  73855. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  73856. * @returns a new EquiRectangularCubeTextureAssetTask object
  73857. */
  73858. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  73859. /**
  73860. * Remove a task from the assets manager.
  73861. * @param task the task to remove
  73862. */
  73863. removeTask(task: AbstractAssetTask): void;
  73864. private _decreaseWaitingTasksCount;
  73865. private _runTask;
  73866. /**
  73867. * Reset the AssetsManager and remove all tasks
  73868. * @return the current instance of the AssetsManager
  73869. */
  73870. reset(): AssetsManager;
  73871. /**
  73872. * Start the loading process
  73873. * @return the current instance of the AssetsManager
  73874. */
  73875. load(): AssetsManager;
  73876. /**
  73877. * Start the loading process as an async operation
  73878. * @return a promise returning the list of failed tasks
  73879. */
  73880. loadAsync(): Promise<void>;
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /**
  73885. * Wrapper class for promise with external resolve and reject.
  73886. */
  73887. export class Deferred<T> {
  73888. /**
  73889. * The promise associated with this deferred object.
  73890. */
  73891. readonly promise: Promise<T>;
  73892. private _resolve;
  73893. private _reject;
  73894. /**
  73895. * The resolve method of the promise associated with this deferred object.
  73896. */
  73897. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  73898. /**
  73899. * The reject method of the promise associated with this deferred object.
  73900. */
  73901. get reject(): (reason?: any) => void;
  73902. /**
  73903. * Constructor for this deferred object.
  73904. */
  73905. constructor();
  73906. }
  73907. }
  73908. declare module BABYLON {
  73909. /**
  73910. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  73911. */
  73912. export class MeshExploder {
  73913. private _centerMesh;
  73914. private _meshes;
  73915. private _meshesOrigins;
  73916. private _toCenterVectors;
  73917. private _scaledDirection;
  73918. private _newPosition;
  73919. private _centerPosition;
  73920. /**
  73921. * Explodes meshes from a center mesh.
  73922. * @param meshes The meshes to explode.
  73923. * @param centerMesh The mesh to be center of explosion.
  73924. */
  73925. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  73926. private _setCenterMesh;
  73927. /**
  73928. * Get class name
  73929. * @returns "MeshExploder"
  73930. */
  73931. getClassName(): string;
  73932. /**
  73933. * "Exploded meshes"
  73934. * @returns Array of meshes with the centerMesh at index 0.
  73935. */
  73936. getMeshes(): Array<Mesh>;
  73937. /**
  73938. * Explodes meshes giving a specific direction
  73939. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  73940. */
  73941. explode(direction?: number): void;
  73942. }
  73943. }
  73944. declare module BABYLON {
  73945. /**
  73946. * Class used to help managing file picking and drag'n'drop
  73947. */
  73948. export class FilesInput {
  73949. /**
  73950. * List of files ready to be loaded
  73951. */
  73952. static get FilesToLoad(): {
  73953. [key: string]: File;
  73954. };
  73955. /**
  73956. * Callback called when a file is processed
  73957. */
  73958. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  73959. private _engine;
  73960. private _currentScene;
  73961. private _sceneLoadedCallback;
  73962. private _progressCallback;
  73963. private _additionalRenderLoopLogicCallback;
  73964. private _textureLoadingCallback;
  73965. private _startingProcessingFilesCallback;
  73966. private _onReloadCallback;
  73967. private _errorCallback;
  73968. private _elementToMonitor;
  73969. private _sceneFileToLoad;
  73970. private _filesToLoad;
  73971. /**
  73972. * Creates a new FilesInput
  73973. * @param engine defines the rendering engine
  73974. * @param scene defines the hosting scene
  73975. * @param sceneLoadedCallback callback called when scene is loaded
  73976. * @param progressCallback callback called to track progress
  73977. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  73978. * @param textureLoadingCallback callback called when a texture is loading
  73979. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  73980. * @param onReloadCallback callback called when a reload is requested
  73981. * @param errorCallback callback call if an error occurs
  73982. */
  73983. 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>);
  73984. private _dragEnterHandler;
  73985. private _dragOverHandler;
  73986. private _dropHandler;
  73987. /**
  73988. * Calls this function to listen to drag'n'drop events on a specific DOM element
  73989. * @param elementToMonitor defines the DOM element to track
  73990. */
  73991. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  73992. /** Gets the current list of files to load */
  73993. get filesToLoad(): File[];
  73994. /**
  73995. * Release all associated resources
  73996. */
  73997. dispose(): void;
  73998. private renderFunction;
  73999. private drag;
  74000. private drop;
  74001. private _traverseFolder;
  74002. private _processFiles;
  74003. /**
  74004. * Load files from a drop event
  74005. * @param event defines the drop event to use as source
  74006. */
  74007. loadFiles(event: any): void;
  74008. private _processReload;
  74009. /**
  74010. * Reload the current scene from the loaded files
  74011. */
  74012. reload(): void;
  74013. }
  74014. }
  74015. declare module BABYLON {
  74016. /**
  74017. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74018. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74019. */
  74020. export class SceneOptimization {
  74021. /**
  74022. * Defines the priority of this optimization (0 by default which means first in the list)
  74023. */
  74024. priority: number;
  74025. /**
  74026. * Gets a string describing the action executed by the current optimization
  74027. * @returns description string
  74028. */
  74029. getDescription(): string;
  74030. /**
  74031. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74032. * @param scene defines the current scene where to apply this optimization
  74033. * @param optimizer defines the current optimizer
  74034. * @returns true if everything that can be done was applied
  74035. */
  74036. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74037. /**
  74038. * Creates the SceneOptimization object
  74039. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74040. * @param desc defines the description associated with the optimization
  74041. */
  74042. constructor(
  74043. /**
  74044. * Defines the priority of this optimization (0 by default which means first in the list)
  74045. */
  74046. priority?: number);
  74047. }
  74048. /**
  74049. * Defines an optimization used to reduce the size of render target textures
  74050. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74051. */
  74052. export class TextureOptimization extends SceneOptimization {
  74053. /**
  74054. * Defines the priority of this optimization (0 by default which means first in the list)
  74055. */
  74056. priority: number;
  74057. /**
  74058. * 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
  74059. */
  74060. maximumSize: number;
  74061. /**
  74062. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74063. */
  74064. step: number;
  74065. /**
  74066. * Gets a string describing the action executed by the current optimization
  74067. * @returns description string
  74068. */
  74069. getDescription(): string;
  74070. /**
  74071. * Creates the TextureOptimization object
  74072. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74073. * @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
  74074. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74075. */
  74076. constructor(
  74077. /**
  74078. * Defines the priority of this optimization (0 by default which means first in the list)
  74079. */
  74080. priority?: number,
  74081. /**
  74082. * 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
  74083. */
  74084. maximumSize?: number,
  74085. /**
  74086. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74087. */
  74088. step?: number);
  74089. /**
  74090. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74091. * @param scene defines the current scene where to apply this optimization
  74092. * @param optimizer defines the current optimizer
  74093. * @returns true if everything that can be done was applied
  74094. */
  74095. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74096. }
  74097. /**
  74098. * Defines an optimization used to increase or decrease the rendering resolution
  74099. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74100. */
  74101. export class HardwareScalingOptimization extends SceneOptimization {
  74102. /**
  74103. * Defines the priority of this optimization (0 by default which means first in the list)
  74104. */
  74105. priority: number;
  74106. /**
  74107. * Defines the maximum scale to use (2 by default)
  74108. */
  74109. maximumScale: number;
  74110. /**
  74111. * Defines the step to use between two passes (0.5 by default)
  74112. */
  74113. step: number;
  74114. private _currentScale;
  74115. private _directionOffset;
  74116. /**
  74117. * Gets a string describing the action executed by the current optimization
  74118. * @return description string
  74119. */
  74120. getDescription(): string;
  74121. /**
  74122. * Creates the HardwareScalingOptimization object
  74123. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74124. * @param maximumScale defines the maximum scale to use (2 by default)
  74125. * @param step defines the step to use between two passes (0.5 by default)
  74126. */
  74127. constructor(
  74128. /**
  74129. * Defines the priority of this optimization (0 by default which means first in the list)
  74130. */
  74131. priority?: number,
  74132. /**
  74133. * Defines the maximum scale to use (2 by default)
  74134. */
  74135. maximumScale?: number,
  74136. /**
  74137. * Defines the step to use between two passes (0.5 by default)
  74138. */
  74139. step?: number);
  74140. /**
  74141. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74142. * @param scene defines the current scene where to apply this optimization
  74143. * @param optimizer defines the current optimizer
  74144. * @returns true if everything that can be done was applied
  74145. */
  74146. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74147. }
  74148. /**
  74149. * Defines an optimization used to remove shadows
  74150. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74151. */
  74152. export class ShadowsOptimization extends SceneOptimization {
  74153. /**
  74154. * Gets a string describing the action executed by the current optimization
  74155. * @return description string
  74156. */
  74157. getDescription(): string;
  74158. /**
  74159. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74160. * @param scene defines the current scene where to apply this optimization
  74161. * @param optimizer defines the current optimizer
  74162. * @returns true if everything that can be done was applied
  74163. */
  74164. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74165. }
  74166. /**
  74167. * Defines an optimization used to turn post-processes off
  74168. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74169. */
  74170. export class PostProcessesOptimization extends SceneOptimization {
  74171. /**
  74172. * Gets a string describing the action executed by the current optimization
  74173. * @return description string
  74174. */
  74175. getDescription(): string;
  74176. /**
  74177. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74178. * @param scene defines the current scene where to apply this optimization
  74179. * @param optimizer defines the current optimizer
  74180. * @returns true if everything that can be done was applied
  74181. */
  74182. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74183. }
  74184. /**
  74185. * Defines an optimization used to turn lens flares off
  74186. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74187. */
  74188. export class LensFlaresOptimization extends SceneOptimization {
  74189. /**
  74190. * Gets a string describing the action executed by the current optimization
  74191. * @return description string
  74192. */
  74193. getDescription(): string;
  74194. /**
  74195. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74196. * @param scene defines the current scene where to apply this optimization
  74197. * @param optimizer defines the current optimizer
  74198. * @returns true if everything that can be done was applied
  74199. */
  74200. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74201. }
  74202. /**
  74203. * Defines an optimization based on user defined callback.
  74204. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74205. */
  74206. export class CustomOptimization extends SceneOptimization {
  74207. /**
  74208. * Callback called to apply the custom optimization.
  74209. */
  74210. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74211. /**
  74212. * Callback called to get custom description
  74213. */
  74214. onGetDescription: () => string;
  74215. /**
  74216. * Gets a string describing the action executed by the current optimization
  74217. * @returns description string
  74218. */
  74219. getDescription(): string;
  74220. /**
  74221. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74222. * @param scene defines the current scene where to apply this optimization
  74223. * @param optimizer defines the current optimizer
  74224. * @returns true if everything that can be done was applied
  74225. */
  74226. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74227. }
  74228. /**
  74229. * Defines an optimization used to turn particles off
  74230. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74231. */
  74232. export class ParticlesOptimization extends SceneOptimization {
  74233. /**
  74234. * Gets a string describing the action executed by the current optimization
  74235. * @return description string
  74236. */
  74237. getDescription(): string;
  74238. /**
  74239. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74240. * @param scene defines the current scene where to apply this optimization
  74241. * @param optimizer defines the current optimizer
  74242. * @returns true if everything that can be done was applied
  74243. */
  74244. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74245. }
  74246. /**
  74247. * Defines an optimization used to turn render targets off
  74248. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74249. */
  74250. export class RenderTargetsOptimization extends SceneOptimization {
  74251. /**
  74252. * Gets a string describing the action executed by the current optimization
  74253. * @return description string
  74254. */
  74255. getDescription(): string;
  74256. /**
  74257. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74258. * @param scene defines the current scene where to apply this optimization
  74259. * @param optimizer defines the current optimizer
  74260. * @returns true if everything that can be done was applied
  74261. */
  74262. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74263. }
  74264. /**
  74265. * Defines an optimization used to merge meshes with compatible materials
  74266. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74267. */
  74268. export class MergeMeshesOptimization extends SceneOptimization {
  74269. private static _UpdateSelectionTree;
  74270. /**
  74271. * Gets or sets a boolean which defines if optimization octree has to be updated
  74272. */
  74273. static get UpdateSelectionTree(): boolean;
  74274. /**
  74275. * Gets or sets a boolean which defines if optimization octree has to be updated
  74276. */
  74277. static set UpdateSelectionTree(value: boolean);
  74278. /**
  74279. * Gets a string describing the action executed by the current optimization
  74280. * @return description string
  74281. */
  74282. getDescription(): string;
  74283. private _canBeMerged;
  74284. /**
  74285. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74286. * @param scene defines the current scene where to apply this optimization
  74287. * @param optimizer defines the current optimizer
  74288. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74289. * @returns true if everything that can be done was applied
  74290. */
  74291. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74292. }
  74293. /**
  74294. * Defines a list of options used by SceneOptimizer
  74295. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74296. */
  74297. export class SceneOptimizerOptions {
  74298. /**
  74299. * Defines the target frame rate to reach (60 by default)
  74300. */
  74301. targetFrameRate: number;
  74302. /**
  74303. * Defines the interval between two checkes (2000ms by default)
  74304. */
  74305. trackerDuration: number;
  74306. /**
  74307. * Gets the list of optimizations to apply
  74308. */
  74309. optimizations: SceneOptimization[];
  74310. /**
  74311. * Creates a new list of options used by SceneOptimizer
  74312. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74313. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74314. */
  74315. constructor(
  74316. /**
  74317. * Defines the target frame rate to reach (60 by default)
  74318. */
  74319. targetFrameRate?: number,
  74320. /**
  74321. * Defines the interval between two checkes (2000ms by default)
  74322. */
  74323. trackerDuration?: number);
  74324. /**
  74325. * Add a new optimization
  74326. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74327. * @returns the current SceneOptimizerOptions
  74328. */
  74329. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74330. /**
  74331. * Add a new custom optimization
  74332. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74333. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74334. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74335. * @returns the current SceneOptimizerOptions
  74336. */
  74337. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74338. /**
  74339. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74340. * @param targetFrameRate defines the target frame rate (60 by default)
  74341. * @returns a SceneOptimizerOptions object
  74342. */
  74343. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74344. /**
  74345. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74346. * @param targetFrameRate defines the target frame rate (60 by default)
  74347. * @returns a SceneOptimizerOptions object
  74348. */
  74349. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74350. /**
  74351. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74352. * @param targetFrameRate defines the target frame rate (60 by default)
  74353. * @returns a SceneOptimizerOptions object
  74354. */
  74355. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74356. }
  74357. /**
  74358. * Class used to run optimizations in order to reach a target frame rate
  74359. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74360. */
  74361. export class SceneOptimizer implements IDisposable {
  74362. private _isRunning;
  74363. private _options;
  74364. private _scene;
  74365. private _currentPriorityLevel;
  74366. private _targetFrameRate;
  74367. private _trackerDuration;
  74368. private _currentFrameRate;
  74369. private _sceneDisposeObserver;
  74370. private _improvementMode;
  74371. /**
  74372. * Defines an observable called when the optimizer reaches the target frame rate
  74373. */
  74374. onSuccessObservable: Observable<SceneOptimizer>;
  74375. /**
  74376. * Defines an observable called when the optimizer enables an optimization
  74377. */
  74378. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74379. /**
  74380. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74381. */
  74382. onFailureObservable: Observable<SceneOptimizer>;
  74383. /**
  74384. * Gets a boolean indicating if the optimizer is in improvement mode
  74385. */
  74386. get isInImprovementMode(): boolean;
  74387. /**
  74388. * Gets the current priority level (0 at start)
  74389. */
  74390. get currentPriorityLevel(): number;
  74391. /**
  74392. * Gets the current frame rate checked by the SceneOptimizer
  74393. */
  74394. get currentFrameRate(): number;
  74395. /**
  74396. * Gets or sets the current target frame rate (60 by default)
  74397. */
  74398. get targetFrameRate(): number;
  74399. /**
  74400. * Gets or sets the current target frame rate (60 by default)
  74401. */
  74402. set targetFrameRate(value: number);
  74403. /**
  74404. * Gets or sets the current interval between two checks (every 2000ms by default)
  74405. */
  74406. get trackerDuration(): number;
  74407. /**
  74408. * Gets or sets the current interval between two checks (every 2000ms by default)
  74409. */
  74410. set trackerDuration(value: number);
  74411. /**
  74412. * Gets the list of active optimizations
  74413. */
  74414. get optimizations(): SceneOptimization[];
  74415. /**
  74416. * Creates a new SceneOptimizer
  74417. * @param scene defines the scene to work on
  74418. * @param options defines the options to use with the SceneOptimizer
  74419. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74420. * @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)
  74421. */
  74422. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74423. /**
  74424. * Stops the current optimizer
  74425. */
  74426. stop(): void;
  74427. /**
  74428. * Reset the optimizer to initial step (current priority level = 0)
  74429. */
  74430. reset(): void;
  74431. /**
  74432. * Start the optimizer. By default it will try to reach a specific framerate
  74433. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74434. */
  74435. start(): void;
  74436. private _checkCurrentState;
  74437. /**
  74438. * Release all resources
  74439. */
  74440. dispose(): void;
  74441. /**
  74442. * Helper function to create a SceneOptimizer with one single line of code
  74443. * @param scene defines the scene to work on
  74444. * @param options defines the options to use with the SceneOptimizer
  74445. * @param onSuccess defines a callback to call on success
  74446. * @param onFailure defines a callback to call on failure
  74447. * @returns the new SceneOptimizer object
  74448. */
  74449. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74450. }
  74451. }
  74452. declare module BABYLON {
  74453. /**
  74454. * Class used to serialize a scene into a string
  74455. */
  74456. export class SceneSerializer {
  74457. /**
  74458. * Clear cache used by a previous serialization
  74459. */
  74460. static ClearCache(): void;
  74461. /**
  74462. * Serialize a scene into a JSON compatible object
  74463. * @param scene defines the scene to serialize
  74464. * @returns a JSON compatible object
  74465. */
  74466. static Serialize(scene: Scene): any;
  74467. /**
  74468. * Serialize a mesh into a JSON compatible object
  74469. * @param toSerialize defines the mesh to serialize
  74470. * @param withParents defines if parents must be serialized as well
  74471. * @param withChildren defines if children must be serialized as well
  74472. * @returns a JSON compatible object
  74473. */
  74474. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74475. }
  74476. }
  74477. declare module BABYLON {
  74478. /**
  74479. * Class used to host texture specific utilities
  74480. */
  74481. export class TextureTools {
  74482. /**
  74483. * Uses the GPU to create a copy texture rescaled at a given size
  74484. * @param texture Texture to copy from
  74485. * @param width defines the desired width
  74486. * @param height defines the desired height
  74487. * @param useBilinearMode defines if bilinear mode has to be used
  74488. * @return the generated texture
  74489. */
  74490. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /**
  74495. * This represents the different options available for the video capture.
  74496. */
  74497. export interface VideoRecorderOptions {
  74498. /** Defines the mime type of the video. */
  74499. mimeType: string;
  74500. /** Defines the FPS the video should be recorded at. */
  74501. fps: number;
  74502. /** Defines the chunk size for the recording data. */
  74503. recordChunckSize: number;
  74504. /** The audio tracks to attach to the recording. */
  74505. audioTracks?: MediaStreamTrack[];
  74506. }
  74507. /**
  74508. * This can help with recording videos from BabylonJS.
  74509. * This is based on the available WebRTC functionalities of the browser.
  74510. *
  74511. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74512. */
  74513. export class VideoRecorder {
  74514. private static readonly _defaultOptions;
  74515. /**
  74516. * Returns whether or not the VideoRecorder is available in your browser.
  74517. * @param engine Defines the Babylon Engine.
  74518. * @returns true if supported otherwise false.
  74519. */
  74520. static IsSupported(engine: Engine): boolean;
  74521. private readonly _options;
  74522. private _canvas;
  74523. private _mediaRecorder;
  74524. private _recordedChunks;
  74525. private _fileName;
  74526. private _resolve;
  74527. private _reject;
  74528. /**
  74529. * True when a recording is already in progress.
  74530. */
  74531. get isRecording(): boolean;
  74532. /**
  74533. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74534. * @param engine Defines the BabylonJS Engine you wish to record.
  74535. * @param options Defines options that can be used to customize the capture.
  74536. */
  74537. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74538. /**
  74539. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74540. */
  74541. stopRecording(): void;
  74542. /**
  74543. * Starts recording the canvas for a max duration specified in parameters.
  74544. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74545. * If null no automatic download will start and you can rely on the promise to get the data back.
  74546. * @param maxDuration Defines the maximum recording time in seconds.
  74547. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74548. * @return A promise callback at the end of the recording with the video data in Blob.
  74549. */
  74550. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74551. /**
  74552. * Releases internal resources used during the recording.
  74553. */
  74554. dispose(): void;
  74555. private _handleDataAvailable;
  74556. private _handleError;
  74557. private _handleStop;
  74558. }
  74559. }
  74560. declare module BABYLON {
  74561. /**
  74562. * Class containing a set of static utilities functions for screenshots
  74563. */
  74564. export class ScreenshotTools {
  74565. /**
  74566. * Captures a screenshot of the current rendering
  74567. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74568. * @param engine defines the rendering engine
  74569. * @param camera defines the source camera
  74570. * @param size This parameter can be set to a single number or to an object with the
  74571. * following (optional) properties: precision, width, height. If a single number is passed,
  74572. * it will be used for both width and height. If an object is passed, the screenshot size
  74573. * will be derived from the parameters. The precision property is a multiplier allowing
  74574. * rendering at a higher or lower resolution
  74575. * @param successCallback defines the callback receives a single parameter which contains the
  74576. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74577. * src parameter of an <img> to display it
  74578. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74579. * Check your browser for supported MIME types
  74580. */
  74581. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74582. /**
  74583. * Captures a screenshot of the current rendering
  74584. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74585. * @param engine defines the rendering engine
  74586. * @param camera defines the source camera
  74587. * @param size This parameter can be set to a single number or to an object with the
  74588. * following (optional) properties: precision, width, height. If a single number is passed,
  74589. * it will be used for both width and height. If an object is passed, the screenshot size
  74590. * will be derived from the parameters. The precision property is a multiplier allowing
  74591. * rendering at a higher or lower resolution
  74592. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74593. * Check your browser for supported MIME types
  74594. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74595. * to the src parameter of an <img> to display it
  74596. */
  74597. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74598. /**
  74599. * Generates an image screenshot from the specified camera.
  74600. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74601. * @param engine The engine to use for rendering
  74602. * @param camera The camera to use for rendering
  74603. * @param size This parameter can be set to a single number or to an object with the
  74604. * following (optional) properties: precision, width, height. If a single number is passed,
  74605. * it will be used for both width and height. If an object is passed, the screenshot size
  74606. * will be derived from the parameters. The precision property is a multiplier allowing
  74607. * rendering at a higher or lower resolution
  74608. * @param successCallback The callback receives a single parameter which contains the
  74609. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74610. * src parameter of an <img> to display it
  74611. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74612. * Check your browser for supported MIME types
  74613. * @param samples Texture samples (default: 1)
  74614. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74615. * @param fileName A name for for the downloaded file.
  74616. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74617. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74618. */
  74619. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  74620. /**
  74621. * Generates an image screenshot from the specified camera.
  74622. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74623. * @param engine The engine to use for rendering
  74624. * @param camera The camera to use for rendering
  74625. * @param size This parameter can be set to a single number or to an object with the
  74626. * following (optional) properties: precision, width, height. If a single number is passed,
  74627. * it will be used for both width and height. If an object is passed, the screenshot size
  74628. * will be derived from the parameters. The precision property is a multiplier allowing
  74629. * rendering at a higher or lower resolution
  74630. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74631. * Check your browser for supported MIME types
  74632. * @param samples Texture samples (default: 1)
  74633. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74634. * @param fileName A name for for the downloaded file.
  74635. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74636. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74637. * to the src parameter of an <img> to display it
  74638. */
  74639. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74640. /**
  74641. * Gets height and width for screenshot size
  74642. * @private
  74643. */
  74644. private static _getScreenshotSize;
  74645. }
  74646. }
  74647. declare module BABYLON {
  74648. /**
  74649. * Interface for a data buffer
  74650. */
  74651. export interface IDataBuffer {
  74652. /**
  74653. * Reads bytes from the data buffer.
  74654. * @param byteOffset The byte offset to read
  74655. * @param byteLength The byte length to read
  74656. * @returns A promise that resolves when the bytes are read
  74657. */
  74658. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74659. /**
  74660. * The byte length of the buffer.
  74661. */
  74662. readonly byteLength: number;
  74663. }
  74664. /**
  74665. * Utility class for reading from a data buffer
  74666. */
  74667. export class DataReader {
  74668. /**
  74669. * The data buffer associated with this data reader.
  74670. */
  74671. readonly buffer: IDataBuffer;
  74672. /**
  74673. * The current byte offset from the beginning of the data buffer.
  74674. */
  74675. byteOffset: number;
  74676. private _dataView;
  74677. private _dataByteOffset;
  74678. /**
  74679. * Constructor
  74680. * @param buffer The buffer to read
  74681. */
  74682. constructor(buffer: IDataBuffer);
  74683. /**
  74684. * Loads the given byte length.
  74685. * @param byteLength The byte length to load
  74686. * @returns A promise that resolves when the load is complete
  74687. */
  74688. loadAsync(byteLength: number): Promise<void>;
  74689. /**
  74690. * Read a unsigned 32-bit integer from the currently loaded data range.
  74691. * @returns The 32-bit integer read
  74692. */
  74693. readUint32(): number;
  74694. /**
  74695. * Read a byte array from the currently loaded data range.
  74696. * @param byteLength The byte length to read
  74697. * @returns The byte array read
  74698. */
  74699. readUint8Array(byteLength: number): Uint8Array;
  74700. /**
  74701. * Read a string from the currently loaded data range.
  74702. * @param byteLength The byte length to read
  74703. * @returns The string read
  74704. */
  74705. readString(byteLength: number): string;
  74706. /**
  74707. * Skips the given byte length the currently loaded data range.
  74708. * @param byteLength The byte length to skip
  74709. */
  74710. skipBytes(byteLength: number): void;
  74711. }
  74712. }
  74713. declare module BABYLON {
  74714. /**
  74715. * Class for storing data to local storage if available or in-memory storage otherwise
  74716. */
  74717. export class DataStorage {
  74718. private static _Storage;
  74719. private static _GetStorage;
  74720. /**
  74721. * Reads a string from the data storage
  74722. * @param key The key to read
  74723. * @param defaultValue The value if the key doesn't exist
  74724. * @returns The string value
  74725. */
  74726. static ReadString(key: string, defaultValue: string): string;
  74727. /**
  74728. * Writes a string to the data storage
  74729. * @param key The key to write
  74730. * @param value The value to write
  74731. */
  74732. static WriteString(key: string, value: string): void;
  74733. /**
  74734. * Reads a boolean from the data storage
  74735. * @param key The key to read
  74736. * @param defaultValue The value if the key doesn't exist
  74737. * @returns The boolean value
  74738. */
  74739. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74740. /**
  74741. * Writes a boolean to the data storage
  74742. * @param key The key to write
  74743. * @param value The value to write
  74744. */
  74745. static WriteBoolean(key: string, value: boolean): void;
  74746. /**
  74747. * Reads a number from the data storage
  74748. * @param key The key to read
  74749. * @param defaultValue The value if the key doesn't exist
  74750. * @returns The number value
  74751. */
  74752. static ReadNumber(key: string, defaultValue: number): number;
  74753. /**
  74754. * Writes a number to the data storage
  74755. * @param key The key to write
  74756. * @param value The value to write
  74757. */
  74758. static WriteNumber(key: string, value: number): void;
  74759. }
  74760. }
  74761. declare module BABYLON {
  74762. /**
  74763. * Class used to record delta files between 2 scene states
  74764. */
  74765. export class SceneRecorder {
  74766. private _trackedScene;
  74767. private _savedJSON;
  74768. /**
  74769. * Track a given scene. This means the current scene state will be considered the original state
  74770. * @param scene defines the scene to track
  74771. */
  74772. track(scene: Scene): void;
  74773. /**
  74774. * Get the delta between current state and original state
  74775. * @returns a string containing the delta
  74776. */
  74777. getDelta(): any;
  74778. private _compareArray;
  74779. private _compareObjects;
  74780. private _compareCollections;
  74781. private static GetShadowGeneratorById;
  74782. /**
  74783. * Apply a given delta to a given scene
  74784. * @param deltaJSON defines the JSON containing the delta
  74785. * @param scene defines the scene to apply the delta to
  74786. */
  74787. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74788. private static _ApplyPropertiesToEntity;
  74789. private static _ApplyDeltaForEntity;
  74790. }
  74791. }
  74792. declare module BABYLON {
  74793. /**
  74794. * A 3D trajectory consisting of an order list of vectors describing a
  74795. * path of motion through 3D space.
  74796. */
  74797. export class Trajectory {
  74798. private _points;
  74799. private readonly _segmentLength;
  74800. /**
  74801. * Serialize to JSON.
  74802. * @returns serialized JSON string
  74803. */
  74804. serialize(): string;
  74805. /**
  74806. * Deserialize from JSON.
  74807. * @param json serialized JSON string
  74808. * @returns deserialized Trajectory
  74809. */
  74810. static Deserialize(json: string): Trajectory;
  74811. /**
  74812. * Create a new empty Trajectory.
  74813. * @param segmentLength radius of discretization for Trajectory points
  74814. */
  74815. constructor(segmentLength?: number);
  74816. /**
  74817. * Get the length of the Trajectory.
  74818. * @returns length of the Trajectory
  74819. */
  74820. getLength(): number;
  74821. /**
  74822. * Append a new point to the Trajectory.
  74823. * NOTE: This implementation has many allocations.
  74824. * @param point point to append to the Trajectory
  74825. */
  74826. add(point: DeepImmutable<Vector3>): void;
  74827. /**
  74828. * Create a new Trajectory with a segment length chosen to make it
  74829. * probable that the new Trajectory will have a specified number of
  74830. * segments. This operation is imprecise.
  74831. * @param targetResolution number of segments desired
  74832. * @returns new Trajectory with approximately the requested number of segments
  74833. */
  74834. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74835. /**
  74836. * Convert Trajectory segments into tokenized representation. This
  74837. * representation is an array of numbers where each nth number is the
  74838. * index of the token which is most similar to the nth segment of the
  74839. * Trajectory.
  74840. * @param tokens list of vectors which serve as discrete tokens
  74841. * @returns list of indices of most similar token per segment
  74842. */
  74843. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74844. private static _forwardDir;
  74845. private static _inverseFromVec;
  74846. private static _upDir;
  74847. private static _fromToVec;
  74848. private static _lookMatrix;
  74849. /**
  74850. * Transform the rotation (i.e., direction) of a segment to isolate
  74851. * the relative transformation represented by the segment. This operation
  74852. * may or may not succeed due to singularities in the equations that define
  74853. * motion relativity in this context.
  74854. * @param priorVec the origin of the prior segment
  74855. * @param fromVec the origin of the current segment
  74856. * @param toVec the destination of the current segment
  74857. * @param result reference to output variable
  74858. * @returns whether or not transformation was successful
  74859. */
  74860. private static _transformSegmentDirToRef;
  74861. private static _bestMatch;
  74862. private static _score;
  74863. private static _bestScore;
  74864. /**
  74865. * Determine which token vector is most similar to the
  74866. * segment vector.
  74867. * @param segment segment vector
  74868. * @param tokens token vector list
  74869. * @returns index of the most similar token to the segment
  74870. */
  74871. private static _tokenizeSegment;
  74872. }
  74873. /**
  74874. * Class representing a set of known, named trajectories to which Trajectories can be
  74875. * added and using which Trajectories can be recognized.
  74876. */
  74877. export class TrajectoryClassifier {
  74878. private _maximumAllowableMatchCost;
  74879. private _vector3Alphabet;
  74880. private _levenshteinAlphabet;
  74881. private _nameToDescribedTrajectory;
  74882. /**
  74883. * Serialize to JSON.
  74884. * @returns JSON serialization
  74885. */
  74886. serialize(): string;
  74887. /**
  74888. * Deserialize from JSON.
  74889. * @param json JSON serialization
  74890. * @returns deserialized TrajectorySet
  74891. */
  74892. static Deserialize(json: string): TrajectoryClassifier;
  74893. /**
  74894. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  74895. * VERY naive, need to be generating these things from known
  74896. * sets. Better version later, probably eliminating this one.
  74897. * @returns auto-generated TrajectorySet
  74898. */
  74899. static Generate(): TrajectoryClassifier;
  74900. private constructor();
  74901. /**
  74902. * Add a new Trajectory to the set with a given name.
  74903. * @param trajectory new Trajectory to be added
  74904. * @param classification name to which to add the Trajectory
  74905. */
  74906. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  74907. /**
  74908. * Remove a known named trajectory and all Trajectories associated with it.
  74909. * @param classification name to remove
  74910. * @returns whether anything was removed
  74911. */
  74912. deleteClassification(classification: string): boolean;
  74913. /**
  74914. * Attempt to recognize a Trajectory from among all the classifications
  74915. * already known to the classifier.
  74916. * @param trajectory Trajectory to be recognized
  74917. * @returns classification of Trajectory if recognized, null otherwise
  74918. */
  74919. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  74920. }
  74921. }
  74922. declare module BABYLON {
  74923. /**
  74924. * An interface for all Hit test features
  74925. */
  74926. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  74927. /**
  74928. * Triggered when new babylon (transformed) hit test results are available
  74929. */
  74930. onHitTestResultObservable: Observable<T[]>;
  74931. }
  74932. /**
  74933. * Options used for hit testing
  74934. */
  74935. export interface IWebXRLegacyHitTestOptions {
  74936. /**
  74937. * Only test when user interacted with the scene. Default - hit test every frame
  74938. */
  74939. testOnPointerDownOnly?: boolean;
  74940. /**
  74941. * The node to use to transform the local results to world coordinates
  74942. */
  74943. worldParentNode?: TransformNode;
  74944. }
  74945. /**
  74946. * Interface defining the babylon result of raycasting/hit-test
  74947. */
  74948. export interface IWebXRLegacyHitResult {
  74949. /**
  74950. * Transformation matrix that can be applied to a node that will put it in the hit point location
  74951. */
  74952. transformationMatrix: Matrix;
  74953. /**
  74954. * The native hit test result
  74955. */
  74956. xrHitResult: XRHitResult | XRHitTestResult;
  74957. }
  74958. /**
  74959. * The currently-working hit-test module.
  74960. * Hit test (or Ray-casting) is used to interact with the real world.
  74961. * For further information read here - https://github.com/immersive-web/hit-test
  74962. */
  74963. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  74964. /**
  74965. * options to use when constructing this feature
  74966. */
  74967. readonly options: IWebXRLegacyHitTestOptions;
  74968. private _direction;
  74969. private _mat;
  74970. private _onSelectEnabled;
  74971. private _origin;
  74972. /**
  74973. * The module's name
  74974. */
  74975. static readonly Name: string;
  74976. /**
  74977. * The (Babylon) version of this module.
  74978. * This is an integer representing the implementation version.
  74979. * This number does not correspond to the WebXR specs version
  74980. */
  74981. static readonly Version: number;
  74982. /**
  74983. * Populated with the last native XR Hit Results
  74984. */
  74985. lastNativeXRHitResults: XRHitResult[];
  74986. /**
  74987. * Triggered when new babylon (transformed) hit test results are available
  74988. */
  74989. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  74990. /**
  74991. * Creates a new instance of the (legacy version) hit test feature
  74992. * @param _xrSessionManager an instance of WebXRSessionManager
  74993. * @param options options to use when constructing this feature
  74994. */
  74995. constructor(_xrSessionManager: WebXRSessionManager,
  74996. /**
  74997. * options to use when constructing this feature
  74998. */
  74999. options?: IWebXRLegacyHitTestOptions);
  75000. /**
  75001. * execute a hit test with an XR Ray
  75002. *
  75003. * @param xrSession a native xrSession that will execute this hit test
  75004. * @param xrRay the ray (position and direction) to use for ray-casting
  75005. * @param referenceSpace native XR reference space to use for the hit-test
  75006. * @param filter filter function that will filter the results
  75007. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75008. */
  75009. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75010. /**
  75011. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75012. * @param event the (select) event to use to select with
  75013. * @param referenceSpace the reference space to use for this hit test
  75014. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75015. */
  75016. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75017. /**
  75018. * attach this feature
  75019. * Will usually be called by the features manager
  75020. *
  75021. * @returns true if successful.
  75022. */
  75023. attach(): boolean;
  75024. /**
  75025. * detach this feature.
  75026. * Will usually be called by the features manager
  75027. *
  75028. * @returns true if successful.
  75029. */
  75030. detach(): boolean;
  75031. /**
  75032. * Dispose this feature and all of the resources attached
  75033. */
  75034. dispose(): void;
  75035. protected _onXRFrame(frame: XRFrame): void;
  75036. private _onHitTestResults;
  75037. private _onSelect;
  75038. }
  75039. }
  75040. declare module BABYLON {
  75041. /**
  75042. * Options used for hit testing (version 2)
  75043. */
  75044. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75045. /**
  75046. * Do not create a permanent hit test. Will usually be used when only
  75047. * transient inputs are needed.
  75048. */
  75049. disablePermanentHitTest?: boolean;
  75050. /**
  75051. * Enable transient (for example touch-based) hit test inspections
  75052. */
  75053. enableTransientHitTest?: boolean;
  75054. /**
  75055. * Offset ray for the permanent hit test
  75056. */
  75057. offsetRay?: Vector3;
  75058. /**
  75059. * Offset ray for the transient hit test
  75060. */
  75061. transientOffsetRay?: Vector3;
  75062. /**
  75063. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75064. */
  75065. useReferenceSpace?: boolean;
  75066. /**
  75067. * Override the default entity type(s) of the hit-test result
  75068. */
  75069. entityTypes?: XRHitTestTrackableType[];
  75070. }
  75071. /**
  75072. * Interface defining the babylon result of hit-test
  75073. */
  75074. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75075. /**
  75076. * The input source that generated this hit test (if transient)
  75077. */
  75078. inputSource?: XRInputSource;
  75079. /**
  75080. * Is this a transient hit test
  75081. */
  75082. isTransient?: boolean;
  75083. /**
  75084. * Position of the hit test result
  75085. */
  75086. position: Vector3;
  75087. /**
  75088. * Rotation of the hit test result
  75089. */
  75090. rotationQuaternion: Quaternion;
  75091. /**
  75092. * The native hit test result
  75093. */
  75094. xrHitResult: XRHitTestResult;
  75095. }
  75096. /**
  75097. * The currently-working hit-test module.
  75098. * Hit test (or Ray-casting) is used to interact with the real world.
  75099. * For further information read here - https://github.com/immersive-web/hit-test
  75100. *
  75101. * Tested on chrome (mobile) 80.
  75102. */
  75103. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75104. /**
  75105. * options to use when constructing this feature
  75106. */
  75107. readonly options: IWebXRHitTestOptions;
  75108. private _tmpMat;
  75109. private _tmpPos;
  75110. private _tmpQuat;
  75111. private _transientXrHitTestSource;
  75112. private _xrHitTestSource;
  75113. private initHitTestSource;
  75114. /**
  75115. * The module's name
  75116. */
  75117. static readonly Name: string;
  75118. /**
  75119. * The (Babylon) version of this module.
  75120. * This is an integer representing the implementation version.
  75121. * This number does not correspond to the WebXR specs version
  75122. */
  75123. static readonly Version: number;
  75124. /**
  75125. * When set to true, each hit test will have its own position/rotation objects
  75126. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75127. * the developers will clone them or copy them as they see fit.
  75128. */
  75129. autoCloneTransformation: boolean;
  75130. /**
  75131. * Triggered when new babylon (transformed) hit test results are available
  75132. * Note - this will be called when results come back from the device. It can be an empty array!!
  75133. */
  75134. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75135. /**
  75136. * Use this to temporarily pause hit test checks.
  75137. */
  75138. paused: boolean;
  75139. /**
  75140. * Creates a new instance of the hit test feature
  75141. * @param _xrSessionManager an instance of WebXRSessionManager
  75142. * @param options options to use when constructing this feature
  75143. */
  75144. constructor(_xrSessionManager: WebXRSessionManager,
  75145. /**
  75146. * options to use when constructing this feature
  75147. */
  75148. options?: IWebXRHitTestOptions);
  75149. /**
  75150. * attach this feature
  75151. * Will usually be called by the features manager
  75152. *
  75153. * @returns true if successful.
  75154. */
  75155. attach(): boolean;
  75156. /**
  75157. * detach this feature.
  75158. * Will usually be called by the features manager
  75159. *
  75160. * @returns true if successful.
  75161. */
  75162. detach(): boolean;
  75163. /**
  75164. * Dispose this feature and all of the resources attached
  75165. */
  75166. dispose(): void;
  75167. protected _onXRFrame(frame: XRFrame): void;
  75168. private _processWebXRHitTestResult;
  75169. }
  75170. }
  75171. declare module BABYLON {
  75172. /**
  75173. * Configuration options of the anchor system
  75174. */
  75175. export interface IWebXRAnchorSystemOptions {
  75176. /**
  75177. * a node that will be used to convert local to world coordinates
  75178. */
  75179. worldParentNode?: TransformNode;
  75180. /**
  75181. * If set to true a reference of the created anchors will be kept until the next session starts
  75182. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75183. */
  75184. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75185. }
  75186. /**
  75187. * A babylon container for an XR Anchor
  75188. */
  75189. export interface IWebXRAnchor {
  75190. /**
  75191. * A babylon-assigned ID for this anchor
  75192. */
  75193. id: number;
  75194. /**
  75195. * Transformation matrix to apply to an object attached to this anchor
  75196. */
  75197. transformationMatrix: Matrix;
  75198. /**
  75199. * The native anchor object
  75200. */
  75201. xrAnchor: XRAnchor;
  75202. /**
  75203. * if defined, this object will be constantly updated by the anchor's position and rotation
  75204. */
  75205. attachedNode?: TransformNode;
  75206. }
  75207. /**
  75208. * An implementation of the anchor system for WebXR.
  75209. * For further information see https://github.com/immersive-web/anchors/
  75210. */
  75211. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75212. private _options;
  75213. private _lastFrameDetected;
  75214. private _trackedAnchors;
  75215. private _referenceSpaceForFrameAnchors;
  75216. private _futureAnchors;
  75217. /**
  75218. * The module's name
  75219. */
  75220. static readonly Name: string;
  75221. /**
  75222. * The (Babylon) version of this module.
  75223. * This is an integer representing the implementation version.
  75224. * This number does not correspond to the WebXR specs version
  75225. */
  75226. static readonly Version: number;
  75227. /**
  75228. * Observers registered here will be executed when a new anchor was added to the session
  75229. */
  75230. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75231. /**
  75232. * Observers registered here will be executed when an anchor was removed from the session
  75233. */
  75234. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75235. /**
  75236. * Observers registered here will be executed when an existing anchor updates
  75237. * This can execute N times every frame
  75238. */
  75239. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75240. /**
  75241. * Set the reference space to use for anchor creation, when not using a hit test.
  75242. * Will default to the session's reference space if not defined
  75243. */
  75244. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75245. /**
  75246. * constructs a new anchor system
  75247. * @param _xrSessionManager an instance of WebXRSessionManager
  75248. * @param _options configuration object for this feature
  75249. */
  75250. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75251. private _tmpVector;
  75252. private _tmpQuaternion;
  75253. private _populateTmpTransformation;
  75254. /**
  75255. * Create a new anchor point using a hit test result at a specific point in the scene
  75256. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75257. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75258. *
  75259. * @param hitTestResult The hit test result to use for this anchor creation
  75260. * @param position an optional position offset for this anchor
  75261. * @param rotationQuaternion an optional rotation offset for this anchor
  75262. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75263. */
  75264. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75265. /**
  75266. * Add a new anchor at a specific position and rotation
  75267. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75268. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75269. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75270. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75271. *
  75272. * @param position the position in which to add an anchor
  75273. * @param rotationQuaternion an optional rotation for the anchor transformation
  75274. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75275. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75276. */
  75277. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75278. /**
  75279. * detach this feature.
  75280. * Will usually be called by the features manager
  75281. *
  75282. * @returns true if successful.
  75283. */
  75284. detach(): boolean;
  75285. /**
  75286. * Dispose this feature and all of the resources attached
  75287. */
  75288. dispose(): void;
  75289. protected _onXRFrame(frame: XRFrame): void;
  75290. /**
  75291. * avoiding using Array.find for global support.
  75292. * @param xrAnchor the plane to find in the array
  75293. */
  75294. private _findIndexInAnchorArray;
  75295. private _updateAnchorWithXRFrame;
  75296. private _createAnchorAtTransformation;
  75297. }
  75298. }
  75299. declare module BABYLON {
  75300. /**
  75301. * Options used in the plane detector module
  75302. */
  75303. export interface IWebXRPlaneDetectorOptions {
  75304. /**
  75305. * The node to use to transform the local results to world coordinates
  75306. */
  75307. worldParentNode?: TransformNode;
  75308. /**
  75309. * If set to true a reference of the created planes will be kept until the next session starts
  75310. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75311. */
  75312. doNotRemovePlanesOnSessionEnded?: boolean;
  75313. }
  75314. /**
  75315. * A babylon interface for a WebXR plane.
  75316. * A Plane is actually a polygon, built from N points in space
  75317. *
  75318. * Supported in chrome 79, not supported in canary 81 ATM
  75319. */
  75320. export interface IWebXRPlane {
  75321. /**
  75322. * a babylon-assigned ID for this polygon
  75323. */
  75324. id: number;
  75325. /**
  75326. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75327. */
  75328. polygonDefinition: Array<Vector3>;
  75329. /**
  75330. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75331. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75332. */
  75333. transformationMatrix: Matrix;
  75334. /**
  75335. * the native xr-plane object
  75336. */
  75337. xrPlane: XRPlane;
  75338. }
  75339. /**
  75340. * The plane detector is used to detect planes in the real world when in AR
  75341. * For more information see https://github.com/immersive-web/real-world-geometry/
  75342. */
  75343. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75344. private _options;
  75345. private _detectedPlanes;
  75346. private _enabled;
  75347. private _lastFrameDetected;
  75348. /**
  75349. * The module's name
  75350. */
  75351. static readonly Name: string;
  75352. /**
  75353. * The (Babylon) version of this module.
  75354. * This is an integer representing the implementation version.
  75355. * This number does not correspond to the WebXR specs version
  75356. */
  75357. static readonly Version: number;
  75358. /**
  75359. * Observers registered here will be executed when a new plane was added to the session
  75360. */
  75361. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75362. /**
  75363. * Observers registered here will be executed when a plane is no longer detected in the session
  75364. */
  75365. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75366. /**
  75367. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75368. * This can execute N times every frame
  75369. */
  75370. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75371. /**
  75372. * construct a new Plane Detector
  75373. * @param _xrSessionManager an instance of xr Session manager
  75374. * @param _options configuration to use when constructing this feature
  75375. */
  75376. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75377. /**
  75378. * detach this feature.
  75379. * Will usually be called by the features manager
  75380. *
  75381. * @returns true if successful.
  75382. */
  75383. detach(): boolean;
  75384. /**
  75385. * Dispose this feature and all of the resources attached
  75386. */
  75387. dispose(): void;
  75388. protected _onXRFrame(frame: XRFrame): void;
  75389. private _init;
  75390. private _updatePlaneWithXRPlane;
  75391. /**
  75392. * avoiding using Array.find for global support.
  75393. * @param xrPlane the plane to find in the array
  75394. */
  75395. private findIndexInPlaneArray;
  75396. }
  75397. }
  75398. declare module BABYLON {
  75399. /**
  75400. * Options interface for the background remover plugin
  75401. */
  75402. export interface IWebXRBackgroundRemoverOptions {
  75403. /**
  75404. * Further background meshes to disable when entering AR
  75405. */
  75406. backgroundMeshes?: AbstractMesh[];
  75407. /**
  75408. * flags to configure the removal of the environment helper.
  75409. * If not set, the entire background will be removed. If set, flags should be set as well.
  75410. */
  75411. environmentHelperRemovalFlags?: {
  75412. /**
  75413. * Should the skybox be removed (default false)
  75414. */
  75415. skyBox?: boolean;
  75416. /**
  75417. * Should the ground be removed (default false)
  75418. */
  75419. ground?: boolean;
  75420. };
  75421. /**
  75422. * don't disable the environment helper
  75423. */
  75424. ignoreEnvironmentHelper?: boolean;
  75425. }
  75426. /**
  75427. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75428. */
  75429. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75430. /**
  75431. * read-only options to be used in this module
  75432. */
  75433. readonly options: IWebXRBackgroundRemoverOptions;
  75434. /**
  75435. * The module's name
  75436. */
  75437. static readonly Name: string;
  75438. /**
  75439. * The (Babylon) version of this module.
  75440. * This is an integer representing the implementation version.
  75441. * This number does not correspond to the WebXR specs version
  75442. */
  75443. static readonly Version: number;
  75444. /**
  75445. * registered observers will be triggered when the background state changes
  75446. */
  75447. onBackgroundStateChangedObservable: Observable<boolean>;
  75448. /**
  75449. * constructs a new background remover module
  75450. * @param _xrSessionManager the session manager for this module
  75451. * @param options read-only options to be used in this module
  75452. */
  75453. constructor(_xrSessionManager: WebXRSessionManager,
  75454. /**
  75455. * read-only options to be used in this module
  75456. */
  75457. options?: IWebXRBackgroundRemoverOptions);
  75458. /**
  75459. * attach this feature
  75460. * Will usually be called by the features manager
  75461. *
  75462. * @returns true if successful.
  75463. */
  75464. attach(): boolean;
  75465. /**
  75466. * detach this feature.
  75467. * Will usually be called by the features manager
  75468. *
  75469. * @returns true if successful.
  75470. */
  75471. detach(): boolean;
  75472. /**
  75473. * Dispose this feature and all of the resources attached
  75474. */
  75475. dispose(): void;
  75476. protected _onXRFrame(_xrFrame: XRFrame): void;
  75477. private _setBackgroundState;
  75478. }
  75479. }
  75480. declare module BABYLON {
  75481. /**
  75482. * Options for the controller physics feature
  75483. */
  75484. export class IWebXRControllerPhysicsOptions {
  75485. /**
  75486. * Should the headset get its own impostor
  75487. */
  75488. enableHeadsetImpostor?: boolean;
  75489. /**
  75490. * Optional parameters for the headset impostor
  75491. */
  75492. headsetImpostorParams?: {
  75493. /**
  75494. * The type of impostor to create. Default is sphere
  75495. */
  75496. impostorType: number;
  75497. /**
  75498. * the size of the impostor. Defaults to 10cm
  75499. */
  75500. impostorSize?: number | {
  75501. width: number;
  75502. height: number;
  75503. depth: number;
  75504. };
  75505. /**
  75506. * Friction definitions
  75507. */
  75508. friction?: number;
  75509. /**
  75510. * Restitution
  75511. */
  75512. restitution?: number;
  75513. };
  75514. /**
  75515. * The physics properties of the future impostors
  75516. */
  75517. physicsProperties?: {
  75518. /**
  75519. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75520. * Note that this requires a physics engine that supports mesh impostors!
  75521. */
  75522. useControllerMesh?: boolean;
  75523. /**
  75524. * The type of impostor to create. Default is sphere
  75525. */
  75526. impostorType?: number;
  75527. /**
  75528. * the size of the impostor. Defaults to 10cm
  75529. */
  75530. impostorSize?: number | {
  75531. width: number;
  75532. height: number;
  75533. depth: number;
  75534. };
  75535. /**
  75536. * Friction definitions
  75537. */
  75538. friction?: number;
  75539. /**
  75540. * Restitution
  75541. */
  75542. restitution?: number;
  75543. };
  75544. /**
  75545. * the xr input to use with this pointer selection
  75546. */
  75547. xrInput: WebXRInput;
  75548. }
  75549. /**
  75550. * Add physics impostor to your webxr controllers,
  75551. * including naive calculation of their linear and angular velocity
  75552. */
  75553. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75554. private readonly _options;
  75555. private _attachController;
  75556. private _controllers;
  75557. private _debugMode;
  75558. private _delta;
  75559. private _headsetImpostor?;
  75560. private _headsetMesh?;
  75561. private _lastTimestamp;
  75562. private _tmpQuaternion;
  75563. private _tmpVector;
  75564. /**
  75565. * The module's name
  75566. */
  75567. static readonly Name: string;
  75568. /**
  75569. * The (Babylon) version of this module.
  75570. * This is an integer representing the implementation version.
  75571. * This number does not correspond to the webxr specs version
  75572. */
  75573. static readonly Version: number;
  75574. /**
  75575. * Construct a new Controller Physics Feature
  75576. * @param _xrSessionManager the corresponding xr session manager
  75577. * @param _options options to create this feature with
  75578. */
  75579. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75580. /**
  75581. * @hidden
  75582. * enable debugging - will show console outputs and the impostor mesh
  75583. */
  75584. _enablePhysicsDebug(): void;
  75585. /**
  75586. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75587. * @param xrController the controller to add
  75588. */
  75589. addController(xrController: WebXRInputSource): void;
  75590. /**
  75591. * attach this feature
  75592. * Will usually be called by the features manager
  75593. *
  75594. * @returns true if successful.
  75595. */
  75596. attach(): boolean;
  75597. /**
  75598. * detach this feature.
  75599. * Will usually be called by the features manager
  75600. *
  75601. * @returns true if successful.
  75602. */
  75603. detach(): boolean;
  75604. /**
  75605. * Get the headset impostor, if enabled
  75606. * @returns the impostor
  75607. */
  75608. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75609. /**
  75610. * Get the physics impostor of a specific controller.
  75611. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75612. * @param controller the controller or the controller id of which to get the impostor
  75613. * @returns the impostor or null
  75614. */
  75615. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75616. /**
  75617. * Update the physics properties provided in the constructor
  75618. * @param newProperties the new properties object
  75619. */
  75620. setPhysicsProperties(newProperties: {
  75621. impostorType?: number;
  75622. impostorSize?: number | {
  75623. width: number;
  75624. height: number;
  75625. depth: number;
  75626. };
  75627. friction?: number;
  75628. restitution?: number;
  75629. }): void;
  75630. protected _onXRFrame(_xrFrame: any): void;
  75631. private _detachController;
  75632. }
  75633. }
  75634. declare module BABYLON {
  75635. /**
  75636. * A babylon interface for a "WebXR" feature point.
  75637. * Represents the position and confidence value of a given feature point.
  75638. */
  75639. export interface IWebXRFeaturePoint {
  75640. /**
  75641. * Represents the position of the feature point in world space.
  75642. */
  75643. position: Vector3;
  75644. /**
  75645. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75646. */
  75647. confidenceValue: number;
  75648. }
  75649. /**
  75650. * The feature point system is used to detect feature points from real world geometry.
  75651. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75652. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75653. */
  75654. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75655. private _enabled;
  75656. private _featurePointCloud;
  75657. /**
  75658. * The module's name
  75659. */
  75660. static readonly Name: string;
  75661. /**
  75662. * The (Babylon) version of this module.
  75663. * This is an integer representing the implementation version.
  75664. * This number does not correspond to the WebXR specs version
  75665. */
  75666. static readonly Version: number;
  75667. /**
  75668. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75669. * Will notify the observers about which feature points have been added.
  75670. */
  75671. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75672. /**
  75673. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75674. * Will notify the observers about which feature points have been updated.
  75675. */
  75676. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75677. /**
  75678. * The current feature point cloud maintained across frames.
  75679. */
  75680. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75681. /**
  75682. * construct the feature point system
  75683. * @param _xrSessionManager an instance of xr Session manager
  75684. */
  75685. constructor(_xrSessionManager: WebXRSessionManager);
  75686. /**
  75687. * Detach this feature.
  75688. * Will usually be called by the features manager
  75689. *
  75690. * @returns true if successful.
  75691. */
  75692. detach(): boolean;
  75693. /**
  75694. * Dispose this feature and all of the resources attached
  75695. */
  75696. dispose(): void;
  75697. /**
  75698. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75699. */
  75700. protected _onXRFrame(frame: XRFrame): void;
  75701. /**
  75702. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75703. */
  75704. private _init;
  75705. }
  75706. }
  75707. declare module BABYLON {
  75708. /**
  75709. * Configuration interface for the hand tracking feature
  75710. */
  75711. export interface IWebXRHandTrackingOptions {
  75712. /**
  75713. * The xrInput that will be used as source for new hands
  75714. */
  75715. xrInput: WebXRInput;
  75716. /**
  75717. * Configuration object for the joint meshes
  75718. */
  75719. jointMeshes?: {
  75720. /**
  75721. * Should the meshes created be invisible (defaults to false)
  75722. */
  75723. invisible?: boolean;
  75724. /**
  75725. * A source mesh to be used to create instances. Defaults to a sphere.
  75726. * This mesh will be the source for all other (25) meshes.
  75727. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75728. */
  75729. sourceMesh?: Mesh;
  75730. /**
  75731. * Should the source mesh stay visible. Defaults to false
  75732. */
  75733. keepOriginalVisible?: boolean;
  75734. /**
  75735. * Scale factor for all instances (defaults to 2)
  75736. */
  75737. scaleFactor?: number;
  75738. /**
  75739. * Should each instance have its own physics impostor
  75740. */
  75741. enablePhysics?: boolean;
  75742. /**
  75743. * If enabled, override default physics properties
  75744. */
  75745. physicsProps?: {
  75746. friction?: number;
  75747. restitution?: number;
  75748. impostorType?: number;
  75749. };
  75750. /**
  75751. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75752. */
  75753. handMesh?: AbstractMesh;
  75754. };
  75755. }
  75756. /**
  75757. * Parts of the hands divided to writs and finger names
  75758. */
  75759. export const enum HandPart {
  75760. /**
  75761. * HandPart - Wrist
  75762. */
  75763. WRIST = "wrist",
  75764. /**
  75765. * HandPart - The THumb
  75766. */
  75767. THUMB = "thumb",
  75768. /**
  75769. * HandPart - Index finger
  75770. */
  75771. INDEX = "index",
  75772. /**
  75773. * HandPart - Middle finger
  75774. */
  75775. MIDDLE = "middle",
  75776. /**
  75777. * HandPart - Ring finger
  75778. */
  75779. RING = "ring",
  75780. /**
  75781. * HandPart - Little finger
  75782. */
  75783. LITTLE = "little"
  75784. }
  75785. /**
  75786. * Representing a single hand (with its corresponding native XRHand object)
  75787. */
  75788. export class WebXRHand implements IDisposable {
  75789. /** the controller to which the hand correlates */
  75790. readonly xrController: WebXRInputSource;
  75791. /** the meshes to be used to track the hand joints */
  75792. readonly trackedMeshes: AbstractMesh[];
  75793. /**
  75794. * Hand-parts definition (key is HandPart)
  75795. */
  75796. handPartsDefinition: {
  75797. [key: string]: number[];
  75798. };
  75799. /**
  75800. * Populate the HandPartsDefinition object.
  75801. * This is called as a side effect since certain browsers don't have XRHand defined.
  75802. */
  75803. private generateHandPartsDefinition;
  75804. /**
  75805. * Construct a new hand object
  75806. * @param xrController the controller to which the hand correlates
  75807. * @param trackedMeshes the meshes to be used to track the hand joints
  75808. */
  75809. constructor(
  75810. /** the controller to which the hand correlates */
  75811. xrController: WebXRInputSource,
  75812. /** the meshes to be used to track the hand joints */
  75813. trackedMeshes: AbstractMesh[]);
  75814. /**
  75815. * Update this hand from the latest xr frame
  75816. * @param xrFrame xrFrame to update from
  75817. * @param referenceSpace The current viewer reference space
  75818. * @param scaleFactor optional scale factor for the meshes
  75819. */
  75820. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75821. /**
  75822. * Get meshes of part of the hand
  75823. * @param part the part of hand to get
  75824. * @returns An array of meshes that correlate to the hand part requested
  75825. */
  75826. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75827. /**
  75828. * Dispose this Hand object
  75829. */
  75830. dispose(): void;
  75831. }
  75832. /**
  75833. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75834. */
  75835. export class WebXRHandTracking extends WebXRAbstractFeature {
  75836. /**
  75837. * options to use when constructing this feature
  75838. */
  75839. readonly options: IWebXRHandTrackingOptions;
  75840. private static _idCounter;
  75841. /**
  75842. * The module's name
  75843. */
  75844. static readonly Name: string;
  75845. /**
  75846. * The (Babylon) version of this module.
  75847. * This is an integer representing the implementation version.
  75848. * This number does not correspond to the WebXR specs version
  75849. */
  75850. static readonly Version: number;
  75851. /**
  75852. * This observable will notify registered observers when a new hand object was added and initialized
  75853. */
  75854. onHandAddedObservable: Observable<WebXRHand>;
  75855. /**
  75856. * This observable will notify its observers right before the hand object is disposed
  75857. */
  75858. onHandRemovedObservable: Observable<WebXRHand>;
  75859. private _hands;
  75860. /**
  75861. * Creates a new instance of the hit test feature
  75862. * @param _xrSessionManager an instance of WebXRSessionManager
  75863. * @param options options to use when constructing this feature
  75864. */
  75865. constructor(_xrSessionManager: WebXRSessionManager,
  75866. /**
  75867. * options to use when constructing this feature
  75868. */
  75869. options: IWebXRHandTrackingOptions);
  75870. /**
  75871. * Check if the needed objects are defined.
  75872. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  75873. */
  75874. isCompatible(): boolean;
  75875. /**
  75876. * attach this feature
  75877. * Will usually be called by the features manager
  75878. *
  75879. * @returns true if successful.
  75880. */
  75881. attach(): boolean;
  75882. /**
  75883. * detach this feature.
  75884. * Will usually be called by the features manager
  75885. *
  75886. * @returns true if successful.
  75887. */
  75888. detach(): boolean;
  75889. /**
  75890. * Dispose this feature and all of the resources attached
  75891. */
  75892. dispose(): void;
  75893. /**
  75894. * Get the hand object according to the controller id
  75895. * @param controllerId the controller id to which we want to get the hand
  75896. * @returns null if not found or the WebXRHand object if found
  75897. */
  75898. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  75899. /**
  75900. * Get a hand object according to the requested handedness
  75901. * @param handedness the handedness to request
  75902. * @returns null if not found or the WebXRHand object if found
  75903. */
  75904. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  75905. protected _onXRFrame(_xrFrame: XRFrame): void;
  75906. private _attachHand;
  75907. private _detachHand;
  75908. }
  75909. }
  75910. declare module BABYLON {
  75911. /**
  75912. * The motion controller class for all microsoft mixed reality controllers
  75913. */
  75914. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  75915. protected readonly _mapping: {
  75916. defaultButton: {
  75917. valueNodeName: string;
  75918. unpressedNodeName: string;
  75919. pressedNodeName: string;
  75920. };
  75921. defaultAxis: {
  75922. valueNodeName: string;
  75923. minNodeName: string;
  75924. maxNodeName: string;
  75925. };
  75926. buttons: {
  75927. "xr-standard-trigger": {
  75928. rootNodeName: string;
  75929. componentProperty: string;
  75930. states: string[];
  75931. };
  75932. "xr-standard-squeeze": {
  75933. rootNodeName: string;
  75934. componentProperty: string;
  75935. states: string[];
  75936. };
  75937. "xr-standard-touchpad": {
  75938. rootNodeName: string;
  75939. labelAnchorNodeName: string;
  75940. touchPointNodeName: string;
  75941. };
  75942. "xr-standard-thumbstick": {
  75943. rootNodeName: string;
  75944. componentProperty: string;
  75945. states: string[];
  75946. };
  75947. };
  75948. axes: {
  75949. "xr-standard-touchpad": {
  75950. "x-axis": {
  75951. rootNodeName: string;
  75952. };
  75953. "y-axis": {
  75954. rootNodeName: string;
  75955. };
  75956. };
  75957. "xr-standard-thumbstick": {
  75958. "x-axis": {
  75959. rootNodeName: string;
  75960. };
  75961. "y-axis": {
  75962. rootNodeName: string;
  75963. };
  75964. };
  75965. };
  75966. };
  75967. /**
  75968. * The base url used to load the left and right controller models
  75969. */
  75970. static MODEL_BASE_URL: string;
  75971. /**
  75972. * The name of the left controller model file
  75973. */
  75974. static MODEL_LEFT_FILENAME: string;
  75975. /**
  75976. * The name of the right controller model file
  75977. */
  75978. static MODEL_RIGHT_FILENAME: string;
  75979. profileId: string;
  75980. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  75981. protected _getFilenameAndPath(): {
  75982. filename: string;
  75983. path: string;
  75984. };
  75985. protected _getModelLoadingConstraints(): boolean;
  75986. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  75987. protected _setRootMesh(meshes: AbstractMesh[]): void;
  75988. protected _updateModel(): void;
  75989. }
  75990. }
  75991. declare module BABYLON {
  75992. /**
  75993. * The motion controller class for oculus touch (quest, rift).
  75994. * This class supports legacy mapping as well the standard xr mapping
  75995. */
  75996. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  75997. private _forceLegacyControllers;
  75998. private _modelRootNode;
  75999. /**
  76000. * The base url used to load the left and right controller models
  76001. */
  76002. static MODEL_BASE_URL: string;
  76003. /**
  76004. * The name of the left controller model file
  76005. */
  76006. static MODEL_LEFT_FILENAME: string;
  76007. /**
  76008. * The name of the right controller model file
  76009. */
  76010. static MODEL_RIGHT_FILENAME: string;
  76011. /**
  76012. * Base Url for the Quest controller model.
  76013. */
  76014. static QUEST_MODEL_BASE_URL: string;
  76015. profileId: string;
  76016. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76017. protected _getFilenameAndPath(): {
  76018. filename: string;
  76019. path: string;
  76020. };
  76021. protected _getModelLoadingConstraints(): boolean;
  76022. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76023. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76024. protected _updateModel(): void;
  76025. /**
  76026. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76027. * between the touch and touch 2.
  76028. */
  76029. private _isQuest;
  76030. }
  76031. }
  76032. declare module BABYLON {
  76033. /**
  76034. * The motion controller class for the standard HTC-Vive controllers
  76035. */
  76036. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76037. private _modelRootNode;
  76038. /**
  76039. * The base url used to load the left and right controller models
  76040. */
  76041. static MODEL_BASE_URL: string;
  76042. /**
  76043. * File name for the controller model.
  76044. */
  76045. static MODEL_FILENAME: string;
  76046. profileId: string;
  76047. /**
  76048. * Create a new Vive motion controller object
  76049. * @param scene the scene to use to create this controller
  76050. * @param gamepadObject the corresponding gamepad object
  76051. * @param handedness the handedness of the controller
  76052. */
  76053. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76054. protected _getFilenameAndPath(): {
  76055. filename: string;
  76056. path: string;
  76057. };
  76058. protected _getModelLoadingConstraints(): boolean;
  76059. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76060. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76061. protected _updateModel(): void;
  76062. }
  76063. }
  76064. declare module BABYLON {
  76065. /**
  76066. * A cursor which tracks a point on a path
  76067. */
  76068. export class PathCursor {
  76069. private path;
  76070. /**
  76071. * Stores path cursor callbacks for when an onchange event is triggered
  76072. */
  76073. private _onchange;
  76074. /**
  76075. * The value of the path cursor
  76076. */
  76077. value: number;
  76078. /**
  76079. * The animation array of the path cursor
  76080. */
  76081. animations: Animation[];
  76082. /**
  76083. * Initializes the path cursor
  76084. * @param path The path to track
  76085. */
  76086. constructor(path: Path2);
  76087. /**
  76088. * Gets the cursor point on the path
  76089. * @returns A point on the path cursor at the cursor location
  76090. */
  76091. getPoint(): Vector3;
  76092. /**
  76093. * Moves the cursor ahead by the step amount
  76094. * @param step The amount to move the cursor forward
  76095. * @returns This path cursor
  76096. */
  76097. moveAhead(step?: number): PathCursor;
  76098. /**
  76099. * Moves the cursor behind by the step amount
  76100. * @param step The amount to move the cursor back
  76101. * @returns This path cursor
  76102. */
  76103. moveBack(step?: number): PathCursor;
  76104. /**
  76105. * Moves the cursor by the step amount
  76106. * If the step amount is greater than one, an exception is thrown
  76107. * @param step The amount to move the cursor
  76108. * @returns This path cursor
  76109. */
  76110. move(step: number): PathCursor;
  76111. /**
  76112. * Ensures that the value is limited between zero and one
  76113. * @returns This path cursor
  76114. */
  76115. private ensureLimits;
  76116. /**
  76117. * Runs onchange callbacks on change (used by the animation engine)
  76118. * @returns This path cursor
  76119. */
  76120. private raiseOnChange;
  76121. /**
  76122. * Executes a function on change
  76123. * @param f A path cursor onchange callback
  76124. * @returns This path cursor
  76125. */
  76126. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76127. }
  76128. }
  76129. declare module BABYLON {
  76130. /** @hidden */
  76131. export var blurPixelShader: {
  76132. name: string;
  76133. shader: string;
  76134. };
  76135. }
  76136. declare module BABYLON {
  76137. /** @hidden */
  76138. export var pointCloudVertexDeclaration: {
  76139. name: string;
  76140. shader: string;
  76141. };
  76142. }
  76143. // Mixins
  76144. interface Window {
  76145. mozIndexedDB: IDBFactory;
  76146. webkitIndexedDB: IDBFactory;
  76147. msIndexedDB: IDBFactory;
  76148. webkitURL: typeof URL;
  76149. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76150. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76151. WebGLRenderingContext: WebGLRenderingContext;
  76152. MSGesture: MSGesture;
  76153. CANNON: any;
  76154. AudioContext: AudioContext;
  76155. webkitAudioContext: AudioContext;
  76156. PointerEvent: any;
  76157. Math: Math;
  76158. Uint8Array: Uint8ArrayConstructor;
  76159. Float32Array: Float32ArrayConstructor;
  76160. mozURL: typeof URL;
  76161. msURL: typeof URL;
  76162. VRFrameData: any; // WebVR, from specs 1.1
  76163. DracoDecoderModule: any;
  76164. setImmediate(handler: (...args: any[]) => void): number;
  76165. }
  76166. interface HTMLCanvasElement {
  76167. requestPointerLock(): void;
  76168. msRequestPointerLock?(): void;
  76169. mozRequestPointerLock?(): void;
  76170. webkitRequestPointerLock?(): void;
  76171. /** Track wether a record is in progress */
  76172. isRecording: boolean;
  76173. /** Capture Stream method defined by some browsers */
  76174. captureStream(fps?: number): MediaStream;
  76175. }
  76176. interface CanvasRenderingContext2D {
  76177. msImageSmoothingEnabled: boolean;
  76178. }
  76179. interface MouseEvent {
  76180. mozMovementX: number;
  76181. mozMovementY: number;
  76182. webkitMovementX: number;
  76183. webkitMovementY: number;
  76184. msMovementX: number;
  76185. msMovementY: number;
  76186. }
  76187. interface Navigator {
  76188. mozGetVRDevices: (any: any) => any;
  76189. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76190. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76191. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76192. webkitGetGamepads(): Gamepad[];
  76193. msGetGamepads(): Gamepad[];
  76194. webkitGamepads(): Gamepad[];
  76195. }
  76196. interface HTMLVideoElement {
  76197. mozSrcObject: any;
  76198. }
  76199. interface Math {
  76200. fround(x: number): number;
  76201. imul(a: number, b: number): number;
  76202. }
  76203. interface WebGLRenderingContext {
  76204. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76205. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76206. vertexAttribDivisor(index: number, divisor: number): void;
  76207. createVertexArray(): any;
  76208. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76209. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76210. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76211. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76212. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76213. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76214. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76215. // Queries
  76216. createQuery(): WebGLQuery;
  76217. deleteQuery(query: WebGLQuery): void;
  76218. beginQuery(target: number, query: WebGLQuery): void;
  76219. endQuery(target: number): void;
  76220. getQueryParameter(query: WebGLQuery, pname: number): any;
  76221. getQuery(target: number, pname: number): any;
  76222. MAX_SAMPLES: number;
  76223. RGBA8: number;
  76224. READ_FRAMEBUFFER: number;
  76225. DRAW_FRAMEBUFFER: number;
  76226. UNIFORM_BUFFER: number;
  76227. HALF_FLOAT_OES: number;
  76228. RGBA16F: number;
  76229. RGBA32F: number;
  76230. R32F: number;
  76231. RG32F: number;
  76232. RGB32F: number;
  76233. R16F: number;
  76234. RG16F: number;
  76235. RGB16F: number;
  76236. RED: number;
  76237. RG: number;
  76238. R8: number;
  76239. RG8: number;
  76240. UNSIGNED_INT_24_8: number;
  76241. DEPTH24_STENCIL8: number;
  76242. MIN: number;
  76243. MAX: number;
  76244. /* Multiple Render Targets */
  76245. drawBuffers(buffers: number[]): void;
  76246. readBuffer(src: number): void;
  76247. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76248. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76249. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76250. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76251. // Occlusion Query
  76252. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76253. ANY_SAMPLES_PASSED: number;
  76254. QUERY_RESULT_AVAILABLE: number;
  76255. QUERY_RESULT: number;
  76256. }
  76257. interface WebGLProgram {
  76258. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76259. }
  76260. interface EXT_disjoint_timer_query {
  76261. QUERY_COUNTER_BITS_EXT: number;
  76262. TIME_ELAPSED_EXT: number;
  76263. TIMESTAMP_EXT: number;
  76264. GPU_DISJOINT_EXT: number;
  76265. QUERY_RESULT_EXT: number;
  76266. QUERY_RESULT_AVAILABLE_EXT: number;
  76267. queryCounterEXT(query: WebGLQuery, target: number): void;
  76268. createQueryEXT(): WebGLQuery;
  76269. beginQueryEXT(target: number, query: WebGLQuery): void;
  76270. endQueryEXT(target: number): void;
  76271. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76272. deleteQueryEXT(query: WebGLQuery): void;
  76273. }
  76274. interface WebGLUniformLocation {
  76275. _currentState: any;
  76276. }
  76277. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76278. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76279. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76280. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76281. interface WebGLRenderingContext {
  76282. readonly RASTERIZER_DISCARD: number;
  76283. readonly DEPTH_COMPONENT24: number;
  76284. readonly TEXTURE_3D: number;
  76285. readonly TEXTURE_2D_ARRAY: number;
  76286. readonly TEXTURE_COMPARE_FUNC: number;
  76287. readonly TEXTURE_COMPARE_MODE: number;
  76288. readonly COMPARE_REF_TO_TEXTURE: number;
  76289. readonly TEXTURE_WRAP_R: number;
  76290. readonly HALF_FLOAT: number;
  76291. readonly RGB8: number;
  76292. readonly RED_INTEGER: number;
  76293. readonly RG_INTEGER: number;
  76294. readonly RGB_INTEGER: number;
  76295. readonly RGBA_INTEGER: number;
  76296. readonly R8_SNORM: number;
  76297. readonly RG8_SNORM: number;
  76298. readonly RGB8_SNORM: number;
  76299. readonly RGBA8_SNORM: number;
  76300. readonly R8I: number;
  76301. readonly RG8I: number;
  76302. readonly RGB8I: number;
  76303. readonly RGBA8I: number;
  76304. readonly R8UI: number;
  76305. readonly RG8UI: number;
  76306. readonly RGB8UI: number;
  76307. readonly RGBA8UI: number;
  76308. readonly R16I: number;
  76309. readonly RG16I: number;
  76310. readonly RGB16I: number;
  76311. readonly RGBA16I: number;
  76312. readonly R16UI: number;
  76313. readonly RG16UI: number;
  76314. readonly RGB16UI: number;
  76315. readonly RGBA16UI: number;
  76316. readonly R32I: number;
  76317. readonly RG32I: number;
  76318. readonly RGB32I: number;
  76319. readonly RGBA32I: number;
  76320. readonly R32UI: number;
  76321. readonly RG32UI: number;
  76322. readonly RGB32UI: number;
  76323. readonly RGBA32UI: number;
  76324. readonly RGB10_A2UI: number;
  76325. readonly R11F_G11F_B10F: number;
  76326. readonly RGB9_E5: number;
  76327. readonly RGB10_A2: number;
  76328. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76329. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76330. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76331. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76332. readonly DEPTH_COMPONENT32F: number;
  76333. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76334. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76335. 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;
  76336. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76337. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76338. readonly TRANSFORM_FEEDBACK: number;
  76339. readonly INTERLEAVED_ATTRIBS: number;
  76340. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76341. createTransformFeedback(): WebGLTransformFeedback;
  76342. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76343. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76344. beginTransformFeedback(primitiveMode: number): void;
  76345. endTransformFeedback(): void;
  76346. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76347. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76348. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76349. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76350. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76351. }
  76352. interface ImageBitmap {
  76353. readonly width: number;
  76354. readonly height: number;
  76355. close(): void;
  76356. }
  76357. interface WebGLQuery extends WebGLObject {
  76358. }
  76359. declare var WebGLQuery: {
  76360. prototype: WebGLQuery;
  76361. new(): WebGLQuery;
  76362. };
  76363. interface WebGLSampler extends WebGLObject {
  76364. }
  76365. declare var WebGLSampler: {
  76366. prototype: WebGLSampler;
  76367. new(): WebGLSampler;
  76368. };
  76369. interface WebGLSync extends WebGLObject {
  76370. }
  76371. declare var WebGLSync: {
  76372. prototype: WebGLSync;
  76373. new(): WebGLSync;
  76374. };
  76375. interface WebGLTransformFeedback extends WebGLObject {
  76376. }
  76377. declare var WebGLTransformFeedback: {
  76378. prototype: WebGLTransformFeedback;
  76379. new(): WebGLTransformFeedback;
  76380. };
  76381. interface WebGLVertexArrayObject extends WebGLObject {
  76382. }
  76383. declare var WebGLVertexArrayObject: {
  76384. prototype: WebGLVertexArrayObject;
  76385. new(): WebGLVertexArrayObject;
  76386. };
  76387. // Type definitions for WebVR API
  76388. // Project: https://w3c.github.io/webvr/
  76389. // Definitions by: six a <https://github.com/lostfictions>
  76390. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76391. interface VRDisplay extends EventTarget {
  76392. /**
  76393. * Dictionary of capabilities describing the VRDisplay.
  76394. */
  76395. readonly capabilities: VRDisplayCapabilities;
  76396. /**
  76397. * z-depth defining the far plane of the eye view frustum
  76398. * enables mapping of values in the render target depth
  76399. * attachment to scene coordinates. Initially set to 10000.0.
  76400. */
  76401. depthFar: number;
  76402. /**
  76403. * z-depth defining the near plane of the eye view frustum
  76404. * enables mapping of values in the render target depth
  76405. * attachment to scene coordinates. Initially set to 0.01.
  76406. */
  76407. depthNear: number;
  76408. /**
  76409. * An identifier for this distinct VRDisplay. Used as an
  76410. * association point in the Gamepad API.
  76411. */
  76412. readonly displayId: number;
  76413. /**
  76414. * A display name, a user-readable name identifying it.
  76415. */
  76416. readonly displayName: string;
  76417. readonly isConnected: boolean;
  76418. readonly isPresenting: boolean;
  76419. /**
  76420. * If this VRDisplay supports room-scale experiences, the optional
  76421. * stage attribute contains details on the room-scale parameters.
  76422. */
  76423. readonly stageParameters: VRStageParameters | null;
  76424. /**
  76425. * Passing the value returned by `requestAnimationFrame` to
  76426. * `cancelAnimationFrame` will unregister the callback.
  76427. * @param handle Define the hanle of the request to cancel
  76428. */
  76429. cancelAnimationFrame(handle: number): void;
  76430. /**
  76431. * Stops presenting to the VRDisplay.
  76432. * @returns a promise to know when it stopped
  76433. */
  76434. exitPresent(): Promise<void>;
  76435. /**
  76436. * Return the current VREyeParameters for the given eye.
  76437. * @param whichEye Define the eye we want the parameter for
  76438. * @returns the eye parameters
  76439. */
  76440. getEyeParameters(whichEye: string): VREyeParameters;
  76441. /**
  76442. * Populates the passed VRFrameData with the information required to render
  76443. * the current frame.
  76444. * @param frameData Define the data structure to populate
  76445. * @returns true if ok otherwise false
  76446. */
  76447. getFrameData(frameData: VRFrameData): boolean;
  76448. /**
  76449. * Get the layers currently being presented.
  76450. * @returns the list of VR layers
  76451. */
  76452. getLayers(): VRLayer[];
  76453. /**
  76454. * Return a VRPose containing the future predicted pose of the VRDisplay
  76455. * when the current frame will be presented. The value returned will not
  76456. * change until JavaScript has returned control to the browser.
  76457. *
  76458. * The VRPose will contain the position, orientation, velocity,
  76459. * and acceleration of each of these properties.
  76460. * @returns the pose object
  76461. */
  76462. getPose(): VRPose;
  76463. /**
  76464. * Return the current instantaneous pose of the VRDisplay, with no
  76465. * prediction applied.
  76466. * @returns the current instantaneous pose
  76467. */
  76468. getImmediatePose(): VRPose;
  76469. /**
  76470. * The callback passed to `requestAnimationFrame` will be called
  76471. * any time a new frame should be rendered. When the VRDisplay is
  76472. * presenting the callback will be called at the native refresh
  76473. * rate of the HMD. When not presenting this function acts
  76474. * identically to how window.requestAnimationFrame acts. Content should
  76475. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76476. * asynchronously from other displays and at differing refresh rates.
  76477. * @param callback Define the eaction to run next frame
  76478. * @returns the request handle it
  76479. */
  76480. requestAnimationFrame(callback: FrameRequestCallback): number;
  76481. /**
  76482. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76483. * Repeat calls while already presenting will update the VRLayers being displayed.
  76484. * @param layers Define the list of layer to present
  76485. * @returns a promise to know when the request has been fulfilled
  76486. */
  76487. requestPresent(layers: VRLayer[]): Promise<void>;
  76488. /**
  76489. * Reset the pose for this display, treating its current position and
  76490. * orientation as the "origin/zero" values. VRPose.position,
  76491. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76492. * updated when calling resetPose(). This should be called in only
  76493. * sitting-space experiences.
  76494. */
  76495. resetPose(): void;
  76496. /**
  76497. * The VRLayer provided to the VRDisplay will be captured and presented
  76498. * in the HMD. Calling this function has the same effect on the source
  76499. * canvas as any other operation that uses its source image, and canvases
  76500. * created without preserveDrawingBuffer set to true will be cleared.
  76501. * @param pose Define the pose to submit
  76502. */
  76503. submitFrame(pose?: VRPose): void;
  76504. }
  76505. declare var VRDisplay: {
  76506. prototype: VRDisplay;
  76507. new(): VRDisplay;
  76508. };
  76509. interface VRLayer {
  76510. leftBounds?: number[] | Float32Array | null;
  76511. rightBounds?: number[] | Float32Array | null;
  76512. source?: HTMLCanvasElement | null;
  76513. }
  76514. interface VRDisplayCapabilities {
  76515. readonly canPresent: boolean;
  76516. readonly hasExternalDisplay: boolean;
  76517. readonly hasOrientation: boolean;
  76518. readonly hasPosition: boolean;
  76519. readonly maxLayers: number;
  76520. }
  76521. interface VREyeParameters {
  76522. /** @deprecated */
  76523. readonly fieldOfView: VRFieldOfView;
  76524. readonly offset: Float32Array;
  76525. readonly renderHeight: number;
  76526. readonly renderWidth: number;
  76527. }
  76528. interface VRFieldOfView {
  76529. readonly downDegrees: number;
  76530. readonly leftDegrees: number;
  76531. readonly rightDegrees: number;
  76532. readonly upDegrees: number;
  76533. }
  76534. interface VRFrameData {
  76535. readonly leftProjectionMatrix: Float32Array;
  76536. readonly leftViewMatrix: Float32Array;
  76537. readonly pose: VRPose;
  76538. readonly rightProjectionMatrix: Float32Array;
  76539. readonly rightViewMatrix: Float32Array;
  76540. readonly timestamp: number;
  76541. }
  76542. interface VRPose {
  76543. readonly angularAcceleration: Float32Array | null;
  76544. readonly angularVelocity: Float32Array | null;
  76545. readonly linearAcceleration: Float32Array | null;
  76546. readonly linearVelocity: Float32Array | null;
  76547. readonly orientation: Float32Array | null;
  76548. readonly position: Float32Array | null;
  76549. readonly timestamp: number;
  76550. }
  76551. interface VRStageParameters {
  76552. sittingToStandingTransform?: Float32Array;
  76553. sizeX?: number;
  76554. sizeY?: number;
  76555. }
  76556. interface Navigator {
  76557. getVRDisplays(): Promise<VRDisplay[]>;
  76558. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76559. }
  76560. interface Window {
  76561. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76562. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76563. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76564. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76565. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76566. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76567. }
  76568. interface Gamepad {
  76569. readonly displayId: number;
  76570. }
  76571. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76572. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76573. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76574. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76575. type XRHandedness = "none" | "left" | "right";
  76576. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76577. type XREye = "none" | "left" | "right";
  76578. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76579. interface XRSpace extends EventTarget {}
  76580. interface XRRenderState {
  76581. depthNear?: number;
  76582. depthFar?: number;
  76583. inlineVerticalFieldOfView?: number;
  76584. baseLayer?: XRWebGLLayer;
  76585. }
  76586. interface XRInputSource {
  76587. handedness: XRHandedness;
  76588. targetRayMode: XRTargetRayMode;
  76589. targetRaySpace: XRSpace;
  76590. gripSpace: XRSpace | undefined;
  76591. gamepad: Gamepad | undefined;
  76592. profiles: Array<string>;
  76593. hand: XRHand | undefined;
  76594. }
  76595. interface XRSessionInit {
  76596. optionalFeatures?: string[];
  76597. requiredFeatures?: string[];
  76598. }
  76599. interface XRSession {
  76600. addEventListener: Function;
  76601. removeEventListener: Function;
  76602. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76603. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76604. requestAnimationFrame: Function;
  76605. end(): Promise<void>;
  76606. renderState: XRRenderState;
  76607. inputSources: Array<XRInputSource>;
  76608. // hit test
  76609. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76610. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76611. // legacy AR hit test
  76612. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76613. // legacy plane detection
  76614. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76615. }
  76616. interface XRReferenceSpace extends XRSpace {
  76617. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76618. onreset: any;
  76619. }
  76620. type XRPlaneSet = Set<XRPlane>;
  76621. type XRAnchorSet = Set<XRAnchor>;
  76622. interface XRFrame {
  76623. session: XRSession;
  76624. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76625. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76626. // AR
  76627. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76628. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76629. // Anchors
  76630. trackedAnchors?: XRAnchorSet;
  76631. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76632. // Planes
  76633. worldInformation: {
  76634. detectedPlanes?: XRPlaneSet;
  76635. };
  76636. // Hand tracking
  76637. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76638. }
  76639. interface XRViewerPose extends XRPose {
  76640. views: Array<XRView>;
  76641. }
  76642. interface XRPose {
  76643. transform: XRRigidTransform;
  76644. emulatedPosition: boolean;
  76645. }
  76646. interface XRWebGLLayerOptions {
  76647. antialias?: boolean;
  76648. depth?: boolean;
  76649. stencil?: boolean;
  76650. alpha?: boolean;
  76651. multiview?: boolean;
  76652. framebufferScaleFactor?: number;
  76653. }
  76654. declare var XRWebGLLayer: {
  76655. prototype: XRWebGLLayer;
  76656. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76657. };
  76658. interface XRWebGLLayer {
  76659. framebuffer: WebGLFramebuffer;
  76660. framebufferWidth: number;
  76661. framebufferHeight: number;
  76662. getViewport: Function;
  76663. }
  76664. declare class XRRigidTransform {
  76665. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76666. position: DOMPointReadOnly;
  76667. orientation: DOMPointReadOnly;
  76668. matrix: Float32Array;
  76669. inverse: XRRigidTransform;
  76670. }
  76671. interface XRView {
  76672. eye: XREye;
  76673. projectionMatrix: Float32Array;
  76674. transform: XRRigidTransform;
  76675. }
  76676. interface XRInputSourceChangeEvent {
  76677. session: XRSession;
  76678. removed: Array<XRInputSource>;
  76679. added: Array<XRInputSource>;
  76680. }
  76681. interface XRInputSourceEvent extends Event {
  76682. readonly frame: XRFrame;
  76683. readonly inputSource: XRInputSource;
  76684. }
  76685. // Experimental(er) features
  76686. declare class XRRay {
  76687. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76688. origin: DOMPointReadOnly;
  76689. direction: DOMPointReadOnly;
  76690. matrix: Float32Array;
  76691. }
  76692. declare enum XRHitTestTrackableType {
  76693. "point",
  76694. "plane",
  76695. "mesh",
  76696. }
  76697. interface XRHitResult {
  76698. hitMatrix: Float32Array;
  76699. }
  76700. interface XRTransientInputHitTestResult {
  76701. readonly inputSource: XRInputSource;
  76702. readonly results: Array<XRHitTestResult>;
  76703. }
  76704. interface XRHitTestResult {
  76705. getPose(baseSpace: XRSpace): XRPose | undefined;
  76706. // When anchor system is enabled
  76707. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76708. }
  76709. interface XRHitTestSource {
  76710. cancel(): void;
  76711. }
  76712. interface XRTransientInputHitTestSource {
  76713. cancel(): void;
  76714. }
  76715. interface XRHitTestOptionsInit {
  76716. space: XRSpace;
  76717. entityTypes?: Array<XRHitTestTrackableType>;
  76718. offsetRay?: XRRay;
  76719. }
  76720. interface XRTransientInputHitTestOptionsInit {
  76721. profile: string;
  76722. entityTypes?: Array<XRHitTestTrackableType>;
  76723. offsetRay?: XRRay;
  76724. }
  76725. interface XRAnchor {
  76726. anchorSpace: XRSpace;
  76727. delete(): void;
  76728. }
  76729. interface XRPlane {
  76730. orientation: "Horizontal" | "Vertical";
  76731. planeSpace: XRSpace;
  76732. polygon: Array<DOMPointReadOnly>;
  76733. lastChangedTime: number;
  76734. }
  76735. interface XRJointSpace extends XRSpace {}
  76736. interface XRJointPose extends XRPose {
  76737. radius: number | undefined;
  76738. }
  76739. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76740. readonly length: number;
  76741. [index: number]: XRJointSpace;
  76742. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76743. readonly WRIST: number;
  76744. readonly THUMB_METACARPAL: number;
  76745. readonly THUMB_PHALANX_PROXIMAL: number;
  76746. readonly THUMB_PHALANX_DISTAL: number;
  76747. readonly THUMB_PHALANX_TIP: number;
  76748. readonly INDEX_METACARPAL: number;
  76749. readonly INDEX_PHALANX_PROXIMAL: number;
  76750. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76751. readonly INDEX_PHALANX_DISTAL: number;
  76752. readonly INDEX_PHALANX_TIP: number;
  76753. readonly MIDDLE_METACARPAL: number;
  76754. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76755. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76756. readonly MIDDLE_PHALANX_DISTAL: number;
  76757. readonly MIDDLE_PHALANX_TIP: number;
  76758. readonly RING_METACARPAL: number;
  76759. readonly RING_PHALANX_PROXIMAL: number;
  76760. readonly RING_PHALANX_INTERMEDIATE: number;
  76761. readonly RING_PHALANX_DISTAL: number;
  76762. readonly RING_PHALANX_TIP: number;
  76763. readonly LITTLE_METACARPAL: number;
  76764. readonly LITTLE_PHALANX_PROXIMAL: number;
  76765. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76766. readonly LITTLE_PHALANX_DISTAL: number;
  76767. readonly LITTLE_PHALANX_TIP: number;
  76768. }
  76769. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76770. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76771. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76772. interface XRSession {
  76773. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76774. }
  76775. interface XRFrame {
  76776. featurePointCloud? : Array<number>;
  76777. }
  76778. /**
  76779. * @ignore
  76780. */
  76781. declare module BABYLON.GLTF2.Exporter {
  76782. }
  76783. /**
  76784. * @ignore
  76785. */
  76786. declare module BABYLON.GLTF1 {
  76787. }
  76788. declare module BABYLON.GUI {
  76789. /**
  76790. * Class used to specific a value and its associated unit
  76791. */
  76792. export class ValueAndUnit {
  76793. /** defines the unit to store */
  76794. unit: number;
  76795. /** defines a boolean indicating if the value can be negative */
  76796. negativeValueAllowed: boolean;
  76797. private _value;
  76798. private _originalUnit;
  76799. /**
  76800. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76801. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76802. */
  76803. ignoreAdaptiveScaling: boolean;
  76804. /**
  76805. * Creates a new ValueAndUnit
  76806. * @param value defines the value to store
  76807. * @param unit defines the unit to store
  76808. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76809. */
  76810. constructor(value: number,
  76811. /** defines the unit to store */
  76812. unit?: number,
  76813. /** defines a boolean indicating if the value can be negative */
  76814. negativeValueAllowed?: boolean);
  76815. /** Gets a boolean indicating if the value is a percentage */
  76816. get isPercentage(): boolean;
  76817. /** Gets a boolean indicating if the value is store as pixel */
  76818. get isPixel(): boolean;
  76819. /** Gets direct internal value */
  76820. get internalValue(): number;
  76821. /**
  76822. * Gets value as pixel
  76823. * @param host defines the root host
  76824. * @param refValue defines the reference value for percentages
  76825. * @returns the value as pixel
  76826. */
  76827. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76828. /**
  76829. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76830. * @param value defines the value to store
  76831. * @param unit defines the unit to store
  76832. * @returns the current ValueAndUnit
  76833. */
  76834. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76835. /**
  76836. * Gets the value accordingly to its unit
  76837. * @param host defines the root host
  76838. * @returns the value
  76839. */
  76840. getValue(host: AdvancedDynamicTexture): number;
  76841. /**
  76842. * Gets a string representation of the value
  76843. * @param host defines the root host
  76844. * @param decimals defines an optional number of decimals to display
  76845. * @returns a string
  76846. */
  76847. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  76848. /**
  76849. * Store a value parsed from a string
  76850. * @param source defines the source string
  76851. * @returns true if the value was successfully parsed
  76852. */
  76853. fromString(source: string | number): boolean;
  76854. private static _Regex;
  76855. private static _UNITMODE_PERCENTAGE;
  76856. private static _UNITMODE_PIXEL;
  76857. /** UNITMODE_PERCENTAGE */
  76858. static get UNITMODE_PERCENTAGE(): number;
  76859. /** UNITMODE_PIXEL */
  76860. static get UNITMODE_PIXEL(): number;
  76861. }
  76862. }
  76863. declare module BABYLON.GUI {
  76864. /**
  76865. * Define a style used by control to automatically setup properties based on a template.
  76866. * Only support font related properties so far
  76867. */
  76868. export class Style implements BABYLON.IDisposable {
  76869. private _fontFamily;
  76870. private _fontStyle;
  76871. private _fontWeight;
  76872. /** @hidden */
  76873. _host: AdvancedDynamicTexture;
  76874. /** @hidden */
  76875. _fontSize: ValueAndUnit;
  76876. /**
  76877. * BABYLON.Observable raised when the style values are changed
  76878. */
  76879. onChangedObservable: BABYLON.Observable<Style>;
  76880. /**
  76881. * Creates a new style object
  76882. * @param host defines the AdvancedDynamicTexture which hosts this style
  76883. */
  76884. constructor(host: AdvancedDynamicTexture);
  76885. /**
  76886. * Gets or sets the font size
  76887. */
  76888. get fontSize(): string | number;
  76889. set fontSize(value: string | number);
  76890. /**
  76891. * Gets or sets the font family
  76892. */
  76893. get fontFamily(): string;
  76894. set fontFamily(value: string);
  76895. /**
  76896. * Gets or sets the font style
  76897. */
  76898. get fontStyle(): string;
  76899. set fontStyle(value: string);
  76900. /** Gets or sets font weight */
  76901. get fontWeight(): string;
  76902. set fontWeight(value: string);
  76903. /** Dispose all associated resources */
  76904. dispose(): void;
  76905. }
  76906. }
  76907. declare module BABYLON.GUI {
  76908. /**
  76909. * Class used to transport BABYLON.Vector2 information for pointer events
  76910. */
  76911. export class Vector2WithInfo extends BABYLON.Vector2 {
  76912. /** defines the current mouse button index */
  76913. buttonIndex: number;
  76914. /**
  76915. * Creates a new Vector2WithInfo
  76916. * @param source defines the vector2 data to transport
  76917. * @param buttonIndex defines the current mouse button index
  76918. */
  76919. constructor(source: BABYLON.Vector2,
  76920. /** defines the current mouse button index */
  76921. buttonIndex?: number);
  76922. }
  76923. /** Class used to provide 2D matrix features */
  76924. export class Matrix2D {
  76925. /** Gets the internal array of 6 floats used to store matrix data */
  76926. m: Float32Array;
  76927. /**
  76928. * Creates a new matrix
  76929. * @param m00 defines value for (0, 0)
  76930. * @param m01 defines value for (0, 1)
  76931. * @param m10 defines value for (1, 0)
  76932. * @param m11 defines value for (1, 1)
  76933. * @param m20 defines value for (2, 0)
  76934. * @param m21 defines value for (2, 1)
  76935. */
  76936. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  76937. /**
  76938. * Fills the matrix from direct values
  76939. * @param m00 defines value for (0, 0)
  76940. * @param m01 defines value for (0, 1)
  76941. * @param m10 defines value for (1, 0)
  76942. * @param m11 defines value for (1, 1)
  76943. * @param m20 defines value for (2, 0)
  76944. * @param m21 defines value for (2, 1)
  76945. * @returns the current modified matrix
  76946. */
  76947. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  76948. /**
  76949. * Gets matrix determinant
  76950. * @returns the determinant
  76951. */
  76952. determinant(): number;
  76953. /**
  76954. * Inverses the matrix and stores it in a target matrix
  76955. * @param result defines the target matrix
  76956. * @returns the current matrix
  76957. */
  76958. invertToRef(result: Matrix2D): Matrix2D;
  76959. /**
  76960. * Multiplies the current matrix with another one
  76961. * @param other defines the second operand
  76962. * @param result defines the target matrix
  76963. * @returns the current matrix
  76964. */
  76965. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  76966. /**
  76967. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  76968. * @param x defines the x coordinate to transform
  76969. * @param y defines the x coordinate to transform
  76970. * @param result defines the target vector2
  76971. * @returns the current matrix
  76972. */
  76973. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  76974. /**
  76975. * Creates an identity matrix
  76976. * @returns a new matrix
  76977. */
  76978. static Identity(): Matrix2D;
  76979. /**
  76980. * Creates a translation matrix and stores it in a target matrix
  76981. * @param x defines the x coordinate of the translation
  76982. * @param y defines the y coordinate of the translation
  76983. * @param result defines the target matrix
  76984. */
  76985. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  76986. /**
  76987. * Creates a scaling matrix and stores it in a target matrix
  76988. * @param x defines the x coordinate of the scaling
  76989. * @param y defines the y coordinate of the scaling
  76990. * @param result defines the target matrix
  76991. */
  76992. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  76993. /**
  76994. * Creates a rotation matrix and stores it in a target matrix
  76995. * @param angle defines the rotation angle
  76996. * @param result defines the target matrix
  76997. */
  76998. static RotationToRef(angle: number, result: Matrix2D): void;
  76999. private static _TempPreTranslationMatrix;
  77000. private static _TempPostTranslationMatrix;
  77001. private static _TempRotationMatrix;
  77002. private static _TempScalingMatrix;
  77003. private static _TempCompose0;
  77004. private static _TempCompose1;
  77005. private static _TempCompose2;
  77006. /**
  77007. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77008. * @param tx defines the x coordinate of the translation
  77009. * @param ty defines the y coordinate of the translation
  77010. * @param angle defines the rotation angle
  77011. * @param scaleX defines the x coordinate of the scaling
  77012. * @param scaleY defines the y coordinate of the scaling
  77013. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77014. * @param result defines the target matrix
  77015. */
  77016. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77017. }
  77018. }
  77019. declare module BABYLON.GUI {
  77020. /**
  77021. * Class used to store 2D control sizes
  77022. */
  77023. export class Measure {
  77024. /** defines left coordinate */
  77025. left: number;
  77026. /** defines top coordinate */
  77027. top: number;
  77028. /** defines width dimension */
  77029. width: number;
  77030. /** defines height dimension */
  77031. height: number;
  77032. /**
  77033. * Creates a new measure
  77034. * @param left defines left coordinate
  77035. * @param top defines top coordinate
  77036. * @param width defines width dimension
  77037. * @param height defines height dimension
  77038. */
  77039. constructor(
  77040. /** defines left coordinate */
  77041. left: number,
  77042. /** defines top coordinate */
  77043. top: number,
  77044. /** defines width dimension */
  77045. width: number,
  77046. /** defines height dimension */
  77047. height: number);
  77048. /**
  77049. * Copy from another measure
  77050. * @param other defines the other measure to copy from
  77051. */
  77052. copyFrom(other: Measure): void;
  77053. /**
  77054. * Copy from a group of 4 floats
  77055. * @param left defines left coordinate
  77056. * @param top defines top coordinate
  77057. * @param width defines width dimension
  77058. * @param height defines height dimension
  77059. */
  77060. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77061. /**
  77062. * Computes the axis aligned bounding box measure for two given measures
  77063. * @param a Input measure
  77064. * @param b Input measure
  77065. * @param result the resulting bounding measure
  77066. */
  77067. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77068. /**
  77069. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77070. * @param transform the matrix to transform the measure before computing the AABB
  77071. * @param addX number to add to left
  77072. * @param addY number to add to top
  77073. * @param addWidth number to add to width
  77074. * @param addHeight number to add to height
  77075. * @param result the resulting AABB
  77076. */
  77077. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77078. /**
  77079. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77080. * @param transform the matrix to transform the measure before computing the AABB
  77081. * @param result the resulting AABB
  77082. */
  77083. transformToRef(transform: Matrix2D, result: Measure): void;
  77084. /**
  77085. * Check equality between this measure and another one
  77086. * @param other defines the other measures
  77087. * @returns true if both measures are equals
  77088. */
  77089. isEqualsTo(other: Measure): boolean;
  77090. /**
  77091. * Creates an empty measure
  77092. * @returns a new measure
  77093. */
  77094. static Empty(): Measure;
  77095. }
  77096. }
  77097. declare module BABYLON.GUI {
  77098. /**
  77099. * Interface used to define a control that can receive focus
  77100. */
  77101. export interface IFocusableControl {
  77102. /**
  77103. * Function called when the control receives the focus
  77104. */
  77105. onFocus(): void;
  77106. /**
  77107. * Function called when the control loses the focus
  77108. */
  77109. onBlur(): void;
  77110. /**
  77111. * Function called to let the control handle keyboard events
  77112. * @param evt defines the current keyboard event
  77113. */
  77114. processKeyboard(evt: KeyboardEvent): void;
  77115. /**
  77116. * Function called to get the list of controls that should not steal the focus from this control
  77117. * @returns an array of controls
  77118. */
  77119. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77120. }
  77121. /**
  77122. * Class used to create texture to support 2D GUI elements
  77123. * @see https://doc.babylonjs.com/how_to/gui
  77124. */
  77125. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77126. private _isDirty;
  77127. private _renderObserver;
  77128. private _resizeObserver;
  77129. private _preKeyboardObserver;
  77130. private _pointerMoveObserver;
  77131. private _pointerObserver;
  77132. private _canvasPointerOutObserver;
  77133. private _canvasBlurObserver;
  77134. private _background;
  77135. /** @hidden */
  77136. _rootContainer: Container;
  77137. /** @hidden */
  77138. _lastPickedControl: Control;
  77139. /** @hidden */
  77140. _lastControlOver: {
  77141. [pointerId: number]: Control;
  77142. };
  77143. /** @hidden */
  77144. _lastControlDown: {
  77145. [pointerId: number]: Control;
  77146. };
  77147. /** @hidden */
  77148. _capturingControl: {
  77149. [pointerId: number]: Control;
  77150. };
  77151. /** @hidden */
  77152. _shouldBlockPointer: boolean;
  77153. /** @hidden */
  77154. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77155. /** @hidden */
  77156. _linkedControls: Control[];
  77157. private _isFullscreen;
  77158. private _fullscreenViewport;
  77159. private _idealWidth;
  77160. private _idealHeight;
  77161. private _useSmallestIdeal;
  77162. private _renderAtIdealSize;
  77163. private _focusedControl;
  77164. private _blockNextFocusCheck;
  77165. private _renderScale;
  77166. private _rootElement;
  77167. private _cursorChanged;
  77168. private _defaultMousePointerId;
  77169. /** @hidden */
  77170. _numLayoutCalls: number;
  77171. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77172. get numLayoutCalls(): number;
  77173. /** @hidden */
  77174. _numRenderCalls: number;
  77175. /** Gets the number of render calls made the last time the ADT has been rendered */
  77176. get numRenderCalls(): number;
  77177. /**
  77178. * Define type to string to ensure compatibility across browsers
  77179. * Safari doesn't support DataTransfer constructor
  77180. */
  77181. private _clipboardData;
  77182. /**
  77183. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77184. */
  77185. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77186. /**
  77187. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77188. */
  77189. onControlPickedObservable: BABYLON.Observable<Control>;
  77190. /**
  77191. * BABYLON.Observable event triggered before layout is evaluated
  77192. */
  77193. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77194. /**
  77195. * BABYLON.Observable event triggered after the layout was evaluated
  77196. */
  77197. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77198. /**
  77199. * BABYLON.Observable event triggered before the texture is rendered
  77200. */
  77201. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77202. /**
  77203. * BABYLON.Observable event triggered after the texture was rendered
  77204. */
  77205. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77206. /**
  77207. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77208. */
  77209. premulAlpha: boolean;
  77210. /**
  77211. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77212. * Useful when you want more antialiasing
  77213. */
  77214. get renderScale(): number;
  77215. set renderScale(value: number);
  77216. /** Gets or sets the background color */
  77217. get background(): string;
  77218. set background(value: string);
  77219. /**
  77220. * Gets or sets the ideal width used to design controls.
  77221. * The GUI will then rescale everything accordingly
  77222. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77223. */
  77224. get idealWidth(): number;
  77225. set idealWidth(value: number);
  77226. /**
  77227. * Gets or sets the ideal height used to design controls.
  77228. * The GUI will then rescale everything accordingly
  77229. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77230. */
  77231. get idealHeight(): number;
  77232. set idealHeight(value: number);
  77233. /**
  77234. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77235. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77236. */
  77237. get useSmallestIdeal(): boolean;
  77238. set useSmallestIdeal(value: boolean);
  77239. /**
  77240. * Gets or sets a boolean indicating if adaptive scaling must be used
  77241. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77242. */
  77243. get renderAtIdealSize(): boolean;
  77244. set renderAtIdealSize(value: boolean);
  77245. /**
  77246. * Gets the ratio used when in "ideal mode"
  77247. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77248. * */
  77249. get idealRatio(): number;
  77250. /**
  77251. * Gets the underlying layer used to render the texture when in fullscreen mode
  77252. */
  77253. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77254. /**
  77255. * Gets the root container control
  77256. */
  77257. get rootContainer(): Container;
  77258. /**
  77259. * Returns an array containing the root container.
  77260. * This is mostly used to let the Inspector introspects the ADT
  77261. * @returns an array containing the rootContainer
  77262. */
  77263. getChildren(): Array<Container>;
  77264. /**
  77265. * Will return all controls that are inside this texture
  77266. * @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
  77267. * @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
  77268. * @return all child controls
  77269. */
  77270. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77271. /**
  77272. * Gets or sets the current focused control
  77273. */
  77274. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77275. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77276. /**
  77277. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77278. */
  77279. get isForeground(): boolean;
  77280. set isForeground(value: boolean);
  77281. /**
  77282. * Gets or set information about clipboardData
  77283. */
  77284. get clipboardData(): string;
  77285. set clipboardData(value: string);
  77286. /**
  77287. * Creates a new AdvancedDynamicTexture
  77288. * @param name defines the name of the texture
  77289. * @param width defines the width of the texture
  77290. * @param height defines the height of the texture
  77291. * @param scene defines the hosting scene
  77292. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77293. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77294. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77295. */
  77296. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77297. /**
  77298. * Get the current class name of the texture useful for serialization or dynamic coding.
  77299. * @returns "AdvancedDynamicTexture"
  77300. */
  77301. getClassName(): string;
  77302. /**
  77303. * Function used to execute a function on all controls
  77304. * @param func defines the function to execute
  77305. * @param container defines the container where controls belong. If null the root container will be used
  77306. */
  77307. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77308. private _useInvalidateRectOptimization;
  77309. /**
  77310. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77311. */
  77312. get useInvalidateRectOptimization(): boolean;
  77313. set useInvalidateRectOptimization(value: boolean);
  77314. private _invalidatedRectangle;
  77315. /**
  77316. * Invalidates a rectangle area on the gui texture
  77317. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77318. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77319. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77320. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77321. */
  77322. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77323. /**
  77324. * Marks the texture as dirty forcing a complete update
  77325. */
  77326. markAsDirty(): void;
  77327. /**
  77328. * Helper function used to create a new style
  77329. * @returns a new style
  77330. * @see https://doc.babylonjs.com/how_to/gui#styles
  77331. */
  77332. createStyle(): Style;
  77333. /**
  77334. * Adds a new control to the root container
  77335. * @param control defines the control to add
  77336. * @returns the current texture
  77337. */
  77338. addControl(control: Control): AdvancedDynamicTexture;
  77339. /**
  77340. * Removes a control from the root container
  77341. * @param control defines the control to remove
  77342. * @returns the current texture
  77343. */
  77344. removeControl(control: Control): AdvancedDynamicTexture;
  77345. /**
  77346. * Release all resources
  77347. */
  77348. dispose(): void;
  77349. private _onResize;
  77350. /** @hidden */
  77351. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77352. /**
  77353. * Get screen coordinates for a vector3
  77354. * @param position defines the position to project
  77355. * @param worldMatrix defines the world matrix to use
  77356. * @returns the projected position
  77357. */
  77358. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77359. private _checkUpdate;
  77360. private _clearMeasure;
  77361. private _render;
  77362. /** @hidden */
  77363. _changeCursor(cursor: string): void;
  77364. /** @hidden */
  77365. _registerLastControlDown(control: Control, pointerId: number): void;
  77366. private _doPicking;
  77367. /** @hidden */
  77368. _cleanControlAfterRemovalFromList(list: {
  77369. [pointerId: number]: Control;
  77370. }, control: Control): void;
  77371. /** @hidden */
  77372. _cleanControlAfterRemoval(control: Control): void;
  77373. /** Attach to all scene events required to support pointer events */
  77374. attach(): void;
  77375. /** @hidden */
  77376. private onClipboardCopy;
  77377. /** @hidden */
  77378. private onClipboardCut;
  77379. /** @hidden */
  77380. private onClipboardPaste;
  77381. /**
  77382. * Register the clipboard Events onto the canvas
  77383. */
  77384. registerClipboardEvents(): void;
  77385. /**
  77386. * Unregister the clipboard Events from the canvas
  77387. */
  77388. unRegisterClipboardEvents(): void;
  77389. /**
  77390. * Connect the texture to a hosting mesh to enable interactions
  77391. * @param mesh defines the mesh to attach to
  77392. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77393. */
  77394. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77395. /**
  77396. * Move the focus to a specific control
  77397. * @param control defines the control which will receive the focus
  77398. */
  77399. moveFocusToControl(control: IFocusableControl): void;
  77400. private _manageFocus;
  77401. private _attachToOnPointerOut;
  77402. private _attachToOnBlur;
  77403. /**
  77404. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77405. * @param mesh defines the mesh which will receive the texture
  77406. * @param width defines the texture width (1024 by default)
  77407. * @param height defines the texture height (1024 by default)
  77408. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77409. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77410. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77411. * @returns a new AdvancedDynamicTexture
  77412. */
  77413. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77414. /**
  77415. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77416. * In this mode the texture will rely on a layer for its rendering.
  77417. * This allows it to be treated like any other layer.
  77418. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77419. * LayerMask is set through advancedTexture.layer.layerMask
  77420. * @param name defines name for the texture
  77421. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77422. * @param scene defines the hsoting scene
  77423. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77424. * @returns a new AdvancedDynamicTexture
  77425. */
  77426. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77427. }
  77428. }
  77429. declare module BABYLON.GUI {
  77430. /**
  77431. * Root class used for all 2D controls
  77432. * @see https://doc.babylonjs.com/how_to/gui#controls
  77433. */
  77434. export class Control {
  77435. /** defines the name of the control */
  77436. name?: string | undefined;
  77437. /**
  77438. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77439. */
  77440. static AllowAlphaInheritance: boolean;
  77441. private _alpha;
  77442. private _alphaSet;
  77443. private _zIndex;
  77444. /** @hidden */
  77445. _host: AdvancedDynamicTexture;
  77446. /** Gets or sets the control parent */
  77447. parent: BABYLON.Nullable<Container>;
  77448. /** @hidden */
  77449. _currentMeasure: Measure;
  77450. private _fontFamily;
  77451. private _fontStyle;
  77452. private _fontWeight;
  77453. private _fontSize;
  77454. private _font;
  77455. /** @hidden */
  77456. _width: ValueAndUnit;
  77457. /** @hidden */
  77458. _height: ValueAndUnit;
  77459. /** @hidden */
  77460. protected _fontOffset: {
  77461. ascent: number;
  77462. height: number;
  77463. descent: number;
  77464. };
  77465. private _color;
  77466. private _style;
  77467. private _styleObserver;
  77468. /** @hidden */
  77469. protected _horizontalAlignment: number;
  77470. /** @hidden */
  77471. protected _verticalAlignment: number;
  77472. /** @hidden */
  77473. protected _isDirty: boolean;
  77474. /** @hidden */
  77475. protected _wasDirty: boolean;
  77476. /** @hidden */
  77477. _tempParentMeasure: Measure;
  77478. /** @hidden */
  77479. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77480. /** @hidden */
  77481. protected _cachedParentMeasure: Measure;
  77482. private _paddingLeft;
  77483. private _paddingRight;
  77484. private _paddingTop;
  77485. private _paddingBottom;
  77486. /** @hidden */
  77487. _left: ValueAndUnit;
  77488. /** @hidden */
  77489. _top: ValueAndUnit;
  77490. private _scaleX;
  77491. private _scaleY;
  77492. private _rotation;
  77493. private _transformCenterX;
  77494. private _transformCenterY;
  77495. /** @hidden */
  77496. _transformMatrix: Matrix2D;
  77497. /** @hidden */
  77498. protected _invertTransformMatrix: Matrix2D;
  77499. /** @hidden */
  77500. protected _transformedPosition: BABYLON.Vector2;
  77501. private _isMatrixDirty;
  77502. private _cachedOffsetX;
  77503. private _cachedOffsetY;
  77504. private _isVisible;
  77505. private _isHighlighted;
  77506. /** @hidden */
  77507. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77508. private _fontSet;
  77509. private _dummyVector2;
  77510. private _downCount;
  77511. private _enterCount;
  77512. private _doNotRender;
  77513. private _downPointerIds;
  77514. protected _isEnabled: boolean;
  77515. protected _disabledColor: string;
  77516. protected _disabledColorItem: string;
  77517. /** @hidden */
  77518. protected _rebuildLayout: boolean;
  77519. /** @hidden */
  77520. _customData: any;
  77521. /** @hidden */
  77522. _isClipped: boolean;
  77523. /** @hidden */
  77524. _automaticSize: boolean;
  77525. /** @hidden */
  77526. _tag: any;
  77527. /**
  77528. * 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
  77529. */
  77530. uniqueId: number;
  77531. /**
  77532. * Gets or sets an object used to store user defined information for the node
  77533. */
  77534. metadata: any;
  77535. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77536. isHitTestVisible: boolean;
  77537. /** Gets or sets a boolean indicating if the control can block pointer events */
  77538. isPointerBlocker: boolean;
  77539. /** Gets or sets a boolean indicating if the control can be focusable */
  77540. isFocusInvisible: boolean;
  77541. /**
  77542. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77543. * 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
  77544. */
  77545. clipChildren: boolean;
  77546. /**
  77547. * Gets or sets a boolean indicating that control content must be clipped
  77548. * 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
  77549. */
  77550. clipContent: boolean;
  77551. /**
  77552. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77553. */
  77554. useBitmapCache: boolean;
  77555. private _cacheData;
  77556. private _shadowOffsetX;
  77557. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77558. get shadowOffsetX(): number;
  77559. set shadowOffsetX(value: number);
  77560. private _shadowOffsetY;
  77561. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77562. get shadowOffsetY(): number;
  77563. set shadowOffsetY(value: number);
  77564. private _shadowBlur;
  77565. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77566. get shadowBlur(): number;
  77567. set shadowBlur(value: number);
  77568. private _shadowColor;
  77569. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77570. get shadowColor(): string;
  77571. set shadowColor(value: string);
  77572. /** Gets or sets the cursor to use when the control is hovered */
  77573. hoverCursor: string;
  77574. /** @hidden */
  77575. protected _linkOffsetX: ValueAndUnit;
  77576. /** @hidden */
  77577. protected _linkOffsetY: ValueAndUnit;
  77578. /** Gets the control type name */
  77579. get typeName(): string;
  77580. /**
  77581. * Get the current class name of the control.
  77582. * @returns current class name
  77583. */
  77584. getClassName(): string;
  77585. /**
  77586. * An event triggered when pointer wheel is scrolled
  77587. */
  77588. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77589. /**
  77590. * An event triggered when the pointer move over the control.
  77591. */
  77592. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77593. /**
  77594. * An event triggered when the pointer move out of the control.
  77595. */
  77596. onPointerOutObservable: BABYLON.Observable<Control>;
  77597. /**
  77598. * An event triggered when the pointer taps the control
  77599. */
  77600. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77601. /**
  77602. * An event triggered when pointer up
  77603. */
  77604. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77605. /**
  77606. * An event triggered when a control is clicked on
  77607. */
  77608. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77609. /**
  77610. * An event triggered when pointer enters the control
  77611. */
  77612. onPointerEnterObservable: BABYLON.Observable<Control>;
  77613. /**
  77614. * An event triggered when the control is marked as dirty
  77615. */
  77616. onDirtyObservable: BABYLON.Observable<Control>;
  77617. /**
  77618. * An event triggered before drawing the control
  77619. */
  77620. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77621. /**
  77622. * An event triggered after the control was drawn
  77623. */
  77624. onAfterDrawObservable: BABYLON.Observable<Control>;
  77625. /**
  77626. * An event triggered when the control has been disposed
  77627. */
  77628. onDisposeObservable: BABYLON.Observable<Control>;
  77629. /**
  77630. * Get the hosting AdvancedDynamicTexture
  77631. */
  77632. get host(): AdvancedDynamicTexture;
  77633. /** Gets or set information about font offsets (used to render and align text) */
  77634. get fontOffset(): {
  77635. ascent: number;
  77636. height: number;
  77637. descent: number;
  77638. };
  77639. set fontOffset(offset: {
  77640. ascent: number;
  77641. height: number;
  77642. descent: number;
  77643. });
  77644. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77645. get alpha(): number;
  77646. set alpha(value: number);
  77647. /**
  77648. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77649. */
  77650. get isHighlighted(): boolean;
  77651. set isHighlighted(value: boolean);
  77652. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77653. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77654. */
  77655. get scaleX(): number;
  77656. set scaleX(value: number);
  77657. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77658. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77659. */
  77660. get scaleY(): number;
  77661. set scaleY(value: number);
  77662. /** Gets or sets the rotation angle (0 by default)
  77663. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77664. */
  77665. get rotation(): number;
  77666. set rotation(value: number);
  77667. /** Gets or sets the transformation center on Y axis (0 by default)
  77668. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77669. */
  77670. get transformCenterY(): number;
  77671. set transformCenterY(value: number);
  77672. /** Gets or sets the transformation center on X axis (0 by default)
  77673. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77674. */
  77675. get transformCenterX(): number;
  77676. set transformCenterX(value: number);
  77677. /**
  77678. * Gets or sets the horizontal alignment
  77679. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77680. */
  77681. get horizontalAlignment(): number;
  77682. set horizontalAlignment(value: number);
  77683. /**
  77684. * Gets or sets the vertical alignment
  77685. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77686. */
  77687. get verticalAlignment(): number;
  77688. set verticalAlignment(value: number);
  77689. /**
  77690. * Gets or sets a fixed ratio for this control.
  77691. * When different from 0, the ratio is used to compute the "second" dimension.
  77692. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77693. * second dimension is computed as first dimension * fixedRatio
  77694. */
  77695. fixedRatio: number;
  77696. private _fixedRatioMasterIsWidth;
  77697. /**
  77698. * Gets or sets control width
  77699. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77700. */
  77701. get width(): string | number;
  77702. set width(value: string | number);
  77703. /**
  77704. * Gets or sets the control width in pixel
  77705. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77706. */
  77707. get widthInPixels(): number;
  77708. set widthInPixels(value: number);
  77709. /**
  77710. * Gets or sets control height
  77711. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77712. */
  77713. get height(): string | number;
  77714. set height(value: string | number);
  77715. /**
  77716. * Gets or sets control height in pixel
  77717. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77718. */
  77719. get heightInPixels(): number;
  77720. set heightInPixels(value: number);
  77721. /** Gets or set font family */
  77722. get fontFamily(): string;
  77723. set fontFamily(value: string);
  77724. /** Gets or sets font style */
  77725. get fontStyle(): string;
  77726. set fontStyle(value: string);
  77727. /** Gets or sets font weight */
  77728. get fontWeight(): string;
  77729. set fontWeight(value: string);
  77730. /**
  77731. * Gets or sets style
  77732. * @see https://doc.babylonjs.com/how_to/gui#styles
  77733. */
  77734. get style(): BABYLON.Nullable<Style>;
  77735. set style(value: BABYLON.Nullable<Style>);
  77736. /** @hidden */
  77737. get _isFontSizeInPercentage(): boolean;
  77738. /** Gets or sets font size in pixels */
  77739. get fontSizeInPixels(): number;
  77740. set fontSizeInPixels(value: number);
  77741. /** Gets or sets font size */
  77742. get fontSize(): string | number;
  77743. set fontSize(value: string | number);
  77744. /** Gets or sets foreground color */
  77745. get color(): string;
  77746. set color(value: string);
  77747. /** Gets or sets z index which is used to reorder controls on the z axis */
  77748. get zIndex(): number;
  77749. set zIndex(value: number);
  77750. /** Gets or sets a boolean indicating if the control can be rendered */
  77751. get notRenderable(): boolean;
  77752. set notRenderable(value: boolean);
  77753. /** Gets or sets a boolean indicating if the control is visible */
  77754. get isVisible(): boolean;
  77755. set isVisible(value: boolean);
  77756. /** Gets a boolean indicating that the control needs to update its rendering */
  77757. get isDirty(): boolean;
  77758. /**
  77759. * Gets the current linked mesh (or null if none)
  77760. */
  77761. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77762. /**
  77763. * Gets or sets a value indicating the padding to use on the left of the control
  77764. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77765. */
  77766. get paddingLeft(): string | number;
  77767. set paddingLeft(value: string | number);
  77768. /**
  77769. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77770. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77771. */
  77772. get paddingLeftInPixels(): number;
  77773. set paddingLeftInPixels(value: number);
  77774. /**
  77775. * Gets or sets a value indicating the padding to use on the right of the control
  77776. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77777. */
  77778. get paddingRight(): string | number;
  77779. set paddingRight(value: string | number);
  77780. /**
  77781. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77782. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77783. */
  77784. get paddingRightInPixels(): number;
  77785. set paddingRightInPixels(value: number);
  77786. /**
  77787. * Gets or sets a value indicating the padding to use on the top of the control
  77788. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77789. */
  77790. get paddingTop(): string | number;
  77791. set paddingTop(value: string | number);
  77792. /**
  77793. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77794. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77795. */
  77796. get paddingTopInPixels(): number;
  77797. set paddingTopInPixels(value: number);
  77798. /**
  77799. * Gets or sets a value indicating the padding to use on the bottom of the control
  77800. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77801. */
  77802. get paddingBottom(): string | number;
  77803. set paddingBottom(value: string | number);
  77804. /**
  77805. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77806. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77807. */
  77808. get paddingBottomInPixels(): number;
  77809. set paddingBottomInPixels(value: number);
  77810. /**
  77811. * Gets or sets a value indicating the left coordinate of the control
  77812. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77813. */
  77814. get left(): string | number;
  77815. set left(value: string | number);
  77816. /**
  77817. * Gets or sets a value indicating the left coordinate in pixels of the control
  77818. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77819. */
  77820. get leftInPixels(): number;
  77821. set leftInPixels(value: number);
  77822. /**
  77823. * Gets or sets a value indicating the top coordinate of the control
  77824. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77825. */
  77826. get top(): string | number;
  77827. set top(value: string | number);
  77828. /**
  77829. * Gets or sets a value indicating the top coordinate in pixels of the control
  77830. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77831. */
  77832. get topInPixels(): number;
  77833. set topInPixels(value: number);
  77834. /**
  77835. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77836. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77837. */
  77838. get linkOffsetX(): string | number;
  77839. set linkOffsetX(value: string | number);
  77840. /**
  77841. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77842. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77843. */
  77844. get linkOffsetXInPixels(): number;
  77845. set linkOffsetXInPixels(value: number);
  77846. /**
  77847. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  77848. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77849. */
  77850. get linkOffsetY(): string | number;
  77851. set linkOffsetY(value: string | number);
  77852. /**
  77853. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  77854. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77855. */
  77856. get linkOffsetYInPixels(): number;
  77857. set linkOffsetYInPixels(value: number);
  77858. /** Gets the center coordinate on X axis */
  77859. get centerX(): number;
  77860. /** Gets the center coordinate on Y axis */
  77861. get centerY(): number;
  77862. /** Gets or sets if control is Enabled*/
  77863. get isEnabled(): boolean;
  77864. set isEnabled(value: boolean);
  77865. /** Gets or sets background color of control if it's disabled*/
  77866. get disabledColor(): string;
  77867. set disabledColor(value: string);
  77868. /** Gets or sets front color of control if it's disabled*/
  77869. get disabledColorItem(): string;
  77870. set disabledColorItem(value: string);
  77871. /**
  77872. * Creates a new control
  77873. * @param name defines the name of the control
  77874. */
  77875. constructor(
  77876. /** defines the name of the control */
  77877. name?: string | undefined);
  77878. /** @hidden */
  77879. protected _getTypeName(): string;
  77880. /**
  77881. * Gets the first ascendant in the hierarchy of the given type
  77882. * @param className defines the required type
  77883. * @returns the ascendant or null if not found
  77884. */
  77885. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  77886. /** @hidden */
  77887. _resetFontCache(): void;
  77888. /**
  77889. * Determines if a container is an ascendant of the current control
  77890. * @param container defines the container to look for
  77891. * @returns true if the container is one of the ascendant of the control
  77892. */
  77893. isAscendant(container: Control): boolean;
  77894. /**
  77895. * Gets coordinates in local control space
  77896. * @param globalCoordinates defines the coordinates to transform
  77897. * @returns the new coordinates in local space
  77898. */
  77899. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77900. /**
  77901. * Gets coordinates in local control space
  77902. * @param globalCoordinates defines the coordinates to transform
  77903. * @param result defines the target vector2 where to store the result
  77904. * @returns the current control
  77905. */
  77906. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  77907. /**
  77908. * Gets coordinates in parent local control space
  77909. * @param globalCoordinates defines the coordinates to transform
  77910. * @returns the new coordinates in parent local space
  77911. */
  77912. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  77913. /**
  77914. * Move the current control to a vector3 position projected onto the screen.
  77915. * @param position defines the target position
  77916. * @param scene defines the hosting scene
  77917. */
  77918. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  77919. /**
  77920. * Will store all controls that have this control as ascendant in a given array
  77921. * @param results defines the array where to store the descendants
  77922. * @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
  77923. * @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
  77924. */
  77925. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  77926. /**
  77927. * Will return all controls that have this control as ascendant
  77928. * @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
  77929. * @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
  77930. * @return all child controls
  77931. */
  77932. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77933. /**
  77934. * Link current control with a target mesh
  77935. * @param mesh defines the mesh to link with
  77936. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77937. */
  77938. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  77939. /** @hidden */
  77940. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  77941. /** @hidden */
  77942. _offsetLeft(offset: number): void;
  77943. /** @hidden */
  77944. _offsetTop(offset: number): void;
  77945. /** @hidden */
  77946. _markMatrixAsDirty(): void;
  77947. /** @hidden */
  77948. _flagDescendantsAsMatrixDirty(): void;
  77949. /** @hidden */
  77950. _intersectsRect(rect: Measure): boolean;
  77951. /** @hidden */
  77952. protected invalidateRect(): void;
  77953. /** @hidden */
  77954. _markAsDirty(force?: boolean): void;
  77955. /** @hidden */
  77956. _markAllAsDirty(): void;
  77957. /** @hidden */
  77958. _link(host: AdvancedDynamicTexture): void;
  77959. /** @hidden */
  77960. protected _transform(context?: CanvasRenderingContext2D): void;
  77961. /** @hidden */
  77962. _renderHighlight(context: CanvasRenderingContext2D): void;
  77963. /** @hidden */
  77964. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  77965. /** @hidden */
  77966. protected _applyStates(context: CanvasRenderingContext2D): void;
  77967. /** @hidden */
  77968. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  77969. /** @hidden */
  77970. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77971. protected _evaluateClippingState(parentMeasure: Measure): void;
  77972. /** @hidden */
  77973. _measure(): void;
  77974. /** @hidden */
  77975. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77976. /** @hidden */
  77977. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77978. /** @hidden */
  77979. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  77980. /** @hidden */
  77981. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  77982. private static _ClipMeasure;
  77983. private _tmpMeasureA;
  77984. private _clip;
  77985. /** @hidden */
  77986. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  77987. /** @hidden */
  77988. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  77989. /**
  77990. * Tests if a given coordinates belong to the current control
  77991. * @param x defines x coordinate to test
  77992. * @param y defines y coordinate to test
  77993. * @returns true if the coordinates are inside the control
  77994. */
  77995. contains(x: number, y: number): boolean;
  77996. /** @hidden */
  77997. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  77998. /** @hidden */
  77999. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78000. /** @hidden */
  78001. _onPointerEnter(target: Control): boolean;
  78002. /** @hidden */
  78003. _onPointerOut(target: Control, force?: boolean): void;
  78004. /** @hidden */
  78005. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78006. /** @hidden */
  78007. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78008. /** @hidden */
  78009. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78010. /** @hidden */
  78011. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78012. /** @hidden */
  78013. _onCanvasBlur(): void;
  78014. /** @hidden */
  78015. _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78016. private _prepareFont;
  78017. /** Releases associated resources */
  78018. dispose(): void;
  78019. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78020. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78021. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78022. private static _VERTICAL_ALIGNMENT_TOP;
  78023. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78024. private static _VERTICAL_ALIGNMENT_CENTER;
  78025. /** HORIZONTAL_ALIGNMENT_LEFT */
  78026. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78027. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78028. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78029. /** HORIZONTAL_ALIGNMENT_CENTER */
  78030. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78031. /** VERTICAL_ALIGNMENT_TOP */
  78032. static get VERTICAL_ALIGNMENT_TOP(): number;
  78033. /** VERTICAL_ALIGNMENT_BOTTOM */
  78034. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78035. /** VERTICAL_ALIGNMENT_CENTER */
  78036. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78037. private static _FontHeightSizes;
  78038. /** @hidden */
  78039. static _GetFontOffset(font: string): {
  78040. ascent: number;
  78041. height: number;
  78042. descent: number;
  78043. };
  78044. /**
  78045. * Creates a stack panel that can be used to render headers
  78046. * @param control defines the control to associate with the header
  78047. * @param text defines the text of the header
  78048. * @param size defines the size of the header
  78049. * @param options defines options used to configure the header
  78050. * @returns a new StackPanel
  78051. * @ignore
  78052. * @hidden
  78053. */
  78054. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78055. isHorizontal: boolean;
  78056. controlFirst: boolean;
  78057. }) => any;
  78058. /** @hidden */
  78059. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78060. }
  78061. }
  78062. declare module BABYLON.GUI {
  78063. /**
  78064. * Root class for 2D containers
  78065. * @see https://doc.babylonjs.com/how_to/gui#containers
  78066. */
  78067. export class Container extends Control {
  78068. name?: string | undefined;
  78069. /** @hidden */
  78070. _children: Control[];
  78071. /** @hidden */
  78072. protected _measureForChildren: Measure;
  78073. /** @hidden */
  78074. protected _background: string;
  78075. /** @hidden */
  78076. protected _adaptWidthToChildren: boolean;
  78077. /** @hidden */
  78078. protected _adaptHeightToChildren: boolean;
  78079. /**
  78080. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78081. */
  78082. logLayoutCycleErrors: boolean;
  78083. /**
  78084. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78085. */
  78086. maxLayoutCycle: number;
  78087. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78088. get adaptHeightToChildren(): boolean;
  78089. set adaptHeightToChildren(value: boolean);
  78090. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78091. get adaptWidthToChildren(): boolean;
  78092. set adaptWidthToChildren(value: boolean);
  78093. /** Gets or sets background color */
  78094. get background(): string;
  78095. set background(value: string);
  78096. /** Gets the list of children */
  78097. get children(): Control[];
  78098. /**
  78099. * Creates a new Container
  78100. * @param name defines the name of the container
  78101. */
  78102. constructor(name?: string | undefined);
  78103. protected _getTypeName(): string;
  78104. _flagDescendantsAsMatrixDirty(): void;
  78105. /**
  78106. * Gets a child using its name
  78107. * @param name defines the child name to look for
  78108. * @returns the child control if found
  78109. */
  78110. getChildByName(name: string): BABYLON.Nullable<Control>;
  78111. /**
  78112. * Gets a child using its type and its name
  78113. * @param name defines the child name to look for
  78114. * @param type defines the child type to look for
  78115. * @returns the child control if found
  78116. */
  78117. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78118. /**
  78119. * Search for a specific control in children
  78120. * @param control defines the control to look for
  78121. * @returns true if the control is in child list
  78122. */
  78123. containsControl(control: Control): boolean;
  78124. /**
  78125. * Adds a new control to the current container
  78126. * @param control defines the control to add
  78127. * @returns the current container
  78128. */
  78129. addControl(control: BABYLON.Nullable<Control>): Container;
  78130. /**
  78131. * Removes all controls from the current container
  78132. * @returns the current container
  78133. */
  78134. clearControls(): Container;
  78135. /**
  78136. * Removes a control from the current container
  78137. * @param control defines the control to remove
  78138. * @returns the current container
  78139. */
  78140. removeControl(control: Control): Container;
  78141. /** @hidden */
  78142. _reOrderControl(control: Control): void;
  78143. /** @hidden */
  78144. _offsetLeft(offset: number): void;
  78145. /** @hidden */
  78146. _offsetTop(offset: number): void;
  78147. /** @hidden */
  78148. _markAllAsDirty(): void;
  78149. /** @hidden */
  78150. protected _localDraw(context: CanvasRenderingContext2D): void;
  78151. /** @hidden */
  78152. _link(host: AdvancedDynamicTexture): void;
  78153. /** @hidden */
  78154. protected _beforeLayout(): void;
  78155. /** @hidden */
  78156. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78157. /** @hidden */
  78158. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78159. protected _postMeasure(): void;
  78160. /** @hidden */
  78161. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78162. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78163. /** @hidden */
  78164. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78165. /** @hidden */
  78166. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78167. /** Releases associated resources */
  78168. dispose(): void;
  78169. }
  78170. }
  78171. declare module BABYLON.GUI {
  78172. /** Class used to create rectangle container */
  78173. export class Rectangle extends Container {
  78174. name?: string | undefined;
  78175. private _thickness;
  78176. private _cornerRadius;
  78177. /** Gets or sets border thickness */
  78178. get thickness(): number;
  78179. set thickness(value: number);
  78180. /** Gets or sets the corner radius angle */
  78181. get cornerRadius(): number;
  78182. set cornerRadius(value: number);
  78183. /**
  78184. * Creates a new Rectangle
  78185. * @param name defines the control name
  78186. */
  78187. constructor(name?: string | undefined);
  78188. protected _getTypeName(): string;
  78189. protected _localDraw(context: CanvasRenderingContext2D): void;
  78190. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78191. private _drawRoundedRect;
  78192. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78193. }
  78194. }
  78195. declare module BABYLON.GUI {
  78196. /**
  78197. * Enum that determines the text-wrapping mode to use.
  78198. */
  78199. export enum TextWrapping {
  78200. /**
  78201. * Clip the text when it's larger than Control.width; this is the default mode.
  78202. */
  78203. Clip = 0,
  78204. /**
  78205. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78206. */
  78207. WordWrap = 1,
  78208. /**
  78209. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78210. */
  78211. Ellipsis = 2
  78212. }
  78213. /**
  78214. * Class used to create text block control
  78215. */
  78216. export class TextBlock extends Control {
  78217. /**
  78218. * Defines the name of the control
  78219. */
  78220. name?: string | undefined;
  78221. private _text;
  78222. private _textWrapping;
  78223. private _textHorizontalAlignment;
  78224. private _textVerticalAlignment;
  78225. private _lines;
  78226. private _resizeToFit;
  78227. private _lineSpacing;
  78228. private _outlineWidth;
  78229. private _outlineColor;
  78230. private _underline;
  78231. private _lineThrough;
  78232. /**
  78233. * An event triggered after the text is changed
  78234. */
  78235. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78236. /**
  78237. * An event triggered after the text was broken up into lines
  78238. */
  78239. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78240. /**
  78241. * Function used to split a string into words. By default, a string is split at each space character found
  78242. */
  78243. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78244. /**
  78245. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78246. */
  78247. get lines(): any[];
  78248. /**
  78249. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78250. */
  78251. get resizeToFit(): boolean;
  78252. /**
  78253. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78254. */
  78255. set resizeToFit(value: boolean);
  78256. /**
  78257. * Gets or sets a boolean indicating if text must be wrapped
  78258. */
  78259. get textWrapping(): TextWrapping | boolean;
  78260. /**
  78261. * Gets or sets a boolean indicating if text must be wrapped
  78262. */
  78263. set textWrapping(value: TextWrapping | boolean);
  78264. /**
  78265. * Gets or sets text to display
  78266. */
  78267. get text(): string;
  78268. /**
  78269. * Gets or sets text to display
  78270. */
  78271. set text(value: string);
  78272. /**
  78273. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78274. */
  78275. get textHorizontalAlignment(): number;
  78276. /**
  78277. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78278. */
  78279. set textHorizontalAlignment(value: number);
  78280. /**
  78281. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78282. */
  78283. get textVerticalAlignment(): number;
  78284. /**
  78285. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78286. */
  78287. set textVerticalAlignment(value: number);
  78288. /**
  78289. * Gets or sets line spacing value
  78290. */
  78291. set lineSpacing(value: string | number);
  78292. /**
  78293. * Gets or sets line spacing value
  78294. */
  78295. get lineSpacing(): string | number;
  78296. /**
  78297. * Gets or sets outlineWidth of the text to display
  78298. */
  78299. get outlineWidth(): number;
  78300. /**
  78301. * Gets or sets outlineWidth of the text to display
  78302. */
  78303. set outlineWidth(value: number);
  78304. /**
  78305. * Gets or sets a boolean indicating that text must have underline
  78306. */
  78307. get underline(): boolean;
  78308. /**
  78309. * Gets or sets a boolean indicating that text must have underline
  78310. */
  78311. set underline(value: boolean);
  78312. /**
  78313. * Gets or sets an boolean indicating that text must be crossed out
  78314. */
  78315. get lineThrough(): boolean;
  78316. /**
  78317. * Gets or sets an boolean indicating that text must be crossed out
  78318. */
  78319. set lineThrough(value: boolean);
  78320. /**
  78321. * Gets or sets outlineColor of the text to display
  78322. */
  78323. get outlineColor(): string;
  78324. /**
  78325. * Gets or sets outlineColor of the text to display
  78326. */
  78327. set outlineColor(value: string);
  78328. /**
  78329. * Creates a new TextBlock object
  78330. * @param name defines the name of the control
  78331. * @param text defines the text to display (emptry string by default)
  78332. */
  78333. constructor(
  78334. /**
  78335. * Defines the name of the control
  78336. */
  78337. name?: string | undefined, text?: string);
  78338. protected _getTypeName(): string;
  78339. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78340. private _drawText;
  78341. /** @hidden */
  78342. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78343. protected _applyStates(context: CanvasRenderingContext2D): void;
  78344. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78345. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78346. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78347. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78348. protected _renderLines(context: CanvasRenderingContext2D): void;
  78349. /**
  78350. * Given a width constraint applied on the text block, find the expected height
  78351. * @returns expected height
  78352. */
  78353. computeExpectedHeight(): number;
  78354. dispose(): void;
  78355. }
  78356. }
  78357. declare module BABYLON.GUI {
  78358. /**
  78359. * Class used to create 2D images
  78360. */
  78361. export class Image extends Control {
  78362. name?: string | undefined;
  78363. private _workingCanvas;
  78364. private _domImage;
  78365. private _imageWidth;
  78366. private _imageHeight;
  78367. private _loaded;
  78368. private _stretch;
  78369. private _source;
  78370. private _autoScale;
  78371. private _sourceLeft;
  78372. private _sourceTop;
  78373. private _sourceWidth;
  78374. private _sourceHeight;
  78375. private _svgAttributesComputationCompleted;
  78376. private _isSVG;
  78377. private _cellWidth;
  78378. private _cellHeight;
  78379. private _cellId;
  78380. private _populateNinePatchSlicesFromImage;
  78381. private _sliceLeft;
  78382. private _sliceRight;
  78383. private _sliceTop;
  78384. private _sliceBottom;
  78385. private _detectPointerOnOpaqueOnly;
  78386. private _imageDataCache;
  78387. /**
  78388. * BABYLON.Observable notified when the content is loaded
  78389. */
  78390. onImageLoadedObservable: BABYLON.Observable<Image>;
  78391. /**
  78392. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78393. */
  78394. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78395. /**
  78396. * Gets a boolean indicating that the content is loaded
  78397. */
  78398. get isLoaded(): boolean;
  78399. /**
  78400. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78401. */
  78402. get populateNinePatchSlicesFromImage(): boolean;
  78403. set populateNinePatchSlicesFromImage(value: boolean);
  78404. /**
  78405. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78406. * Beware using this as this will comsume more memory as the image has to be stored twice
  78407. */
  78408. get detectPointerOnOpaqueOnly(): boolean;
  78409. set detectPointerOnOpaqueOnly(value: boolean);
  78410. /**
  78411. * Gets or sets the left value for slicing (9-patch)
  78412. */
  78413. get sliceLeft(): number;
  78414. set sliceLeft(value: number);
  78415. /**
  78416. * Gets or sets the right value for slicing (9-patch)
  78417. */
  78418. get sliceRight(): number;
  78419. set sliceRight(value: number);
  78420. /**
  78421. * Gets or sets the top value for slicing (9-patch)
  78422. */
  78423. get sliceTop(): number;
  78424. set sliceTop(value: number);
  78425. /**
  78426. * Gets or sets the bottom value for slicing (9-patch)
  78427. */
  78428. get sliceBottom(): number;
  78429. set sliceBottom(value: number);
  78430. /**
  78431. * Gets or sets the left coordinate in the source image
  78432. */
  78433. get sourceLeft(): number;
  78434. set sourceLeft(value: number);
  78435. /**
  78436. * Gets or sets the top coordinate in the source image
  78437. */
  78438. get sourceTop(): number;
  78439. set sourceTop(value: number);
  78440. /**
  78441. * Gets or sets the width to capture in the source image
  78442. */
  78443. get sourceWidth(): number;
  78444. set sourceWidth(value: number);
  78445. /**
  78446. * Gets or sets the height to capture in the source image
  78447. */
  78448. get sourceHeight(): number;
  78449. set sourceHeight(value: number);
  78450. /** Indicates if the format of the image is SVG */
  78451. get isSVG(): boolean;
  78452. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78453. get svgAttributesComputationCompleted(): boolean;
  78454. /**
  78455. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78456. * @see https://doc.babylonjs.com/how_to/gui#image
  78457. */
  78458. get autoScale(): boolean;
  78459. set autoScale(value: boolean);
  78460. /** Gets or sets the streching mode used by the image */
  78461. get stretch(): number;
  78462. set stretch(value: number);
  78463. /** @hidden */
  78464. _rotate90(n: number, preserveProperties?: boolean): Image;
  78465. private _handleRotationForSVGImage;
  78466. private _rotate90SourceProperties;
  78467. /**
  78468. * Gets or sets the internal DOM image used to render the control
  78469. */
  78470. set domImage(value: HTMLImageElement);
  78471. get domImage(): HTMLImageElement;
  78472. private _onImageLoaded;
  78473. private _extractNinePatchSliceDataFromImage;
  78474. /**
  78475. * Gets or sets image source url
  78476. */
  78477. set source(value: BABYLON.Nullable<string>);
  78478. /**
  78479. * Checks for svg document with icon id present
  78480. */
  78481. private _svgCheck;
  78482. /**
  78483. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78484. * given external svg file and icon id
  78485. */
  78486. private _getSVGAttribs;
  78487. /**
  78488. * Gets or sets the cell width to use when animation sheet is enabled
  78489. * @see https://doc.babylonjs.com/how_to/gui#image
  78490. */
  78491. get cellWidth(): number;
  78492. set cellWidth(value: number);
  78493. /**
  78494. * Gets or sets the cell height to use when animation sheet is enabled
  78495. * @see https://doc.babylonjs.com/how_to/gui#image
  78496. */
  78497. get cellHeight(): number;
  78498. set cellHeight(value: number);
  78499. /**
  78500. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78501. * @see https://doc.babylonjs.com/how_to/gui#image
  78502. */
  78503. get cellId(): number;
  78504. set cellId(value: number);
  78505. /**
  78506. * Creates a new Image
  78507. * @param name defines the control name
  78508. * @param url defines the image url
  78509. */
  78510. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78511. /**
  78512. * Tests if a given coordinates belong to the current control
  78513. * @param x defines x coordinate to test
  78514. * @param y defines y coordinate to test
  78515. * @returns true if the coordinates are inside the control
  78516. */
  78517. contains(x: number, y: number): boolean;
  78518. protected _getTypeName(): string;
  78519. /** Force the control to synchronize with its content */
  78520. synchronizeSizeWithContent(): void;
  78521. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78522. private _prepareWorkingCanvasForOpaqueDetection;
  78523. private _drawImage;
  78524. _draw(context: CanvasRenderingContext2D): void;
  78525. private _renderCornerPatch;
  78526. private _renderNinePatch;
  78527. dispose(): void;
  78528. /** STRETCH_NONE */
  78529. static readonly STRETCH_NONE: number;
  78530. /** STRETCH_FILL */
  78531. static readonly STRETCH_FILL: number;
  78532. /** STRETCH_UNIFORM */
  78533. static readonly STRETCH_UNIFORM: number;
  78534. /** STRETCH_EXTEND */
  78535. static readonly STRETCH_EXTEND: number;
  78536. /** NINE_PATCH */
  78537. static readonly STRETCH_NINE_PATCH: number;
  78538. }
  78539. }
  78540. declare module BABYLON.GUI {
  78541. /**
  78542. * Class used to create 2D buttons
  78543. */
  78544. export class Button extends Rectangle {
  78545. name?: string | undefined;
  78546. /**
  78547. * Function called to generate a pointer enter animation
  78548. */
  78549. pointerEnterAnimation: () => void;
  78550. /**
  78551. * Function called to generate a pointer out animation
  78552. */
  78553. pointerOutAnimation: () => void;
  78554. /**
  78555. * Function called to generate a pointer down animation
  78556. */
  78557. pointerDownAnimation: () => void;
  78558. /**
  78559. * Function called to generate a pointer up animation
  78560. */
  78561. pointerUpAnimation: () => void;
  78562. /**
  78563. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78564. */
  78565. delegatePickingToChildren: boolean;
  78566. private _image;
  78567. /**
  78568. * Returns the image part of the button (if any)
  78569. */
  78570. get image(): BABYLON.Nullable<Image>;
  78571. private _textBlock;
  78572. /**
  78573. * Returns the image part of the button (if any)
  78574. */
  78575. get textBlock(): BABYLON.Nullable<TextBlock>;
  78576. /**
  78577. * Creates a new Button
  78578. * @param name defines the name of the button
  78579. */
  78580. constructor(name?: string | undefined);
  78581. protected _getTypeName(): string;
  78582. /** @hidden */
  78583. _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78584. /** @hidden */
  78585. _onPointerEnter(target: Control): boolean;
  78586. /** @hidden */
  78587. _onPointerOut(target: Control, force?: boolean): void;
  78588. /** @hidden */
  78589. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78590. /** @hidden */
  78591. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78592. /**
  78593. * Creates a new button made with an image and a text
  78594. * @param name defines the name of the button
  78595. * @param text defines the text of the button
  78596. * @param imageUrl defines the url of the image
  78597. * @returns a new Button
  78598. */
  78599. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78600. /**
  78601. * Creates a new button made with an image
  78602. * @param name defines the name of the button
  78603. * @param imageUrl defines the url of the image
  78604. * @returns a new Button
  78605. */
  78606. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78607. /**
  78608. * Creates a new button made with a text
  78609. * @param name defines the name of the button
  78610. * @param text defines the text of the button
  78611. * @returns a new Button
  78612. */
  78613. static CreateSimpleButton(name: string, text: string): Button;
  78614. /**
  78615. * Creates a new button made with an image and a centered text
  78616. * @param name defines the name of the button
  78617. * @param text defines the text of the button
  78618. * @param imageUrl defines the url of the image
  78619. * @returns a new Button
  78620. */
  78621. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78622. }
  78623. }
  78624. declare module BABYLON.GUI {
  78625. /**
  78626. * Class used to create a 2D stack panel container
  78627. */
  78628. export class StackPanel extends Container {
  78629. name?: string | undefined;
  78630. private _isVertical;
  78631. private _manualWidth;
  78632. private _manualHeight;
  78633. private _doNotTrackManualChanges;
  78634. /**
  78635. * Gets or sets a boolean indicating that layou warnings should be ignored
  78636. */
  78637. ignoreLayoutWarnings: boolean;
  78638. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78639. get isVertical(): boolean;
  78640. set isVertical(value: boolean);
  78641. /**
  78642. * Gets or sets panel width.
  78643. * This value should not be set when in horizontal mode as it will be computed automatically
  78644. */
  78645. set width(value: string | number);
  78646. get width(): string | number;
  78647. /**
  78648. * Gets or sets panel height.
  78649. * This value should not be set when in vertical mode as it will be computed automatically
  78650. */
  78651. set height(value: string | number);
  78652. get height(): string | number;
  78653. /**
  78654. * Creates a new StackPanel
  78655. * @param name defines control name
  78656. */
  78657. constructor(name?: string | undefined);
  78658. protected _getTypeName(): string;
  78659. /** @hidden */
  78660. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78661. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78662. protected _postMeasure(): void;
  78663. }
  78664. }
  78665. declare module BABYLON.GUI {
  78666. /**
  78667. * Class used to represent a 2D checkbox
  78668. */
  78669. export class Checkbox extends Control {
  78670. name?: string | undefined;
  78671. private _isChecked;
  78672. private _background;
  78673. private _checkSizeRatio;
  78674. private _thickness;
  78675. /** Gets or sets border thickness */
  78676. get thickness(): number;
  78677. set thickness(value: number);
  78678. /**
  78679. * BABYLON.Observable raised when isChecked property changes
  78680. */
  78681. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78682. /** Gets or sets a value indicating the ratio between overall size and check size */
  78683. get checkSizeRatio(): number;
  78684. set checkSizeRatio(value: number);
  78685. /** Gets or sets background color */
  78686. get background(): string;
  78687. set background(value: string);
  78688. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78689. get isChecked(): boolean;
  78690. set isChecked(value: boolean);
  78691. /**
  78692. * Creates a new CheckBox
  78693. * @param name defines the control name
  78694. */
  78695. constructor(name?: string | undefined);
  78696. protected _getTypeName(): string;
  78697. /** @hidden */
  78698. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78699. /** @hidden */
  78700. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78701. /**
  78702. * Utility function to easily create a checkbox with a header
  78703. * @param title defines the label to use for the header
  78704. * @param onValueChanged defines the callback to call when value changes
  78705. * @returns a StackPanel containing the checkbox and a textBlock
  78706. */
  78707. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78708. }
  78709. }
  78710. declare module BABYLON.GUI {
  78711. /**
  78712. * Class used to store key control properties
  78713. */
  78714. export class KeyPropertySet {
  78715. /** Width */
  78716. width?: string;
  78717. /** Height */
  78718. height?: string;
  78719. /** Left padding */
  78720. paddingLeft?: string;
  78721. /** Right padding */
  78722. paddingRight?: string;
  78723. /** Top padding */
  78724. paddingTop?: string;
  78725. /** Bottom padding */
  78726. paddingBottom?: string;
  78727. /** Foreground color */
  78728. color?: string;
  78729. /** Background color */
  78730. background?: string;
  78731. }
  78732. /**
  78733. * Class used to create virtual keyboard
  78734. */
  78735. export class VirtualKeyboard extends StackPanel {
  78736. /** BABYLON.Observable raised when a key is pressed */
  78737. onKeyPressObservable: BABYLON.Observable<string>;
  78738. /** Gets or sets default key button width */
  78739. defaultButtonWidth: string;
  78740. /** Gets or sets default key button height */
  78741. defaultButtonHeight: string;
  78742. /** Gets or sets default key button left padding */
  78743. defaultButtonPaddingLeft: string;
  78744. /** Gets or sets default key button right padding */
  78745. defaultButtonPaddingRight: string;
  78746. /** Gets or sets default key button top padding */
  78747. defaultButtonPaddingTop: string;
  78748. /** Gets or sets default key button bottom padding */
  78749. defaultButtonPaddingBottom: string;
  78750. /** Gets or sets default key button foreground color */
  78751. defaultButtonColor: string;
  78752. /** Gets or sets default key button background color */
  78753. defaultButtonBackground: string;
  78754. /** Gets or sets shift button foreground color */
  78755. shiftButtonColor: string;
  78756. /** Gets or sets shift button thickness*/
  78757. selectedShiftThickness: number;
  78758. /** Gets shift key state */
  78759. shiftState: number;
  78760. protected _getTypeName(): string;
  78761. private _createKey;
  78762. /**
  78763. * Adds a new row of keys
  78764. * @param keys defines the list of keys to add
  78765. * @param propertySets defines the associated property sets
  78766. */
  78767. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78768. /**
  78769. * Set the shift key to a specific state
  78770. * @param shiftState defines the new shift state
  78771. */
  78772. applyShiftState(shiftState: number): void;
  78773. private _currentlyConnectedInputText;
  78774. private _connectedInputTexts;
  78775. private _onKeyPressObserver;
  78776. /** Gets the input text control currently attached to the keyboard */
  78777. get connectedInputText(): BABYLON.Nullable<InputText>;
  78778. /**
  78779. * Connects the keyboard with an input text control
  78780. *
  78781. * @param input defines the target control
  78782. */
  78783. connect(input: InputText): void;
  78784. /**
  78785. * Disconnects the keyboard from connected InputText controls
  78786. *
  78787. * @param input optionally defines a target control, otherwise all are disconnected
  78788. */
  78789. disconnect(input?: InputText): void;
  78790. private _removeConnectedInputObservables;
  78791. /**
  78792. * Release all resources
  78793. */
  78794. dispose(): void;
  78795. /**
  78796. * Creates a new keyboard using a default layout
  78797. *
  78798. * @param name defines control name
  78799. * @returns a new VirtualKeyboard
  78800. */
  78801. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78802. }
  78803. }
  78804. declare module BABYLON.GUI {
  78805. /**
  78806. * Class used to create input text control
  78807. */
  78808. export class InputText extends Control implements IFocusableControl {
  78809. name?: string | undefined;
  78810. private _text;
  78811. private _placeholderText;
  78812. private _background;
  78813. private _focusedBackground;
  78814. private _focusedColor;
  78815. private _placeholderColor;
  78816. private _thickness;
  78817. private _margin;
  78818. private _autoStretchWidth;
  78819. private _maxWidth;
  78820. private _isFocused;
  78821. private _blinkTimeout;
  78822. private _blinkIsEven;
  78823. private _cursorOffset;
  78824. private _scrollLeft;
  78825. private _textWidth;
  78826. private _clickedCoordinate;
  78827. private _deadKey;
  78828. private _addKey;
  78829. private _currentKey;
  78830. private _isTextHighlightOn;
  78831. private _textHighlightColor;
  78832. private _highligherOpacity;
  78833. private _highlightedText;
  78834. private _startHighlightIndex;
  78835. private _endHighlightIndex;
  78836. private _cursorIndex;
  78837. private _onFocusSelectAll;
  78838. private _isPointerDown;
  78839. private _onClipboardObserver;
  78840. private _onPointerDblTapObserver;
  78841. /** @hidden */
  78842. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78843. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78844. promptMessage: string;
  78845. /** Force disable prompt on mobile device */
  78846. disableMobilePrompt: boolean;
  78847. /** BABYLON.Observable raised when the text changes */
  78848. onTextChangedObservable: BABYLON.Observable<InputText>;
  78849. /** BABYLON.Observable raised just before an entered character is to be added */
  78850. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  78851. /** BABYLON.Observable raised when the control gets the focus */
  78852. onFocusObservable: BABYLON.Observable<InputText>;
  78853. /** BABYLON.Observable raised when the control loses the focus */
  78854. onBlurObservable: BABYLON.Observable<InputText>;
  78855. /**Observable raised when the text is highlighted */
  78856. onTextHighlightObservable: BABYLON.Observable<InputText>;
  78857. /**Observable raised when copy event is triggered */
  78858. onTextCopyObservable: BABYLON.Observable<InputText>;
  78859. /** BABYLON.Observable raised when cut event is triggered */
  78860. onTextCutObservable: BABYLON.Observable<InputText>;
  78861. /** BABYLON.Observable raised when paste event is triggered */
  78862. onTextPasteObservable: BABYLON.Observable<InputText>;
  78863. /** BABYLON.Observable raised when a key event was processed */
  78864. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  78865. /** Gets or sets the maximum width allowed by the control */
  78866. get maxWidth(): string | number;
  78867. /** Gets the maximum width allowed by the control in pixels */
  78868. get maxWidthInPixels(): number;
  78869. set maxWidth(value: string | number);
  78870. /** Gets or sets the text highlighter transparency; default: 0.4 */
  78871. get highligherOpacity(): number;
  78872. set highligherOpacity(value: number);
  78873. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  78874. get onFocusSelectAll(): boolean;
  78875. set onFocusSelectAll(value: boolean);
  78876. /** Gets or sets the text hightlight color */
  78877. get textHighlightColor(): string;
  78878. set textHighlightColor(value: string);
  78879. /** Gets or sets control margin */
  78880. get margin(): string;
  78881. /** Gets control margin in pixels */
  78882. get marginInPixels(): number;
  78883. set margin(value: string);
  78884. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  78885. get autoStretchWidth(): boolean;
  78886. set autoStretchWidth(value: boolean);
  78887. /** Gets or sets border thickness */
  78888. get thickness(): number;
  78889. set thickness(value: number);
  78890. /** Gets or sets the background color when focused */
  78891. get focusedBackground(): string;
  78892. set focusedBackground(value: string);
  78893. /** Gets or sets the background color when focused */
  78894. get focusedColor(): string;
  78895. set focusedColor(value: string);
  78896. /** Gets or sets the background color */
  78897. get background(): string;
  78898. set background(value: string);
  78899. /** Gets or sets the placeholder color */
  78900. get placeholderColor(): string;
  78901. set placeholderColor(value: string);
  78902. /** Gets or sets the text displayed when the control is empty */
  78903. get placeholderText(): string;
  78904. set placeholderText(value: string);
  78905. /** Gets or sets the dead key flag */
  78906. get deadKey(): boolean;
  78907. set deadKey(flag: boolean);
  78908. /** Gets or sets the highlight text */
  78909. get highlightedText(): string;
  78910. set highlightedText(text: string);
  78911. /** Gets or sets if the current key should be added */
  78912. get addKey(): boolean;
  78913. set addKey(flag: boolean);
  78914. /** Gets or sets the value of the current key being entered */
  78915. get currentKey(): string;
  78916. set currentKey(key: string);
  78917. /** Gets or sets the text displayed in the control */
  78918. get text(): string;
  78919. set text(value: string);
  78920. /** Gets or sets control width */
  78921. get width(): string | number;
  78922. set width(value: string | number);
  78923. /**
  78924. * Creates a new InputText
  78925. * @param name defines the control name
  78926. * @param text defines the text of the control
  78927. */
  78928. constructor(name?: string | undefined, text?: string);
  78929. /** @hidden */
  78930. onBlur(): void;
  78931. /** @hidden */
  78932. onFocus(): void;
  78933. protected _getTypeName(): string;
  78934. /**
  78935. * Function called to get the list of controls that should not steal the focus from this control
  78936. * @returns an array of controls
  78937. */
  78938. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  78939. /** @hidden */
  78940. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  78941. /** @hidden */
  78942. private _updateValueFromCursorIndex;
  78943. /** @hidden */
  78944. private _processDblClick;
  78945. /** @hidden */
  78946. private _selectAllText;
  78947. /**
  78948. * Handles the keyboard event
  78949. * @param evt Defines the KeyboardEvent
  78950. */
  78951. processKeyboard(evt: KeyboardEvent): void;
  78952. /** @hidden */
  78953. private _onCopyText;
  78954. /** @hidden */
  78955. private _onCutText;
  78956. /** @hidden */
  78957. private _onPasteText;
  78958. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78959. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  78960. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  78961. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  78962. protected _beforeRenderText(text: string): string;
  78963. dispose(): void;
  78964. }
  78965. }
  78966. declare module BABYLON.GUI {
  78967. /**
  78968. * Class used to create a 2D grid container
  78969. */
  78970. export class Grid extends Container {
  78971. name?: string | undefined;
  78972. private _rowDefinitions;
  78973. private _columnDefinitions;
  78974. private _cells;
  78975. private _childControls;
  78976. /**
  78977. * Gets the number of columns
  78978. */
  78979. get columnCount(): number;
  78980. /**
  78981. * Gets the number of rows
  78982. */
  78983. get rowCount(): number;
  78984. /** Gets the list of children */
  78985. get children(): Control[];
  78986. /** Gets the list of cells (e.g. the containers) */
  78987. get cells(): {
  78988. [key: string]: Container;
  78989. };
  78990. /**
  78991. * Gets the definition of a specific row
  78992. * @param index defines the index of the row
  78993. * @returns the row definition
  78994. */
  78995. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  78996. /**
  78997. * Gets the definition of a specific column
  78998. * @param index defines the index of the column
  78999. * @returns the column definition
  79000. */
  79001. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79002. /**
  79003. * Adds a new row to the grid
  79004. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79005. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79006. * @returns the current grid
  79007. */
  79008. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79009. /**
  79010. * Adds a new column to the grid
  79011. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79012. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79013. * @returns the current grid
  79014. */
  79015. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79016. /**
  79017. * Update a row definition
  79018. * @param index defines the index of the row to update
  79019. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79020. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79021. * @returns the current grid
  79022. */
  79023. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79024. /**
  79025. * Update a column definition
  79026. * @param index defines the index of the column to update
  79027. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79028. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79029. * @returns the current grid
  79030. */
  79031. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79032. /**
  79033. * Gets the list of children stored in a specific cell
  79034. * @param row defines the row to check
  79035. * @param column defines the column to check
  79036. * @returns the list of controls
  79037. */
  79038. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79039. /**
  79040. * Gets a string representing the child cell info (row x column)
  79041. * @param child defines the control to get info from
  79042. * @returns a string containing the child cell info (row x column)
  79043. */
  79044. getChildCellInfo(child: Control): string;
  79045. private _removeCell;
  79046. private _offsetCell;
  79047. /**
  79048. * Remove a column definition at specified index
  79049. * @param index defines the index of the column to remove
  79050. * @returns the current grid
  79051. */
  79052. removeColumnDefinition(index: number): Grid;
  79053. /**
  79054. * Remove a row definition at specified index
  79055. * @param index defines the index of the row to remove
  79056. * @returns the current grid
  79057. */
  79058. removeRowDefinition(index: number): Grid;
  79059. /**
  79060. * Adds a new control to the current grid
  79061. * @param control defines the control to add
  79062. * @param row defines the row where to add the control (0 by default)
  79063. * @param column defines the column where to add the control (0 by default)
  79064. * @returns the current grid
  79065. */
  79066. addControl(control: Control, row?: number, column?: number): Grid;
  79067. /**
  79068. * Removes a control from the current container
  79069. * @param control defines the control to remove
  79070. * @returns the current container
  79071. */
  79072. removeControl(control: Control): Container;
  79073. /**
  79074. * Creates a new Grid
  79075. * @param name defines control name
  79076. */
  79077. constructor(name?: string | undefined);
  79078. protected _getTypeName(): string;
  79079. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79080. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79081. _flagDescendantsAsMatrixDirty(): void;
  79082. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79083. /** Releases associated resources */
  79084. dispose(): void;
  79085. }
  79086. }
  79087. declare module BABYLON.GUI {
  79088. /** Class used to create color pickers */
  79089. export class ColorPicker extends Control {
  79090. name?: string | undefined;
  79091. private static _Epsilon;
  79092. private _colorWheelCanvas;
  79093. private _value;
  79094. private _tmpColor;
  79095. private _pointerStartedOnSquare;
  79096. private _pointerStartedOnWheel;
  79097. private _squareLeft;
  79098. private _squareTop;
  79099. private _squareSize;
  79100. private _h;
  79101. private _s;
  79102. private _v;
  79103. private _lastPointerDownID;
  79104. /**
  79105. * BABYLON.Observable raised when the value changes
  79106. */
  79107. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79108. /** Gets or sets the color of the color picker */
  79109. get value(): BABYLON.Color3;
  79110. set value(value: BABYLON.Color3);
  79111. /**
  79112. * Gets or sets control width
  79113. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79114. */
  79115. get width(): string | number;
  79116. set width(value: string | number);
  79117. /**
  79118. * Gets or sets control height
  79119. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79120. */
  79121. get height(): string | number;
  79122. /** Gets or sets control height */
  79123. set height(value: string | number);
  79124. /** Gets or sets control size */
  79125. get size(): string | number;
  79126. set size(value: string | number);
  79127. /**
  79128. * Creates a new ColorPicker
  79129. * @param name defines the control name
  79130. */
  79131. constructor(name?: string | undefined);
  79132. protected _getTypeName(): string;
  79133. /** @hidden */
  79134. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79135. private _updateSquareProps;
  79136. private _drawGradientSquare;
  79137. private _drawCircle;
  79138. private _createColorWheelCanvas;
  79139. /** @hidden */
  79140. _draw(context: CanvasRenderingContext2D): void;
  79141. private _pointerIsDown;
  79142. private _updateValueFromPointer;
  79143. private _isPointOnSquare;
  79144. private _isPointOnWheel;
  79145. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79146. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79147. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79148. _onCanvasBlur(): void;
  79149. /**
  79150. * This function expands the color picker by creating a color picker dialog with manual
  79151. * color value input and the ability to save colors into an array to be used later in
  79152. * subsequent launches of the dialogue.
  79153. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79154. * @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.
  79155. * @returns picked color as a hex string and the saved colors array as hex strings.
  79156. */
  79157. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79158. pickerWidth?: string;
  79159. pickerHeight?: string;
  79160. headerHeight?: string;
  79161. lastColor?: string;
  79162. swatchLimit?: number;
  79163. numSwatchesPerLine?: number;
  79164. savedColors?: Array<string>;
  79165. }): Promise<{
  79166. savedColors?: string[];
  79167. pickedColor: string;
  79168. }>;
  79169. }
  79170. }
  79171. declare module BABYLON.GUI {
  79172. /** Class used to create 2D ellipse containers */
  79173. export class Ellipse extends Container {
  79174. name?: string | undefined;
  79175. private _thickness;
  79176. /** Gets or sets border thickness */
  79177. get thickness(): number;
  79178. set thickness(value: number);
  79179. /**
  79180. * Creates a new Ellipse
  79181. * @param name defines the control name
  79182. */
  79183. constructor(name?: string | undefined);
  79184. protected _getTypeName(): string;
  79185. protected _localDraw(context: CanvasRenderingContext2D): void;
  79186. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79187. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79188. }
  79189. }
  79190. declare module BABYLON.GUI {
  79191. /**
  79192. * Class used to create a password control
  79193. */
  79194. export class InputPassword extends InputText {
  79195. protected _beforeRenderText(text: string): string;
  79196. }
  79197. }
  79198. declare module BABYLON.GUI {
  79199. /** Class used to render 2D lines */
  79200. export class Line extends Control {
  79201. name?: string | undefined;
  79202. private _lineWidth;
  79203. private _x1;
  79204. private _y1;
  79205. private _x2;
  79206. private _y2;
  79207. private _dash;
  79208. private _connectedControl;
  79209. private _connectedControlDirtyObserver;
  79210. /** Gets or sets the dash pattern */
  79211. get dash(): Array<number>;
  79212. set dash(value: Array<number>);
  79213. /** Gets or sets the control connected with the line end */
  79214. get connectedControl(): Control;
  79215. set connectedControl(value: Control);
  79216. /** Gets or sets start coordinates on X axis */
  79217. get x1(): string | number;
  79218. set x1(value: string | number);
  79219. /** Gets or sets start coordinates on Y axis */
  79220. get y1(): string | number;
  79221. set y1(value: string | number);
  79222. /** Gets or sets end coordinates on X axis */
  79223. get x2(): string | number;
  79224. set x2(value: string | number);
  79225. /** Gets or sets end coordinates on Y axis */
  79226. get y2(): string | number;
  79227. set y2(value: string | number);
  79228. /** Gets or sets line width */
  79229. get lineWidth(): number;
  79230. set lineWidth(value: number);
  79231. /** Gets or sets horizontal alignment */
  79232. set horizontalAlignment(value: number);
  79233. /** Gets or sets vertical alignment */
  79234. set verticalAlignment(value: number);
  79235. private get _effectiveX2();
  79236. private get _effectiveY2();
  79237. /**
  79238. * Creates a new Line
  79239. * @param name defines the control name
  79240. */
  79241. constructor(name?: string | undefined);
  79242. protected _getTypeName(): string;
  79243. _draw(context: CanvasRenderingContext2D): void;
  79244. _measure(): void;
  79245. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79246. /**
  79247. * Move one end of the line given 3D cartesian coordinates.
  79248. * @param position Targeted world position
  79249. * @param scene BABYLON.Scene
  79250. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79251. */
  79252. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79253. /**
  79254. * Move one end of the line to a position in screen absolute space.
  79255. * @param projectedPosition Position in screen absolute space (X, Y)
  79256. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79257. */
  79258. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79259. }
  79260. }
  79261. declare module BABYLON.GUI {
  79262. /**
  79263. * Class used to store a point for a MultiLine object.
  79264. * The point can be pure 2D coordinates, a mesh or a control
  79265. */
  79266. export class MultiLinePoint {
  79267. private _multiLine;
  79268. private _x;
  79269. private _y;
  79270. private _control;
  79271. private _mesh;
  79272. private _controlObserver;
  79273. private _meshObserver;
  79274. /** @hidden */
  79275. _point: BABYLON.Vector2;
  79276. /**
  79277. * Creates a new MultiLinePoint
  79278. * @param multiLine defines the source MultiLine object
  79279. */
  79280. constructor(multiLine: MultiLine);
  79281. /** Gets or sets x coordinate */
  79282. get x(): string | number;
  79283. set x(value: string | number);
  79284. /** Gets or sets y coordinate */
  79285. get y(): string | number;
  79286. set y(value: string | number);
  79287. /** Gets or sets the control associated with this point */
  79288. get control(): BABYLON.Nullable<Control>;
  79289. set control(value: BABYLON.Nullable<Control>);
  79290. /** Gets or sets the mesh associated with this point */
  79291. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79292. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79293. /** Resets links */
  79294. resetLinks(): void;
  79295. /**
  79296. * Gets a translation vector
  79297. * @returns the translation vector
  79298. */
  79299. translate(): BABYLON.Vector2;
  79300. private _translatePoint;
  79301. /** Release associated resources */
  79302. dispose(): void;
  79303. }
  79304. }
  79305. declare module BABYLON.GUI {
  79306. /**
  79307. * Class used to create multi line control
  79308. */
  79309. export class MultiLine extends Control {
  79310. name?: string | undefined;
  79311. private _lineWidth;
  79312. private _dash;
  79313. private _points;
  79314. private _minX;
  79315. private _minY;
  79316. private _maxX;
  79317. private _maxY;
  79318. /**
  79319. * Creates a new MultiLine
  79320. * @param name defines the control name
  79321. */
  79322. constructor(name?: string | undefined);
  79323. /** Gets or sets dash pattern */
  79324. get dash(): Array<number>;
  79325. set dash(value: Array<number>);
  79326. /**
  79327. * Gets point stored at specified index
  79328. * @param index defines the index to look for
  79329. * @returns the requested point if found
  79330. */
  79331. getAt(index: number): MultiLinePoint;
  79332. /** Function called when a point is updated */
  79333. onPointUpdate: () => void;
  79334. /**
  79335. * Adds new points to the point collection
  79336. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79337. * @returns the list of created MultiLinePoint
  79338. */
  79339. add(...items: (AbstractMesh | Control | {
  79340. x: string | number;
  79341. y: string | number;
  79342. })[]): MultiLinePoint[];
  79343. /**
  79344. * Adds a new point to the point collection
  79345. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79346. * @returns the created MultiLinePoint
  79347. */
  79348. push(item?: (AbstractMesh | Control | {
  79349. x: string | number;
  79350. y: string | number;
  79351. })): MultiLinePoint;
  79352. /**
  79353. * Remove a specific value or point from the active point collection
  79354. * @param value defines the value or point to remove
  79355. */
  79356. remove(value: number | MultiLinePoint): void;
  79357. /**
  79358. * Resets this object to initial state (no point)
  79359. */
  79360. reset(): void;
  79361. /**
  79362. * Resets all links
  79363. */
  79364. resetLinks(): void;
  79365. /** Gets or sets line width */
  79366. get lineWidth(): number;
  79367. set lineWidth(value: number);
  79368. set horizontalAlignment(value: number);
  79369. set verticalAlignment(value: number);
  79370. protected _getTypeName(): string;
  79371. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79372. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79373. _measure(): void;
  79374. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79375. dispose(): void;
  79376. }
  79377. }
  79378. declare module BABYLON.GUI {
  79379. /**
  79380. * Class used to create radio button controls
  79381. */
  79382. export class RadioButton extends Control {
  79383. name?: string | undefined;
  79384. private _isChecked;
  79385. private _background;
  79386. private _checkSizeRatio;
  79387. private _thickness;
  79388. /** Gets or sets border thickness */
  79389. get thickness(): number;
  79390. set thickness(value: number);
  79391. /** Gets or sets group name */
  79392. group: string;
  79393. /** BABYLON.Observable raised when isChecked is changed */
  79394. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79395. /** Gets or sets a value indicating the ratio between overall size and check size */
  79396. get checkSizeRatio(): number;
  79397. set checkSizeRatio(value: number);
  79398. /** Gets or sets background color */
  79399. get background(): string;
  79400. set background(value: string);
  79401. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79402. get isChecked(): boolean;
  79403. set isChecked(value: boolean);
  79404. /**
  79405. * Creates a new RadioButton
  79406. * @param name defines the control name
  79407. */
  79408. constructor(name?: string | undefined);
  79409. protected _getTypeName(): string;
  79410. _draw(context: CanvasRenderingContext2D): void;
  79411. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79412. /**
  79413. * Utility function to easily create a radio button with a header
  79414. * @param title defines the label to use for the header
  79415. * @param group defines the group to use for the radio button
  79416. * @param isChecked defines the initial state of the radio button
  79417. * @param onValueChanged defines the callback to call when value changes
  79418. * @returns a StackPanel containing the radio button and a textBlock
  79419. */
  79420. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79421. }
  79422. }
  79423. declare module BABYLON.GUI {
  79424. /**
  79425. * Class used to create slider controls
  79426. */
  79427. export class BaseSlider extends Control {
  79428. name?: string | undefined;
  79429. protected _thumbWidth: ValueAndUnit;
  79430. private _minimum;
  79431. private _maximum;
  79432. private _value;
  79433. private _isVertical;
  79434. protected _barOffset: ValueAndUnit;
  79435. private _isThumbClamped;
  79436. protected _displayThumb: boolean;
  79437. private _step;
  79438. private _lastPointerDownID;
  79439. protected _effectiveBarOffset: number;
  79440. protected _renderLeft: number;
  79441. protected _renderTop: number;
  79442. protected _renderWidth: number;
  79443. protected _renderHeight: number;
  79444. protected _backgroundBoxLength: number;
  79445. protected _backgroundBoxThickness: number;
  79446. protected _effectiveThumbThickness: number;
  79447. /** BABYLON.Observable raised when the sldier value changes */
  79448. onValueChangedObservable: BABYLON.Observable<number>;
  79449. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79450. get displayThumb(): boolean;
  79451. set displayThumb(value: boolean);
  79452. /** Gets or sets a step to apply to values (0 by default) */
  79453. get step(): number;
  79454. set step(value: number);
  79455. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79456. get barOffset(): string | number;
  79457. /** Gets main bar offset in pixels*/
  79458. get barOffsetInPixels(): number;
  79459. set barOffset(value: string | number);
  79460. /** Gets or sets thumb width */
  79461. get thumbWidth(): string | number;
  79462. /** Gets thumb width in pixels */
  79463. get thumbWidthInPixels(): number;
  79464. set thumbWidth(value: string | number);
  79465. /** Gets or sets minimum value */
  79466. get minimum(): number;
  79467. set minimum(value: number);
  79468. /** Gets or sets maximum value */
  79469. get maximum(): number;
  79470. set maximum(value: number);
  79471. /** Gets or sets current value */
  79472. get value(): number;
  79473. set value(value: number);
  79474. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79475. get isVertical(): boolean;
  79476. set isVertical(value: boolean);
  79477. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79478. get isThumbClamped(): boolean;
  79479. set isThumbClamped(value: boolean);
  79480. /**
  79481. * Creates a new BaseSlider
  79482. * @param name defines the control name
  79483. */
  79484. constructor(name?: string | undefined);
  79485. protected _getTypeName(): string;
  79486. protected _getThumbPosition(): number;
  79487. protected _getThumbThickness(type: string): number;
  79488. protected _prepareRenderingData(type: string): void;
  79489. private _pointerIsDown;
  79490. /** @hidden */
  79491. protected _updateValueFromPointer(x: number, y: number): void;
  79492. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79493. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  79494. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79495. _onCanvasBlur(): void;
  79496. }
  79497. }
  79498. declare module BABYLON.GUI {
  79499. /**
  79500. * Class used to create slider controls
  79501. */
  79502. export class Slider extends BaseSlider {
  79503. name?: string | undefined;
  79504. private _background;
  79505. private _borderColor;
  79506. private _thumbColor;
  79507. private _isThumbCircle;
  79508. protected _displayValueBar: boolean;
  79509. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79510. get displayValueBar(): boolean;
  79511. set displayValueBar(value: boolean);
  79512. /** Gets or sets border color */
  79513. get borderColor(): string;
  79514. set borderColor(value: string);
  79515. /** Gets or sets background color */
  79516. get background(): string;
  79517. set background(value: string);
  79518. /** Gets or sets thumb's color */
  79519. get thumbColor(): string;
  79520. set thumbColor(value: string);
  79521. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79522. get isThumbCircle(): boolean;
  79523. set isThumbCircle(value: boolean);
  79524. /**
  79525. * Creates a new Slider
  79526. * @param name defines the control name
  79527. */
  79528. constructor(name?: string | undefined);
  79529. protected _getTypeName(): string;
  79530. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79531. }
  79532. }
  79533. declare module BABYLON.GUI {
  79534. /** Class used to create a RadioGroup
  79535. * which contains groups of radio buttons
  79536. */
  79537. export class SelectorGroup {
  79538. /** name of SelectorGroup */
  79539. name: string;
  79540. private _groupPanel;
  79541. private _selectors;
  79542. private _groupHeader;
  79543. /**
  79544. * Creates a new SelectorGroup
  79545. * @param name of group, used as a group heading
  79546. */
  79547. constructor(
  79548. /** name of SelectorGroup */
  79549. name: string);
  79550. /** Gets the groupPanel of the SelectorGroup */
  79551. get groupPanel(): StackPanel;
  79552. /** Gets the selectors array */
  79553. get selectors(): StackPanel[];
  79554. /** Gets and sets the group header */
  79555. get header(): string;
  79556. set header(label: string);
  79557. /** @hidden */
  79558. private _addGroupHeader;
  79559. /** @hidden*/
  79560. _getSelector(selectorNb: number): StackPanel | undefined;
  79561. /** Removes the selector at the given position
  79562. * @param selectorNb the position of the selector within the group
  79563. */
  79564. removeSelector(selectorNb: number): void;
  79565. }
  79566. /** Class used to create a CheckboxGroup
  79567. * which contains groups of checkbox buttons
  79568. */
  79569. export class CheckboxGroup extends SelectorGroup {
  79570. /** Adds a checkbox as a control
  79571. * @param text is the label for the selector
  79572. * @param func is the function called when the Selector is checked
  79573. * @param checked is true when Selector is checked
  79574. */
  79575. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79576. /** @hidden */
  79577. _setSelectorLabel(selectorNb: number, label: string): void;
  79578. /** @hidden */
  79579. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79580. /** @hidden */
  79581. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79582. /** @hidden */
  79583. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79584. }
  79585. /** Class used to create a RadioGroup
  79586. * which contains groups of radio buttons
  79587. */
  79588. export class RadioGroup extends SelectorGroup {
  79589. private _selectNb;
  79590. /** Adds a radio button as a control
  79591. * @param label is the label for the selector
  79592. * @param func is the function called when the Selector is checked
  79593. * @param checked is true when Selector is checked
  79594. */
  79595. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79596. /** @hidden */
  79597. _setSelectorLabel(selectorNb: number, label: string): void;
  79598. /** @hidden */
  79599. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79600. /** @hidden */
  79601. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79602. /** @hidden */
  79603. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79604. }
  79605. /** Class used to create a SliderGroup
  79606. * which contains groups of slider buttons
  79607. */
  79608. export class SliderGroup extends SelectorGroup {
  79609. /**
  79610. * Adds a slider to the SelectorGroup
  79611. * @param label is the label for the SliderBar
  79612. * @param func is the function called when the Slider moves
  79613. * @param unit is a string describing the units used, eg degrees or metres
  79614. * @param min is the minimum value for the Slider
  79615. * @param max is the maximum value for the Slider
  79616. * @param value is the start value for the Slider between min and max
  79617. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79618. */
  79619. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79620. /** @hidden */
  79621. _setSelectorLabel(selectorNb: number, label: string): void;
  79622. /** @hidden */
  79623. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79624. /** @hidden */
  79625. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79626. /** @hidden */
  79627. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79628. }
  79629. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79630. * @see https://doc.babylonjs.com/how_to/selector
  79631. */
  79632. export class SelectionPanel extends Rectangle {
  79633. /** name of SelectionPanel */
  79634. name: string;
  79635. /** an array of SelectionGroups */
  79636. groups: SelectorGroup[];
  79637. private _panel;
  79638. private _buttonColor;
  79639. private _buttonBackground;
  79640. private _headerColor;
  79641. private _barColor;
  79642. private _barHeight;
  79643. private _spacerHeight;
  79644. private _labelColor;
  79645. private _groups;
  79646. private _bars;
  79647. /**
  79648. * Creates a new SelectionPanel
  79649. * @param name of SelectionPanel
  79650. * @param groups is an array of SelectionGroups
  79651. */
  79652. constructor(
  79653. /** name of SelectionPanel */
  79654. name: string,
  79655. /** an array of SelectionGroups */
  79656. groups?: SelectorGroup[]);
  79657. protected _getTypeName(): string;
  79658. /** Gets the (stack) panel of the SelectionPanel */
  79659. get panel(): StackPanel;
  79660. /** Gets or sets the headerColor */
  79661. get headerColor(): string;
  79662. set headerColor(color: string);
  79663. private _setHeaderColor;
  79664. /** Gets or sets the button color */
  79665. get buttonColor(): string;
  79666. set buttonColor(color: string);
  79667. private _setbuttonColor;
  79668. /** Gets or sets the label color */
  79669. get labelColor(): string;
  79670. set labelColor(color: string);
  79671. private _setLabelColor;
  79672. /** Gets or sets the button background */
  79673. get buttonBackground(): string;
  79674. set buttonBackground(color: string);
  79675. private _setButtonBackground;
  79676. /** Gets or sets the color of separator bar */
  79677. get barColor(): string;
  79678. set barColor(color: string);
  79679. private _setBarColor;
  79680. /** Gets or sets the height of separator bar */
  79681. get barHeight(): string;
  79682. set barHeight(value: string);
  79683. private _setBarHeight;
  79684. /** Gets or sets the height of spacers*/
  79685. get spacerHeight(): string;
  79686. set spacerHeight(value: string);
  79687. private _setSpacerHeight;
  79688. /** Adds a bar between groups */
  79689. private _addSpacer;
  79690. /** Add a group to the selection panel
  79691. * @param group is the selector group to add
  79692. */
  79693. addGroup(group: SelectorGroup): void;
  79694. /** Remove the group from the given position
  79695. * @param groupNb is the position of the group in the list
  79696. */
  79697. removeGroup(groupNb: number): void;
  79698. /** Change a group header label
  79699. * @param label is the new group header label
  79700. * @param groupNb is the number of the group to relabel
  79701. * */
  79702. setHeaderName(label: string, groupNb: number): void;
  79703. /** Change selector label to the one given
  79704. * @param label is the new selector label
  79705. * @param groupNb is the number of the groupcontaining the selector
  79706. * @param selectorNb is the number of the selector within a group to relabel
  79707. * */
  79708. relabel(label: string, groupNb: number, selectorNb: number): void;
  79709. /** For a given group position remove the selector at the given position
  79710. * @param groupNb is the number of the group to remove the selector from
  79711. * @param selectorNb is the number of the selector within the group
  79712. */
  79713. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79714. /** For a given group position of correct type add a checkbox button
  79715. * @param groupNb is the number of the group to remove the selector from
  79716. * @param label is the label for the selector
  79717. * @param func is the function called when the Selector is checked
  79718. * @param checked is true when Selector is checked
  79719. */
  79720. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79721. /** For a given group position of correct type add a radio button
  79722. * @param groupNb is the number of the group to remove the selector from
  79723. * @param label is the label for the selector
  79724. * @param func is the function called when the Selector is checked
  79725. * @param checked is true when Selector is checked
  79726. */
  79727. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79728. /**
  79729. * For a given slider group add a slider
  79730. * @param groupNb is the number of the group to add the slider to
  79731. * @param label is the label for the Slider
  79732. * @param func is the function called when the Slider moves
  79733. * @param unit is a string describing the units used, eg degrees or metres
  79734. * @param min is the minimum value for the Slider
  79735. * @param max is the maximum value for the Slider
  79736. * @param value is the start value for the Slider between min and max
  79737. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79738. */
  79739. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79740. }
  79741. }
  79742. declare module BABYLON.GUI {
  79743. /**
  79744. * Class used to hold a the container for ScrollViewer
  79745. * @hidden
  79746. */
  79747. export class _ScrollViewerWindow extends Container {
  79748. parentClientWidth: number;
  79749. parentClientHeight: number;
  79750. private _freezeControls;
  79751. private _parentMeasure;
  79752. private _oldLeft;
  79753. private _oldTop;
  79754. get freezeControls(): boolean;
  79755. set freezeControls(value: boolean);
  79756. private _bucketWidth;
  79757. private _bucketHeight;
  79758. private _buckets;
  79759. private _bucketLen;
  79760. get bucketWidth(): number;
  79761. get bucketHeight(): number;
  79762. setBucketSizes(width: number, height: number): void;
  79763. private _useBuckets;
  79764. private _makeBuckets;
  79765. private _dispatchInBuckets;
  79766. private _updateMeasures;
  79767. private _updateChildrenMeasures;
  79768. private _restoreMeasures;
  79769. /**
  79770. * Creates a new ScrollViewerWindow
  79771. * @param name of ScrollViewerWindow
  79772. */
  79773. constructor(name?: string);
  79774. protected _getTypeName(): string;
  79775. /** @hidden */
  79776. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79777. /** @hidden */
  79778. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79779. private _scrollChildren;
  79780. private _scrollChildrenWithBuckets;
  79781. /** @hidden */
  79782. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79783. protected _postMeasure(): void;
  79784. }
  79785. }
  79786. declare module BABYLON.GUI {
  79787. /**
  79788. * Class used to create slider controls
  79789. */
  79790. export class ScrollBar extends BaseSlider {
  79791. name?: string | undefined;
  79792. private _background;
  79793. private _borderColor;
  79794. private _tempMeasure;
  79795. /** Gets or sets border color */
  79796. get borderColor(): string;
  79797. set borderColor(value: string);
  79798. /** Gets or sets background color */
  79799. get background(): string;
  79800. set background(value: string);
  79801. /**
  79802. * Creates a new Slider
  79803. * @param name defines the control name
  79804. */
  79805. constructor(name?: string | undefined);
  79806. protected _getTypeName(): string;
  79807. protected _getThumbThickness(): number;
  79808. _draw(context: CanvasRenderingContext2D): void;
  79809. private _first;
  79810. private _originX;
  79811. private _originY;
  79812. /** @hidden */
  79813. protected _updateValueFromPointer(x: number, y: number): void;
  79814. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79815. }
  79816. }
  79817. declare module BABYLON.GUI {
  79818. /**
  79819. * Class used to create slider controls
  79820. */
  79821. export class ImageScrollBar extends BaseSlider {
  79822. name?: string | undefined;
  79823. private _backgroundBaseImage;
  79824. private _backgroundImage;
  79825. private _thumbImage;
  79826. private _thumbBaseImage;
  79827. private _thumbLength;
  79828. private _thumbHeight;
  79829. private _barImageHeight;
  79830. private _tempMeasure;
  79831. /** Number of 90° rotation to apply on the images when in vertical mode */
  79832. num90RotationInVerticalMode: number;
  79833. /**
  79834. * Gets or sets the image used to render the background for horizontal bar
  79835. */
  79836. get backgroundImage(): Image;
  79837. set backgroundImage(value: Image);
  79838. /**
  79839. * Gets or sets the image used to render the thumb
  79840. */
  79841. get thumbImage(): Image;
  79842. set thumbImage(value: Image);
  79843. /**
  79844. * Gets or sets the length of the thumb
  79845. */
  79846. get thumbLength(): number;
  79847. set thumbLength(value: number);
  79848. /**
  79849. * Gets or sets the height of the thumb
  79850. */
  79851. get thumbHeight(): number;
  79852. set thumbHeight(value: number);
  79853. /**
  79854. * Gets or sets the height of the bar image
  79855. */
  79856. get barImageHeight(): number;
  79857. set barImageHeight(value: number);
  79858. /**
  79859. * Creates a new ImageScrollBar
  79860. * @param name defines the control name
  79861. */
  79862. constructor(name?: string | undefined);
  79863. protected _getTypeName(): string;
  79864. protected _getThumbThickness(): number;
  79865. _draw(context: CanvasRenderingContext2D): void;
  79866. private _first;
  79867. private _originX;
  79868. private _originY;
  79869. /** @hidden */
  79870. protected _updateValueFromPointer(x: number, y: number): void;
  79871. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  79872. }
  79873. }
  79874. declare module BABYLON.GUI {
  79875. /**
  79876. * Class used to hold a viewer window and sliders in a grid
  79877. */
  79878. export class ScrollViewer extends Rectangle {
  79879. private _grid;
  79880. private _horizontalBarSpace;
  79881. private _verticalBarSpace;
  79882. private _dragSpace;
  79883. private _horizontalBar;
  79884. private _verticalBar;
  79885. private _barColor;
  79886. private _barBackground;
  79887. private _barImage;
  79888. private _horizontalBarImage;
  79889. private _verticalBarImage;
  79890. private _barBackgroundImage;
  79891. private _horizontalBarBackgroundImage;
  79892. private _verticalBarBackgroundImage;
  79893. private _barSize;
  79894. private _window;
  79895. private _pointerIsOver;
  79896. private _wheelPrecision;
  79897. private _onWheelObserver;
  79898. private _clientWidth;
  79899. private _clientHeight;
  79900. private _useImageBar;
  79901. private _thumbLength;
  79902. private _thumbHeight;
  79903. private _barImageHeight;
  79904. private _horizontalBarImageHeight;
  79905. private _verticalBarImageHeight;
  79906. private _oldWindowContentsWidth;
  79907. private _oldWindowContentsHeight;
  79908. /**
  79909. * Gets the horizontal scrollbar
  79910. */
  79911. get horizontalBar(): ScrollBar | ImageScrollBar;
  79912. /**
  79913. * Gets the vertical scrollbar
  79914. */
  79915. get verticalBar(): ScrollBar | ImageScrollBar;
  79916. /**
  79917. * Adds a new control to the current container
  79918. * @param control defines the control to add
  79919. * @returns the current container
  79920. */
  79921. addControl(control: BABYLON.Nullable<Control>): Container;
  79922. /**
  79923. * Removes a control from the current container
  79924. * @param control defines the control to remove
  79925. * @returns the current container
  79926. */
  79927. removeControl(control: Control): Container;
  79928. /** Gets the list of children */
  79929. get children(): Control[];
  79930. _flagDescendantsAsMatrixDirty(): void;
  79931. /**
  79932. * Freezes or unfreezes the controls in the window.
  79933. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  79934. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  79935. */
  79936. get freezeControls(): boolean;
  79937. set freezeControls(value: boolean);
  79938. /** Gets the bucket width */
  79939. get bucketWidth(): number;
  79940. /** Gets the bucket height */
  79941. get bucketHeight(): number;
  79942. /**
  79943. * Sets the bucket sizes.
  79944. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  79945. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  79946. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  79947. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  79948. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  79949. * used), that's why it is not enabled by default.
  79950. * @param width width of the bucket
  79951. * @param height height of the bucket
  79952. */
  79953. setBucketSizes(width: number, height: number): void;
  79954. private _forceHorizontalBar;
  79955. private _forceVerticalBar;
  79956. /**
  79957. * Forces the horizontal scroll bar to be displayed
  79958. */
  79959. get forceHorizontalBar(): boolean;
  79960. set forceHorizontalBar(value: boolean);
  79961. /**
  79962. * Forces the vertical scroll bar to be displayed
  79963. */
  79964. get forceVerticalBar(): boolean;
  79965. set forceVerticalBar(value: boolean);
  79966. /**
  79967. * Creates a new ScrollViewer
  79968. * @param name of ScrollViewer
  79969. */
  79970. constructor(name?: string, isImageBased?: boolean);
  79971. /** Reset the scroll viewer window to initial size */
  79972. resetWindow(): void;
  79973. protected _getTypeName(): string;
  79974. private _buildClientSizes;
  79975. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79976. protected _postMeasure(): void;
  79977. /**
  79978. * Gets or sets the mouse wheel precision
  79979. * from 0 to 1 with a default value of 0.05
  79980. * */
  79981. get wheelPrecision(): number;
  79982. set wheelPrecision(value: number);
  79983. /** Gets or sets the scroll bar container background color */
  79984. get scrollBackground(): string;
  79985. set scrollBackground(color: string);
  79986. /** Gets or sets the bar color */
  79987. get barColor(): string;
  79988. set barColor(color: string);
  79989. /** Gets or sets the bar image */
  79990. get thumbImage(): Image;
  79991. set thumbImage(value: Image);
  79992. /** Gets or sets the horizontal bar image */
  79993. get horizontalThumbImage(): Image;
  79994. set horizontalThumbImage(value: Image);
  79995. /** Gets or sets the vertical bar image */
  79996. get verticalThumbImage(): Image;
  79997. set verticalThumbImage(value: Image);
  79998. /** Gets or sets the size of the bar */
  79999. get barSize(): number;
  80000. set barSize(value: number);
  80001. /** Gets or sets the length of the thumb */
  80002. get thumbLength(): number;
  80003. set thumbLength(value: number);
  80004. /** Gets or sets the height of the thumb */
  80005. get thumbHeight(): number;
  80006. set thumbHeight(value: number);
  80007. /** Gets or sets the height of the bar image */
  80008. get barImageHeight(): number;
  80009. set barImageHeight(value: number);
  80010. /** Gets or sets the height of the horizontal bar image */
  80011. get horizontalBarImageHeight(): number;
  80012. set horizontalBarImageHeight(value: number);
  80013. /** Gets or sets the height of the vertical bar image */
  80014. get verticalBarImageHeight(): number;
  80015. set verticalBarImageHeight(value: number);
  80016. /** Gets or sets the bar background */
  80017. get barBackground(): string;
  80018. set barBackground(color: string);
  80019. /** Gets or sets the bar background image */
  80020. get barImage(): Image;
  80021. set barImage(value: Image);
  80022. /** Gets or sets the horizontal bar background image */
  80023. get horizontalBarImage(): Image;
  80024. set horizontalBarImage(value: Image);
  80025. /** Gets or sets the vertical bar background image */
  80026. get verticalBarImage(): Image;
  80027. set verticalBarImage(value: Image);
  80028. private _setWindowPosition;
  80029. /** @hidden */
  80030. private _updateScroller;
  80031. _link(host: AdvancedDynamicTexture): void;
  80032. /** @hidden */
  80033. private _addBar;
  80034. /** @hidden */
  80035. private _attachWheel;
  80036. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80037. /** Releases associated resources */
  80038. dispose(): void;
  80039. }
  80040. }
  80041. declare module BABYLON.GUI {
  80042. /** Class used to render a grid */
  80043. export class DisplayGrid extends Control {
  80044. name?: string | undefined;
  80045. private _cellWidth;
  80046. private _cellHeight;
  80047. private _minorLineTickness;
  80048. private _minorLineColor;
  80049. private _majorLineTickness;
  80050. private _majorLineColor;
  80051. private _majorLineFrequency;
  80052. private _background;
  80053. private _displayMajorLines;
  80054. private _displayMinorLines;
  80055. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80056. get displayMinorLines(): boolean;
  80057. set displayMinorLines(value: boolean);
  80058. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80059. get displayMajorLines(): boolean;
  80060. set displayMajorLines(value: boolean);
  80061. /** Gets or sets background color (Black by default) */
  80062. get background(): string;
  80063. set background(value: string);
  80064. /** Gets or sets the width of each cell (20 by default) */
  80065. get cellWidth(): number;
  80066. set cellWidth(value: number);
  80067. /** Gets or sets the height of each cell (20 by default) */
  80068. get cellHeight(): number;
  80069. set cellHeight(value: number);
  80070. /** Gets or sets the tickness of minor lines (1 by default) */
  80071. get minorLineTickness(): number;
  80072. set minorLineTickness(value: number);
  80073. /** Gets or sets the color of minor lines (DarkGray by default) */
  80074. get minorLineColor(): string;
  80075. set minorLineColor(value: string);
  80076. /** Gets or sets the tickness of major lines (2 by default) */
  80077. get majorLineTickness(): number;
  80078. set majorLineTickness(value: number);
  80079. /** Gets or sets the color of major lines (White by default) */
  80080. get majorLineColor(): string;
  80081. set majorLineColor(value: string);
  80082. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80083. get majorLineFrequency(): number;
  80084. set majorLineFrequency(value: number);
  80085. /**
  80086. * Creates a new GridDisplayRectangle
  80087. * @param name defines the control name
  80088. */
  80089. constructor(name?: string | undefined);
  80090. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80091. protected _getTypeName(): string;
  80092. }
  80093. }
  80094. declare module BABYLON.GUI {
  80095. /**
  80096. * Class used to create slider controls based on images
  80097. */
  80098. export class ImageBasedSlider extends BaseSlider {
  80099. name?: string | undefined;
  80100. private _backgroundImage;
  80101. private _thumbImage;
  80102. private _valueBarImage;
  80103. private _tempMeasure;
  80104. get displayThumb(): boolean;
  80105. set displayThumb(value: boolean);
  80106. /**
  80107. * Gets or sets the image used to render the background
  80108. */
  80109. get backgroundImage(): Image;
  80110. set backgroundImage(value: Image);
  80111. /**
  80112. * Gets or sets the image used to render the value bar
  80113. */
  80114. get valueBarImage(): Image;
  80115. set valueBarImage(value: Image);
  80116. /**
  80117. * Gets or sets the image used to render the thumb
  80118. */
  80119. get thumbImage(): Image;
  80120. set thumbImage(value: Image);
  80121. /**
  80122. * Creates a new ImageBasedSlider
  80123. * @param name defines the control name
  80124. */
  80125. constructor(name?: string | undefined);
  80126. protected _getTypeName(): string;
  80127. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80128. }
  80129. }
  80130. declare module BABYLON.GUI {
  80131. /**
  80132. * Forcing an export so that this code will execute
  80133. * @hidden
  80134. */
  80135. const name = "Statics";
  80136. }
  80137. declare module BABYLON.GUI {
  80138. /**
  80139. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80140. */
  80141. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80142. /**
  80143. * Define the instrumented AdvancedDynamicTexture.
  80144. */
  80145. texture: AdvancedDynamicTexture;
  80146. private _captureRenderTime;
  80147. private _renderTime;
  80148. private _captureLayoutTime;
  80149. private _layoutTime;
  80150. private _onBeginRenderObserver;
  80151. private _onEndRenderObserver;
  80152. private _onBeginLayoutObserver;
  80153. private _onEndLayoutObserver;
  80154. /**
  80155. * Gets the perf counter used to capture render time
  80156. */
  80157. get renderTimeCounter(): BABYLON.PerfCounter;
  80158. /**
  80159. * Gets the perf counter used to capture layout time
  80160. */
  80161. get layoutTimeCounter(): BABYLON.PerfCounter;
  80162. /**
  80163. * Enable or disable the render time capture
  80164. */
  80165. get captureRenderTime(): boolean;
  80166. set captureRenderTime(value: boolean);
  80167. /**
  80168. * Enable or disable the layout time capture
  80169. */
  80170. get captureLayoutTime(): boolean;
  80171. set captureLayoutTime(value: boolean);
  80172. /**
  80173. * Instantiates a new advanced dynamic texture instrumentation.
  80174. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80175. * @param texture Defines the AdvancedDynamicTexture to instrument
  80176. */
  80177. constructor(
  80178. /**
  80179. * Define the instrumented AdvancedDynamicTexture.
  80180. */
  80181. texture: AdvancedDynamicTexture);
  80182. /**
  80183. * Dispose and release associated resources.
  80184. */
  80185. dispose(): void;
  80186. }
  80187. }
  80188. declare module BABYLON.GUI {
  80189. /**
  80190. * Class used to load GUI via XML.
  80191. */
  80192. export class XmlLoader {
  80193. private _nodes;
  80194. private _nodeTypes;
  80195. private _isLoaded;
  80196. private _objectAttributes;
  80197. private _parentClass;
  80198. /**
  80199. * Create a new xml loader
  80200. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80201. */
  80202. constructor(parentClass?: null);
  80203. private _getChainElement;
  80204. private _getClassAttribute;
  80205. private _createGuiElement;
  80206. private _parseGrid;
  80207. private _parseElement;
  80208. private _prepareSourceElement;
  80209. private _parseElementsFromSource;
  80210. private _parseXml;
  80211. /**
  80212. * Gets if the loading has finished.
  80213. * @returns whether the loading has finished or not
  80214. */
  80215. isLoaded(): boolean;
  80216. /**
  80217. * Gets a loaded node / control by id.
  80218. * @param id the Controls id set in the xml
  80219. * @returns element of type Control
  80220. */
  80221. getNodeById(id: string): any;
  80222. /**
  80223. * Gets all loaded nodes / controls
  80224. * @returns Array of controls
  80225. */
  80226. getNodes(): any;
  80227. /**
  80228. * Initiates the xml layout loading
  80229. * @param xmlFile defines the xml layout to load
  80230. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80231. * @param callback defines the callback called on layout load.
  80232. */
  80233. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80234. }
  80235. }
  80236. declare module BABYLON.GUI {
  80237. /**
  80238. * Class used to create containers for controls
  80239. */
  80240. export class Container3D extends Control3D {
  80241. private _blockLayout;
  80242. /**
  80243. * Gets the list of child controls
  80244. */
  80245. protected _children: Control3D[];
  80246. /**
  80247. * Gets the list of child controls
  80248. */
  80249. get children(): Array<Control3D>;
  80250. /**
  80251. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80252. * This is helpful to optimize layout operation when adding multiple children in a row
  80253. */
  80254. get blockLayout(): boolean;
  80255. set blockLayout(value: boolean);
  80256. /**
  80257. * Creates a new container
  80258. * @param name defines the container name
  80259. */
  80260. constructor(name?: string);
  80261. /**
  80262. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80263. * @returns the current container
  80264. */
  80265. updateLayout(): Container3D;
  80266. /**
  80267. * Gets a boolean indicating if the given control is in the children of this control
  80268. * @param control defines the control to check
  80269. * @returns true if the control is in the child list
  80270. */
  80271. containsControl(control: Control3D): boolean;
  80272. /**
  80273. * Adds a control to the children of this control
  80274. * @param control defines the control to add
  80275. * @returns the current container
  80276. */
  80277. addControl(control: Control3D): Container3D;
  80278. /**
  80279. * This function will be called everytime a new control is added
  80280. */
  80281. protected _arrangeChildren(): void;
  80282. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80283. /**
  80284. * Removes a control from the children of this control
  80285. * @param control defines the control to remove
  80286. * @returns the current container
  80287. */
  80288. removeControl(control: Control3D): Container3D;
  80289. protected _getTypeName(): string;
  80290. /**
  80291. * Releases all associated resources
  80292. */
  80293. dispose(): void;
  80294. /** Control rotation will remain unchanged */
  80295. static readonly UNSET_ORIENTATION: number;
  80296. /** Control will rotate to make it look at sphere central axis */
  80297. static readonly FACEORIGIN_ORIENTATION: number;
  80298. /** Control will rotate to make it look back at sphere central axis */
  80299. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80300. /** Control will rotate to look at z axis (0, 0, 1) */
  80301. static readonly FACEFORWARD_ORIENTATION: number;
  80302. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80303. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80304. }
  80305. }
  80306. declare module BABYLON.GUI {
  80307. /**
  80308. * Class used to manage 3D user interface
  80309. * @see https://doc.babylonjs.com/how_to/gui3d
  80310. */
  80311. export class GUI3DManager implements BABYLON.IDisposable {
  80312. private _scene;
  80313. private _sceneDisposeObserver;
  80314. private _utilityLayer;
  80315. private _rootContainer;
  80316. private _pointerObserver;
  80317. private _pointerOutObserver;
  80318. /** @hidden */
  80319. _lastPickedControl: Control3D;
  80320. /** @hidden */
  80321. _lastControlOver: {
  80322. [pointerId: number]: Control3D;
  80323. };
  80324. /** @hidden */
  80325. _lastControlDown: {
  80326. [pointerId: number]: Control3D;
  80327. };
  80328. /**
  80329. * BABYLON.Observable raised when the point picked by the pointer events changed
  80330. */
  80331. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80332. /** @hidden */
  80333. _sharedMaterials: {
  80334. [key: string]: BABYLON.Material;
  80335. };
  80336. /** Gets the hosting scene */
  80337. get scene(): BABYLON.Scene;
  80338. /** Gets associated utility layer */
  80339. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80340. /**
  80341. * Creates a new GUI3DManager
  80342. * @param scene
  80343. */
  80344. constructor(scene?: BABYLON.Scene);
  80345. private _handlePointerOut;
  80346. private _doPicking;
  80347. /**
  80348. * Gets the root container
  80349. */
  80350. get rootContainer(): Container3D;
  80351. /**
  80352. * Gets a boolean indicating if the given control is in the root child list
  80353. * @param control defines the control to check
  80354. * @returns true if the control is in the root child list
  80355. */
  80356. containsControl(control: Control3D): boolean;
  80357. /**
  80358. * Adds a control to the root child list
  80359. * @param control defines the control to add
  80360. * @returns the current manager
  80361. */
  80362. addControl(control: Control3D): GUI3DManager;
  80363. /**
  80364. * Removes a control from the root child list
  80365. * @param control defines the control to remove
  80366. * @returns the current container
  80367. */
  80368. removeControl(control: Control3D): GUI3DManager;
  80369. /**
  80370. * Releases all associated resources
  80371. */
  80372. dispose(): void;
  80373. }
  80374. }
  80375. declare module BABYLON.GUI {
  80376. /**
  80377. * Class used to transport BABYLON.Vector3 information for pointer events
  80378. */
  80379. export class Vector3WithInfo extends BABYLON.Vector3 {
  80380. /** defines the current mouse button index */
  80381. buttonIndex: number;
  80382. /**
  80383. * Creates a new Vector3WithInfo
  80384. * @param source defines the vector3 data to transport
  80385. * @param buttonIndex defines the current mouse button index
  80386. */
  80387. constructor(source: BABYLON.Vector3,
  80388. /** defines the current mouse button index */
  80389. buttonIndex?: number);
  80390. }
  80391. }
  80392. declare module BABYLON.GUI {
  80393. /**
  80394. * Class used as base class for controls
  80395. */
  80396. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80397. /** Defines the control name */
  80398. name?: string | undefined;
  80399. /** @hidden */
  80400. _host: GUI3DManager;
  80401. private _node;
  80402. private _downCount;
  80403. private _enterCount;
  80404. private _downPointerIds;
  80405. private _isVisible;
  80406. /** Gets or sets the control position in world space */
  80407. get position(): BABYLON.Vector3;
  80408. set position(value: BABYLON.Vector3);
  80409. /** Gets or sets the control scaling in world space */
  80410. get scaling(): BABYLON.Vector3;
  80411. set scaling(value: BABYLON.Vector3);
  80412. /** Callback used to start pointer enter animation */
  80413. pointerEnterAnimation: () => void;
  80414. /** Callback used to start pointer out animation */
  80415. pointerOutAnimation: () => void;
  80416. /** Callback used to start pointer down animation */
  80417. pointerDownAnimation: () => void;
  80418. /** Callback used to start pointer up animation */
  80419. pointerUpAnimation: () => void;
  80420. /**
  80421. * An event triggered when the pointer move over the control
  80422. */
  80423. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80424. /**
  80425. * An event triggered when the pointer move out of the control
  80426. */
  80427. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80428. /**
  80429. * An event triggered when the pointer taps the control
  80430. */
  80431. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80432. /**
  80433. * An event triggered when pointer is up
  80434. */
  80435. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80436. /**
  80437. * An event triggered when a control is clicked on (with a mouse)
  80438. */
  80439. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80440. /**
  80441. * An event triggered when pointer enters the control
  80442. */
  80443. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80444. /**
  80445. * Gets or sets the parent container
  80446. */
  80447. parent: BABYLON.Nullable<Container3D>;
  80448. private _behaviors;
  80449. /**
  80450. * Gets the list of attached behaviors
  80451. * @see https://doc.babylonjs.com/features/behaviour
  80452. */
  80453. get behaviors(): BABYLON.Behavior<Control3D>[];
  80454. /**
  80455. * Attach a behavior to the control
  80456. * @see https://doc.babylonjs.com/features/behaviour
  80457. * @param behavior defines the behavior to attach
  80458. * @returns the current control
  80459. */
  80460. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80461. /**
  80462. * Remove an attached behavior
  80463. * @see https://doc.babylonjs.com/features/behaviour
  80464. * @param behavior defines the behavior to attach
  80465. * @returns the current control
  80466. */
  80467. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80468. /**
  80469. * Gets an attached behavior by name
  80470. * @param name defines the name of the behavior to look for
  80471. * @see https://doc.babylonjs.com/features/behaviour
  80472. * @returns null if behavior was not found else the requested behavior
  80473. */
  80474. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80475. /** Gets or sets a boolean indicating if the control is visible */
  80476. get isVisible(): boolean;
  80477. set isVisible(value: boolean);
  80478. /**
  80479. * Creates a new control
  80480. * @param name defines the control name
  80481. */
  80482. constructor(
  80483. /** Defines the control name */
  80484. name?: string | undefined);
  80485. /**
  80486. * Gets a string representing the class name
  80487. */
  80488. get typeName(): string;
  80489. /**
  80490. * Get the current class name of the control.
  80491. * @returns current class name
  80492. */
  80493. getClassName(): string;
  80494. protected _getTypeName(): string;
  80495. /**
  80496. * Gets the transform node used by this control
  80497. */
  80498. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80499. /**
  80500. * Gets the mesh used to render this control
  80501. */
  80502. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80503. /**
  80504. * Link the control as child of the given node
  80505. * @param node defines the node to link to. Use null to unlink the control
  80506. * @returns the current control
  80507. */
  80508. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80509. /** @hidden **/
  80510. _prepareNode(scene: BABYLON.Scene): void;
  80511. /**
  80512. * Node creation.
  80513. * Can be overriden by children
  80514. * @param scene defines the scene where the node must be attached
  80515. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80516. */
  80517. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80518. /**
  80519. * Affect a material to the given mesh
  80520. * @param mesh defines the mesh which will represent the control
  80521. */
  80522. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80523. /** @hidden */
  80524. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80525. /** @hidden */
  80526. _onPointerEnter(target: Control3D): boolean;
  80527. /** @hidden */
  80528. _onPointerOut(target: Control3D): void;
  80529. /** @hidden */
  80530. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80531. /** @hidden */
  80532. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80533. /** @hidden */
  80534. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80535. /** @hidden */
  80536. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80537. /** @hidden */
  80538. _disposeNode(): void;
  80539. /**
  80540. * Releases all associated resources
  80541. */
  80542. dispose(): void;
  80543. }
  80544. }
  80545. declare module BABYLON.GUI {
  80546. /**
  80547. * Class used as a root to all buttons
  80548. */
  80549. export class AbstractButton3D extends Control3D {
  80550. /**
  80551. * Creates a new button
  80552. * @param name defines the control name
  80553. */
  80554. constructor(name?: string);
  80555. protected _getTypeName(): string;
  80556. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80557. }
  80558. }
  80559. declare module BABYLON.GUI {
  80560. /**
  80561. * Class used to create a button in 3D
  80562. */
  80563. export class Button3D extends AbstractButton3D {
  80564. /** @hidden */
  80565. protected _currentMaterial: BABYLON.Material;
  80566. private _facadeTexture;
  80567. private _content;
  80568. private _contentResolution;
  80569. private _contentScaleRatio;
  80570. /**
  80571. * Gets or sets the texture resolution used to render content (512 by default)
  80572. */
  80573. get contentResolution(): BABYLON.int;
  80574. set contentResolution(value: BABYLON.int);
  80575. /**
  80576. * Gets or sets the texture scale ratio used to render content (2 by default)
  80577. */
  80578. get contentScaleRatio(): number;
  80579. set contentScaleRatio(value: number);
  80580. protected _disposeFacadeTexture(): void;
  80581. protected _resetContent(): void;
  80582. /**
  80583. * Creates a new button
  80584. * @param name defines the control name
  80585. */
  80586. constructor(name?: string);
  80587. /**
  80588. * Gets or sets the GUI 2D content used to display the button's facade
  80589. */
  80590. get content(): Control;
  80591. set content(value: Control);
  80592. /**
  80593. * Apply the facade texture (created from the content property).
  80594. * This function can be overloaded by child classes
  80595. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80596. */
  80597. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80598. protected _getTypeName(): string;
  80599. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80600. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80601. /**
  80602. * Releases all associated resources
  80603. */
  80604. dispose(): void;
  80605. }
  80606. }
  80607. declare module BABYLON.GUI {
  80608. /**
  80609. * Abstract class used to create a container panel deployed on the surface of a volume
  80610. */
  80611. export abstract class VolumeBasedPanel extends Container3D {
  80612. private _columns;
  80613. private _rows;
  80614. private _rowThenColum;
  80615. private _orientation;
  80616. protected _cellWidth: number;
  80617. protected _cellHeight: number;
  80618. /**
  80619. * Gets or sets the distance between elements
  80620. */
  80621. margin: number;
  80622. /**
  80623. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80624. * | Value | Type | Description |
  80625. * | ----- | ----------------------------------- | ----------- |
  80626. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80627. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80628. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80629. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80630. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80631. */
  80632. get orientation(): number;
  80633. set orientation(value: number);
  80634. /**
  80635. * Gets or sets the number of columns requested (10 by default).
  80636. * The panel will automatically compute the number of rows based on number of child controls.
  80637. */
  80638. get columns(): BABYLON.int;
  80639. set columns(value: BABYLON.int);
  80640. /**
  80641. * Gets or sets a the number of rows requested.
  80642. * The panel will automatically compute the number of columns based on number of child controls.
  80643. */
  80644. get rows(): BABYLON.int;
  80645. set rows(value: BABYLON.int);
  80646. /**
  80647. * Creates new VolumeBasedPanel
  80648. */
  80649. constructor();
  80650. protected _arrangeChildren(): void;
  80651. /** Child classes must implement this function to provide correct control positioning */
  80652. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80653. /** Child classes can implement this function to provide additional processing */
  80654. protected _finalProcessing(): void;
  80655. }
  80656. }
  80657. declare module BABYLON.GUI {
  80658. /**
  80659. * Class used to create a container panel deployed on the surface of a cylinder
  80660. */
  80661. export class CylinderPanel extends VolumeBasedPanel {
  80662. private _radius;
  80663. /**
  80664. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80665. */
  80666. get radius(): BABYLON.float;
  80667. set radius(value: BABYLON.float);
  80668. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80669. private _cylindricalMapping;
  80670. }
  80671. }
  80672. declare module BABYLON.GUI {
  80673. /** @hidden */
  80674. export var fluentVertexShader: {
  80675. name: string;
  80676. shader: string;
  80677. };
  80678. }
  80679. declare module BABYLON.GUI {
  80680. /** @hidden */
  80681. export var fluentPixelShader: {
  80682. name: string;
  80683. shader: string;
  80684. };
  80685. }
  80686. declare module BABYLON.GUI {
  80687. /** @hidden */
  80688. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80689. INNERGLOW: boolean;
  80690. BORDER: boolean;
  80691. HOVERLIGHT: boolean;
  80692. TEXTURE: boolean;
  80693. constructor();
  80694. }
  80695. /**
  80696. * Class used to render controls with fluent desgin
  80697. */
  80698. export class FluentMaterial extends BABYLON.PushMaterial {
  80699. /**
  80700. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80701. */
  80702. innerGlowColorIntensity: number;
  80703. /**
  80704. * Gets or sets the inner glow color (white by default)
  80705. */
  80706. innerGlowColor: BABYLON.Color3;
  80707. /**
  80708. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80709. */
  80710. albedoColor: BABYLON.Color3;
  80711. /**
  80712. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80713. */
  80714. renderBorders: boolean;
  80715. /**
  80716. * Gets or sets border width (default is 0.5)
  80717. */
  80718. borderWidth: number;
  80719. /**
  80720. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80721. */
  80722. edgeSmoothingValue: number;
  80723. /**
  80724. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80725. */
  80726. borderMinValue: number;
  80727. /**
  80728. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80729. */
  80730. renderHoverLight: boolean;
  80731. /**
  80732. * Gets or sets the radius used to render the hover light (default is 1.0)
  80733. */
  80734. hoverRadius: number;
  80735. /**
  80736. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80737. */
  80738. hoverColor: BABYLON.Color4;
  80739. /**
  80740. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80741. */
  80742. hoverPosition: BABYLON.Vector3;
  80743. private _albedoTexture;
  80744. /** Gets or sets the texture to use for albedo color */
  80745. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80746. /**
  80747. * Creates a new Fluent material
  80748. * @param name defines the name of the material
  80749. * @param scene defines the hosting scene
  80750. */
  80751. constructor(name: string, scene: BABYLON.Scene);
  80752. needAlphaBlending(): boolean;
  80753. needAlphaTesting(): boolean;
  80754. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80755. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80756. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80757. getActiveTextures(): BABYLON.BaseTexture[];
  80758. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80759. dispose(forceDisposeEffect?: boolean): void;
  80760. clone(name: string): FluentMaterial;
  80761. serialize(): any;
  80762. getClassName(): string;
  80763. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80764. }
  80765. }
  80766. declare module BABYLON.GUI {
  80767. /**
  80768. * Class used to create a holographic button in 3D
  80769. */
  80770. export class HolographicButton extends Button3D {
  80771. private _backPlate;
  80772. private _textPlate;
  80773. private _frontPlate;
  80774. private _text;
  80775. private _imageUrl;
  80776. private _shareMaterials;
  80777. private _frontMaterial;
  80778. private _backMaterial;
  80779. private _plateMaterial;
  80780. private _pickedPointObserver;
  80781. private _tooltipFade;
  80782. private _tooltipTextBlock;
  80783. private _tooltipTexture;
  80784. private _tooltipMesh;
  80785. private _tooltipHoverObserver;
  80786. private _tooltipOutObserver;
  80787. private _disposeTooltip;
  80788. /**
  80789. * Rendering ground id of all the mesh in the button
  80790. */
  80791. set renderingGroupId(id: number);
  80792. get renderingGroupId(): number;
  80793. /**
  80794. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80795. */
  80796. set tooltipText(text: BABYLON.Nullable<string>);
  80797. get tooltipText(): BABYLON.Nullable<string>;
  80798. /**
  80799. * Gets or sets text for the button
  80800. */
  80801. get text(): string;
  80802. set text(value: string);
  80803. /**
  80804. * Gets or sets the image url for the button
  80805. */
  80806. get imageUrl(): string;
  80807. set imageUrl(value: string);
  80808. /**
  80809. * Gets the back material used by this button
  80810. */
  80811. get backMaterial(): FluentMaterial;
  80812. /**
  80813. * Gets the front material used by this button
  80814. */
  80815. get frontMaterial(): FluentMaterial;
  80816. /**
  80817. * Gets the plate material used by this button
  80818. */
  80819. get plateMaterial(): BABYLON.StandardMaterial;
  80820. /**
  80821. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80822. */
  80823. get shareMaterials(): boolean;
  80824. /**
  80825. * Creates a new button
  80826. * @param name defines the control name
  80827. */
  80828. constructor(name?: string, shareMaterials?: boolean);
  80829. protected _getTypeName(): string;
  80830. private _rebuildContent;
  80831. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80832. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80833. private _createBackMaterial;
  80834. private _createFrontMaterial;
  80835. private _createPlateMaterial;
  80836. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80837. /**
  80838. * Releases all associated resources
  80839. */
  80840. dispose(): void;
  80841. }
  80842. }
  80843. declare module BABYLON.GUI {
  80844. /**
  80845. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80846. */
  80847. export class MeshButton3D extends Button3D {
  80848. /** @hidden */
  80849. protected _currentMesh: BABYLON.Mesh;
  80850. /**
  80851. * Creates a new 3D button based on a mesh
  80852. * @param mesh mesh to become a 3D button
  80853. * @param name defines the control name
  80854. */
  80855. constructor(mesh: BABYLON.Mesh, name?: string);
  80856. protected _getTypeName(): string;
  80857. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80858. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80859. }
  80860. }
  80861. declare module BABYLON.GUI {
  80862. /**
  80863. * Class used to create a container panel deployed on the surface of a plane
  80864. */
  80865. export class PlanePanel extends VolumeBasedPanel {
  80866. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80867. }
  80868. }
  80869. declare module BABYLON.GUI {
  80870. /**
  80871. * Class used to create a container panel where items get randomized planar mapping
  80872. */
  80873. export class ScatterPanel extends VolumeBasedPanel {
  80874. private _iteration;
  80875. /**
  80876. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  80877. */
  80878. get iteration(): BABYLON.float;
  80879. set iteration(value: BABYLON.float);
  80880. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80881. private _scatterMapping;
  80882. protected _finalProcessing(): void;
  80883. }
  80884. }
  80885. declare module BABYLON.GUI {
  80886. /**
  80887. * Class used to create a container panel deployed on the surface of a sphere
  80888. */
  80889. export class SpherePanel extends VolumeBasedPanel {
  80890. private _radius;
  80891. /**
  80892. * Gets or sets the radius of the sphere where to project controls (5 by default)
  80893. */
  80894. get radius(): BABYLON.float;
  80895. set radius(value: BABYLON.float);
  80896. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80897. private _sphericalMapping;
  80898. }
  80899. }
  80900. declare module BABYLON.GUI {
  80901. /**
  80902. * Class used to create a stack panel in 3D on XY plane
  80903. */
  80904. export class StackPanel3D extends Container3D {
  80905. private _isVertical;
  80906. /**
  80907. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  80908. */
  80909. get isVertical(): boolean;
  80910. set isVertical(value: boolean);
  80911. /**
  80912. * Gets or sets the distance between elements
  80913. */
  80914. margin: number;
  80915. /**
  80916. * Creates new StackPanel
  80917. * @param isVertical
  80918. */
  80919. constructor(isVertical?: boolean);
  80920. protected _arrangeChildren(): void;
  80921. }
  80922. }
  80923. declare module BABYLON {
  80924. /**
  80925. * Configuration for glTF validation
  80926. */
  80927. export interface IGLTFValidationConfiguration {
  80928. /**
  80929. * The url of the glTF validator.
  80930. */
  80931. url: string;
  80932. }
  80933. /**
  80934. * glTF validation
  80935. */
  80936. export class GLTFValidation {
  80937. /**
  80938. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  80939. */
  80940. static Configuration: IGLTFValidationConfiguration;
  80941. private static _LoadScriptPromise;
  80942. /**
  80943. * Validate a glTF asset using the glTF-Validator.
  80944. * @param data The JSON of a glTF or the array buffer of a binary glTF
  80945. * @param rootUrl The root url for the glTF
  80946. * @param fileName The file name for the glTF
  80947. * @param getExternalResource The callback to get external resources for the glTF validator
  80948. * @returns A promise that resolves with the glTF validation results once complete
  80949. */
  80950. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  80951. }
  80952. }
  80953. declare module BABYLON {
  80954. /**
  80955. * Mode that determines the coordinate system to use.
  80956. */
  80957. export enum GLTFLoaderCoordinateSystemMode {
  80958. /**
  80959. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  80960. */
  80961. AUTO = 0,
  80962. /**
  80963. * Sets the useRightHandedSystem flag on the scene.
  80964. */
  80965. FORCE_RIGHT_HANDED = 1
  80966. }
  80967. /**
  80968. * Mode that determines what animations will start.
  80969. */
  80970. export enum GLTFLoaderAnimationStartMode {
  80971. /**
  80972. * No animation will start.
  80973. */
  80974. NONE = 0,
  80975. /**
  80976. * The first animation will start.
  80977. */
  80978. FIRST = 1,
  80979. /**
  80980. * All animations will start.
  80981. */
  80982. ALL = 2
  80983. }
  80984. /**
  80985. * Interface that contains the data for the glTF asset.
  80986. */
  80987. export interface IGLTFLoaderData {
  80988. /**
  80989. * The object that represents the glTF JSON.
  80990. */
  80991. json: Object;
  80992. /**
  80993. * The BIN chunk of a binary glTF.
  80994. */
  80995. bin: Nullable<IDataBuffer>;
  80996. }
  80997. /**
  80998. * Interface for extending the loader.
  80999. */
  81000. export interface IGLTFLoaderExtension {
  81001. /**
  81002. * The name of this extension.
  81003. */
  81004. readonly name: string;
  81005. /**
  81006. * Defines whether this extension is enabled.
  81007. */
  81008. enabled: boolean;
  81009. /**
  81010. * Defines the order of this extension.
  81011. * The loader sorts the extensions using these values when loading.
  81012. */
  81013. order?: number;
  81014. }
  81015. /**
  81016. * Loader state.
  81017. */
  81018. export enum GLTFLoaderState {
  81019. /**
  81020. * The asset is loading.
  81021. */
  81022. LOADING = 0,
  81023. /**
  81024. * The asset is ready for rendering.
  81025. */
  81026. READY = 1,
  81027. /**
  81028. * The asset is completely loaded.
  81029. */
  81030. COMPLETE = 2
  81031. }
  81032. /** @hidden */
  81033. export interface IImportMeshAsyncOutput {
  81034. meshes: AbstractMesh[];
  81035. particleSystems: IParticleSystem[];
  81036. skeletons: Skeleton[];
  81037. animationGroups: AnimationGroup[];
  81038. lights: Light[];
  81039. transformNodes: TransformNode[];
  81040. }
  81041. /** @hidden */
  81042. export interface IGLTFLoader extends IDisposable {
  81043. readonly state: Nullable<GLTFLoaderState>;
  81044. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81045. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81046. }
  81047. /**
  81048. * File loader for loading glTF files into a scene.
  81049. */
  81050. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81051. /** @hidden */
  81052. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81053. /** @hidden */
  81054. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81055. /**
  81056. * Raised when the asset has been parsed
  81057. */
  81058. onParsedObservable: Observable<IGLTFLoaderData>;
  81059. private _onParsedObserver;
  81060. /**
  81061. * Raised when the asset has been parsed
  81062. */
  81063. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81064. /**
  81065. * 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.
  81066. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81067. * Defaults to true.
  81068. * @hidden
  81069. */
  81070. static IncrementalLoading: boolean;
  81071. /**
  81072. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81073. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81074. * @hidden
  81075. */
  81076. static HomogeneousCoordinates: boolean;
  81077. /**
  81078. * The coordinate system mode. Defaults to AUTO.
  81079. */
  81080. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81081. /**
  81082. * The animation start mode. Defaults to FIRST.
  81083. */
  81084. animationStartMode: GLTFLoaderAnimationStartMode;
  81085. /**
  81086. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81087. */
  81088. compileMaterials: boolean;
  81089. /**
  81090. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81091. */
  81092. useClipPlane: boolean;
  81093. /**
  81094. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81095. */
  81096. compileShadowGenerators: boolean;
  81097. /**
  81098. * Defines if the Alpha blended materials are only applied as coverage.
  81099. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81100. * If true, no extra effects are applied to transparent pixels.
  81101. */
  81102. transparencyAsCoverage: boolean;
  81103. /**
  81104. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81105. * Enabling will disable offline support and glTF validator.
  81106. * Defaults to false.
  81107. */
  81108. useRangeRequests: boolean;
  81109. /**
  81110. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81111. */
  81112. createInstances: boolean;
  81113. /**
  81114. * 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.
  81115. */
  81116. alwaysComputeBoundingBox: boolean;
  81117. /**
  81118. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81119. */
  81120. loadAllMaterials: boolean;
  81121. /**
  81122. * Function called before loading a url referenced by the asset.
  81123. */
  81124. preprocessUrlAsync: (url: string) => Promise<string>;
  81125. /**
  81126. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81127. * Note that the observable is raised as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  81128. */
  81129. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81130. private _onMeshLoadedObserver;
  81131. /**
  81132. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81133. * Note that the callback is called as soon as the mesh object is created, meaning some data may not have been setup yet for this mesh (vertex data, morph targets, material, ...)
  81134. */
  81135. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81136. /**
  81137. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81138. */
  81139. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81140. private _onTextureLoadedObserver;
  81141. /**
  81142. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81143. */
  81144. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81145. /**
  81146. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81147. */
  81148. readonly onMaterialLoadedObservable: Observable<Material>;
  81149. private _onMaterialLoadedObserver;
  81150. /**
  81151. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81152. */
  81153. set onMaterialLoaded(callback: (material: Material) => void);
  81154. /**
  81155. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81156. */
  81157. readonly onCameraLoadedObservable: Observable<Camera>;
  81158. private _onCameraLoadedObserver;
  81159. /**
  81160. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81161. */
  81162. set onCameraLoaded(callback: (camera: Camera) => void);
  81163. /**
  81164. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81165. * For assets with LODs, raised when all of the LODs are complete.
  81166. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81167. */
  81168. readonly onCompleteObservable: Observable<void>;
  81169. private _onCompleteObserver;
  81170. /**
  81171. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81172. * For assets with LODs, raised when all of the LODs are complete.
  81173. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81174. */
  81175. set onComplete(callback: () => void);
  81176. /**
  81177. * Observable raised when an error occurs.
  81178. */
  81179. readonly onErrorObservable: Observable<any>;
  81180. private _onErrorObserver;
  81181. /**
  81182. * Callback raised when an error occurs.
  81183. */
  81184. set onError(callback: (reason: any) => void);
  81185. /**
  81186. * Observable raised after the loader is disposed.
  81187. */
  81188. readonly onDisposeObservable: Observable<void>;
  81189. private _onDisposeObserver;
  81190. /**
  81191. * Callback raised after the loader is disposed.
  81192. */
  81193. set onDispose(callback: () => void);
  81194. /**
  81195. * Observable raised after a loader extension is created.
  81196. * Set additional options for a loader extension in this event.
  81197. */
  81198. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81199. private _onExtensionLoadedObserver;
  81200. /**
  81201. * Callback raised after a loader extension is created.
  81202. */
  81203. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81204. /**
  81205. * Defines if the loader logging is enabled.
  81206. */
  81207. get loggingEnabled(): boolean;
  81208. set loggingEnabled(value: boolean);
  81209. /**
  81210. * Defines if the loader should capture performance counters.
  81211. */
  81212. get capturePerformanceCounters(): boolean;
  81213. set capturePerformanceCounters(value: boolean);
  81214. /**
  81215. * Defines if the loader should validate the asset.
  81216. */
  81217. validate: boolean;
  81218. /**
  81219. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81220. */
  81221. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81222. private _onValidatedObserver;
  81223. /**
  81224. * Callback raised after a loader extension is created.
  81225. */
  81226. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81227. private _loader;
  81228. private _progressCallback?;
  81229. private _requests;
  81230. private static magicBase64Encoded;
  81231. /**
  81232. * Name of the loader ("gltf")
  81233. */
  81234. name: string;
  81235. /** @hidden */
  81236. extensions: ISceneLoaderPluginExtensions;
  81237. /**
  81238. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81239. */
  81240. dispose(): void;
  81241. /** @hidden */
  81242. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81243. /** @hidden */
  81244. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81245. /** @hidden */
  81246. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81247. meshes: AbstractMesh[];
  81248. particleSystems: IParticleSystem[];
  81249. skeletons: Skeleton[];
  81250. animationGroups: AnimationGroup[];
  81251. }>;
  81252. /** @hidden */
  81253. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81254. /** @hidden */
  81255. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81256. /** @hidden */
  81257. canDirectLoad(data: string): boolean;
  81258. /** @hidden */
  81259. directLoad(scene: Scene, data: string): Promise<any>;
  81260. /**
  81261. * The callback that allows custom handling of the root url based on the response url.
  81262. * @param rootUrl the original root url
  81263. * @param responseURL the response url if available
  81264. * @returns the new root url
  81265. */
  81266. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81267. /** @hidden */
  81268. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81269. /**
  81270. * The loader state or null if the loader is not active.
  81271. */
  81272. get loaderState(): Nullable<GLTFLoaderState>;
  81273. /**
  81274. * Returns a promise that resolves when the asset is completely loaded.
  81275. * @returns a promise that resolves when the asset is completely loaded.
  81276. */
  81277. whenCompleteAsync(): Promise<void>;
  81278. /** @hidden */
  81279. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81280. /** @hidden */
  81281. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81282. private _onProgress;
  81283. private _validate;
  81284. private _getLoader;
  81285. private _parseJson;
  81286. private _unpackBinaryAsync;
  81287. private _unpackBinaryV1Async;
  81288. private _unpackBinaryV2Async;
  81289. private static _parseVersion;
  81290. private static _compareVersion;
  81291. private static readonly _logSpaces;
  81292. private _logIndentLevel;
  81293. private _loggingEnabled;
  81294. /** @hidden */
  81295. _log: (message: string) => void;
  81296. /** @hidden */
  81297. _logOpen(message: string): void;
  81298. /** @hidden */
  81299. _logClose(): void;
  81300. private _logEnabled;
  81301. private _logDisabled;
  81302. private _capturePerformanceCounters;
  81303. /** @hidden */
  81304. _startPerformanceCounter: (counterName: string) => void;
  81305. /** @hidden */
  81306. _endPerformanceCounter: (counterName: string) => void;
  81307. private _startPerformanceCounterEnabled;
  81308. private _startPerformanceCounterDisabled;
  81309. private _endPerformanceCounterEnabled;
  81310. private _endPerformanceCounterDisabled;
  81311. }
  81312. }
  81313. declare module BABYLON.GLTF1 {
  81314. /**
  81315. * Enums
  81316. * @hidden
  81317. */
  81318. export enum EComponentType {
  81319. BYTE = 5120,
  81320. UNSIGNED_BYTE = 5121,
  81321. SHORT = 5122,
  81322. UNSIGNED_SHORT = 5123,
  81323. FLOAT = 5126
  81324. }
  81325. /** @hidden */
  81326. export enum EShaderType {
  81327. FRAGMENT = 35632,
  81328. VERTEX = 35633
  81329. }
  81330. /** @hidden */
  81331. export enum EParameterType {
  81332. BYTE = 5120,
  81333. UNSIGNED_BYTE = 5121,
  81334. SHORT = 5122,
  81335. UNSIGNED_SHORT = 5123,
  81336. INT = 5124,
  81337. UNSIGNED_INT = 5125,
  81338. FLOAT = 5126,
  81339. FLOAT_VEC2 = 35664,
  81340. FLOAT_VEC3 = 35665,
  81341. FLOAT_VEC4 = 35666,
  81342. INT_VEC2 = 35667,
  81343. INT_VEC3 = 35668,
  81344. INT_VEC4 = 35669,
  81345. BOOL = 35670,
  81346. BOOL_VEC2 = 35671,
  81347. BOOL_VEC3 = 35672,
  81348. BOOL_VEC4 = 35673,
  81349. FLOAT_MAT2 = 35674,
  81350. FLOAT_MAT3 = 35675,
  81351. FLOAT_MAT4 = 35676,
  81352. SAMPLER_2D = 35678
  81353. }
  81354. /** @hidden */
  81355. export enum ETextureWrapMode {
  81356. CLAMP_TO_EDGE = 33071,
  81357. MIRRORED_REPEAT = 33648,
  81358. REPEAT = 10497
  81359. }
  81360. /** @hidden */
  81361. export enum ETextureFilterType {
  81362. NEAREST = 9728,
  81363. LINEAR = 9728,
  81364. NEAREST_MIPMAP_NEAREST = 9984,
  81365. LINEAR_MIPMAP_NEAREST = 9985,
  81366. NEAREST_MIPMAP_LINEAR = 9986,
  81367. LINEAR_MIPMAP_LINEAR = 9987
  81368. }
  81369. /** @hidden */
  81370. export enum ETextureFormat {
  81371. ALPHA = 6406,
  81372. RGB = 6407,
  81373. RGBA = 6408,
  81374. LUMINANCE = 6409,
  81375. LUMINANCE_ALPHA = 6410
  81376. }
  81377. /** @hidden */
  81378. export enum ECullingType {
  81379. FRONT = 1028,
  81380. BACK = 1029,
  81381. FRONT_AND_BACK = 1032
  81382. }
  81383. /** @hidden */
  81384. export enum EBlendingFunction {
  81385. ZERO = 0,
  81386. ONE = 1,
  81387. SRC_COLOR = 768,
  81388. ONE_MINUS_SRC_COLOR = 769,
  81389. DST_COLOR = 774,
  81390. ONE_MINUS_DST_COLOR = 775,
  81391. SRC_ALPHA = 770,
  81392. ONE_MINUS_SRC_ALPHA = 771,
  81393. DST_ALPHA = 772,
  81394. ONE_MINUS_DST_ALPHA = 773,
  81395. CONSTANT_COLOR = 32769,
  81396. ONE_MINUS_CONSTANT_COLOR = 32770,
  81397. CONSTANT_ALPHA = 32771,
  81398. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81399. SRC_ALPHA_SATURATE = 776
  81400. }
  81401. /** @hidden */
  81402. export interface IGLTFProperty {
  81403. extensions?: {
  81404. [key: string]: any;
  81405. };
  81406. extras?: Object;
  81407. }
  81408. /** @hidden */
  81409. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81410. name?: string;
  81411. }
  81412. /** @hidden */
  81413. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81414. bufferView: string;
  81415. byteOffset: number;
  81416. byteStride: number;
  81417. count: number;
  81418. type: string;
  81419. componentType: EComponentType;
  81420. max?: number[];
  81421. min?: number[];
  81422. name?: string;
  81423. }
  81424. /** @hidden */
  81425. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81426. buffer: string;
  81427. byteOffset: number;
  81428. byteLength: number;
  81429. byteStride: number;
  81430. target?: number;
  81431. }
  81432. /** @hidden */
  81433. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81434. uri: string;
  81435. byteLength?: number;
  81436. type?: string;
  81437. }
  81438. /** @hidden */
  81439. export interface IGLTFShader extends IGLTFChildRootProperty {
  81440. uri: string;
  81441. type: EShaderType;
  81442. }
  81443. /** @hidden */
  81444. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81445. attributes: string[];
  81446. fragmentShader: string;
  81447. vertexShader: string;
  81448. }
  81449. /** @hidden */
  81450. export interface IGLTFTechniqueParameter {
  81451. type: number;
  81452. count?: number;
  81453. semantic?: string;
  81454. node?: string;
  81455. value?: number | boolean | string | Array<any>;
  81456. source?: string;
  81457. babylonValue?: any;
  81458. }
  81459. /** @hidden */
  81460. export interface IGLTFTechniqueCommonProfile {
  81461. lightingModel: string;
  81462. texcoordBindings: Object;
  81463. parameters?: Array<any>;
  81464. }
  81465. /** @hidden */
  81466. export interface IGLTFTechniqueStatesFunctions {
  81467. blendColor?: number[];
  81468. blendEquationSeparate?: number[];
  81469. blendFuncSeparate?: number[];
  81470. colorMask: boolean[];
  81471. cullFace: number[];
  81472. }
  81473. /** @hidden */
  81474. export interface IGLTFTechniqueStates {
  81475. enable: number[];
  81476. functions: IGLTFTechniqueStatesFunctions;
  81477. }
  81478. /** @hidden */
  81479. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81480. parameters: {
  81481. [key: string]: IGLTFTechniqueParameter;
  81482. };
  81483. program: string;
  81484. attributes: {
  81485. [key: string]: string;
  81486. };
  81487. uniforms: {
  81488. [key: string]: string;
  81489. };
  81490. states: IGLTFTechniqueStates;
  81491. }
  81492. /** @hidden */
  81493. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81494. technique?: string;
  81495. values: string[];
  81496. }
  81497. /** @hidden */
  81498. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81499. attributes: {
  81500. [key: string]: string;
  81501. };
  81502. indices: string;
  81503. material: string;
  81504. mode?: number;
  81505. }
  81506. /** @hidden */
  81507. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81508. primitives: IGLTFMeshPrimitive[];
  81509. }
  81510. /** @hidden */
  81511. export interface IGLTFImage extends IGLTFChildRootProperty {
  81512. uri: string;
  81513. }
  81514. /** @hidden */
  81515. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81516. magFilter?: number;
  81517. minFilter?: number;
  81518. wrapS?: number;
  81519. wrapT?: number;
  81520. }
  81521. /** @hidden */
  81522. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81523. sampler: string;
  81524. source: string;
  81525. format?: ETextureFormat;
  81526. internalFormat?: ETextureFormat;
  81527. target?: number;
  81528. type?: number;
  81529. babylonTexture?: Texture;
  81530. }
  81531. /** @hidden */
  81532. export interface IGLTFAmbienLight {
  81533. color?: number[];
  81534. }
  81535. /** @hidden */
  81536. export interface IGLTFDirectionalLight {
  81537. color?: number[];
  81538. }
  81539. /** @hidden */
  81540. export interface IGLTFPointLight {
  81541. color?: number[];
  81542. constantAttenuation?: number;
  81543. linearAttenuation?: number;
  81544. quadraticAttenuation?: number;
  81545. }
  81546. /** @hidden */
  81547. export interface IGLTFSpotLight {
  81548. color?: number[];
  81549. constantAttenuation?: number;
  81550. fallOfAngle?: number;
  81551. fallOffExponent?: number;
  81552. linearAttenuation?: number;
  81553. quadraticAttenuation?: number;
  81554. }
  81555. /** @hidden */
  81556. export interface IGLTFLight extends IGLTFChildRootProperty {
  81557. type: string;
  81558. }
  81559. /** @hidden */
  81560. export interface IGLTFCameraOrthographic {
  81561. xmag: number;
  81562. ymag: number;
  81563. zfar: number;
  81564. znear: number;
  81565. }
  81566. /** @hidden */
  81567. export interface IGLTFCameraPerspective {
  81568. aspectRatio: number;
  81569. yfov: number;
  81570. zfar: number;
  81571. znear: number;
  81572. }
  81573. /** @hidden */
  81574. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81575. type: string;
  81576. }
  81577. /** @hidden */
  81578. export interface IGLTFAnimationChannelTarget {
  81579. id: string;
  81580. path: string;
  81581. }
  81582. /** @hidden */
  81583. export interface IGLTFAnimationChannel {
  81584. sampler: string;
  81585. target: IGLTFAnimationChannelTarget;
  81586. }
  81587. /** @hidden */
  81588. export interface IGLTFAnimationSampler {
  81589. input: string;
  81590. output: string;
  81591. interpolation?: string;
  81592. }
  81593. /** @hidden */
  81594. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81595. channels?: IGLTFAnimationChannel[];
  81596. parameters?: {
  81597. [key: string]: string;
  81598. };
  81599. samplers?: {
  81600. [key: string]: IGLTFAnimationSampler;
  81601. };
  81602. }
  81603. /** @hidden */
  81604. export interface IGLTFNodeInstanceSkin {
  81605. skeletons: string[];
  81606. skin: string;
  81607. meshes: string[];
  81608. }
  81609. /** @hidden */
  81610. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81611. bindShapeMatrix: number[];
  81612. inverseBindMatrices: string;
  81613. jointNames: string[];
  81614. babylonSkeleton?: Skeleton;
  81615. }
  81616. /** @hidden */
  81617. export interface IGLTFNode extends IGLTFChildRootProperty {
  81618. camera?: string;
  81619. children: string[];
  81620. skin?: string;
  81621. jointName?: string;
  81622. light?: string;
  81623. matrix: number[];
  81624. mesh?: string;
  81625. meshes?: string[];
  81626. rotation?: number[];
  81627. scale?: number[];
  81628. translation?: number[];
  81629. babylonNode?: Node;
  81630. }
  81631. /** @hidden */
  81632. export interface IGLTFScene extends IGLTFChildRootProperty {
  81633. nodes: string[];
  81634. }
  81635. /** @hidden */
  81636. export interface IGLTFRuntime {
  81637. extensions: {
  81638. [key: string]: any;
  81639. };
  81640. accessors: {
  81641. [key: string]: IGLTFAccessor;
  81642. };
  81643. buffers: {
  81644. [key: string]: IGLTFBuffer;
  81645. };
  81646. bufferViews: {
  81647. [key: string]: IGLTFBufferView;
  81648. };
  81649. meshes: {
  81650. [key: string]: IGLTFMesh;
  81651. };
  81652. lights: {
  81653. [key: string]: IGLTFLight;
  81654. };
  81655. cameras: {
  81656. [key: string]: IGLTFCamera;
  81657. };
  81658. nodes: {
  81659. [key: string]: IGLTFNode;
  81660. };
  81661. images: {
  81662. [key: string]: IGLTFImage;
  81663. };
  81664. textures: {
  81665. [key: string]: IGLTFTexture;
  81666. };
  81667. shaders: {
  81668. [key: string]: IGLTFShader;
  81669. };
  81670. programs: {
  81671. [key: string]: IGLTFProgram;
  81672. };
  81673. samplers: {
  81674. [key: string]: IGLTFSampler;
  81675. };
  81676. techniques: {
  81677. [key: string]: IGLTFTechnique;
  81678. };
  81679. materials: {
  81680. [key: string]: IGLTFMaterial;
  81681. };
  81682. animations: {
  81683. [key: string]: IGLTFAnimation;
  81684. };
  81685. skins: {
  81686. [key: string]: IGLTFSkins;
  81687. };
  81688. currentScene?: Object;
  81689. scenes: {
  81690. [key: string]: IGLTFScene;
  81691. };
  81692. extensionsUsed: string[];
  81693. extensionsRequired?: string[];
  81694. buffersCount: number;
  81695. shaderscount: number;
  81696. scene: Scene;
  81697. rootUrl: string;
  81698. loadedBufferCount: number;
  81699. loadedBufferViews: {
  81700. [name: string]: ArrayBufferView;
  81701. };
  81702. loadedShaderCount: number;
  81703. importOnlyMeshes: boolean;
  81704. importMeshesNames?: string[];
  81705. dummyNodes: Node[];
  81706. forAssetContainer: boolean;
  81707. }
  81708. /** @hidden */
  81709. export interface INodeToRoot {
  81710. bone: Bone;
  81711. node: IGLTFNode;
  81712. id: string;
  81713. }
  81714. /** @hidden */
  81715. export interface IJointNode {
  81716. node: IGLTFNode;
  81717. id: string;
  81718. }
  81719. }
  81720. declare module BABYLON.GLTF1 {
  81721. /**
  81722. * Utils functions for GLTF
  81723. * @hidden
  81724. */
  81725. export class GLTFUtils {
  81726. /**
  81727. * Sets the given "parameter" matrix
  81728. * @param scene: the Scene object
  81729. * @param source: the source node where to pick the matrix
  81730. * @param parameter: the GLTF technique parameter
  81731. * @param uniformName: the name of the shader's uniform
  81732. * @param shaderMaterial: the shader material
  81733. */
  81734. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81735. /**
  81736. * Sets the given "parameter" matrix
  81737. * @param shaderMaterial: the shader material
  81738. * @param uniform: the name of the shader's uniform
  81739. * @param value: the value of the uniform
  81740. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81741. */
  81742. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81743. /**
  81744. * Returns the wrap mode of the texture
  81745. * @param mode: the mode value
  81746. */
  81747. static GetWrapMode(mode: number): number;
  81748. /**
  81749. * Returns the byte stride giving an accessor
  81750. * @param accessor: the GLTF accessor objet
  81751. */
  81752. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81753. /**
  81754. * Returns the texture filter mode giving a mode value
  81755. * @param mode: the filter mode value
  81756. */
  81757. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81758. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81759. /**
  81760. * Returns a buffer from its accessor
  81761. * @param gltfRuntime: the GLTF runtime
  81762. * @param accessor: the GLTF accessor
  81763. */
  81764. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81765. /**
  81766. * Decodes a buffer view into a string
  81767. * @param view: the buffer view
  81768. */
  81769. static DecodeBufferToText(view: ArrayBufferView): string;
  81770. /**
  81771. * Returns the default material of gltf. Related to
  81772. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81773. * @param scene: the Babylon.js scene
  81774. */
  81775. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81776. private static _DefaultMaterial;
  81777. }
  81778. }
  81779. declare module BABYLON.GLTF1 {
  81780. /**
  81781. * Implementation of the base glTF spec
  81782. * @hidden
  81783. */
  81784. export class GLTFLoaderBase {
  81785. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81786. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81787. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81788. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81789. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81790. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81791. }
  81792. /**
  81793. * glTF V1 Loader
  81794. * @hidden
  81795. */
  81796. export class GLTFLoader implements IGLTFLoader {
  81797. static Extensions: {
  81798. [name: string]: GLTFLoaderExtension;
  81799. };
  81800. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81801. state: Nullable<GLTFLoaderState>;
  81802. dispose(): void;
  81803. private _importMeshAsync;
  81804. /**
  81805. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81806. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81807. * @param scene the scene the meshes should be added to
  81808. * @param forAssetContainer defines if the entities must be stored in the scene
  81809. * @param data gltf data containing information of the meshes in a loaded file
  81810. * @param rootUrl root url to load from
  81811. * @param onProgress event that fires when loading progress has occured
  81812. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81813. */
  81814. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81815. private _loadAsync;
  81816. /**
  81817. * Imports all objects from a loaded gltf file and adds them to the scene
  81818. * @param scene the scene the objects should be added to
  81819. * @param data gltf data containing information of the meshes in a loaded file
  81820. * @param rootUrl root url to load from
  81821. * @param onProgress event that fires when loading progress has occured
  81822. * @returns a promise which completes when objects have been loaded to the scene
  81823. */
  81824. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81825. private _loadShadersAsync;
  81826. private _loadBuffersAsync;
  81827. private _createNodes;
  81828. }
  81829. /** @hidden */
  81830. export abstract class GLTFLoaderExtension {
  81831. private _name;
  81832. constructor(name: string);
  81833. get name(): string;
  81834. /**
  81835. * Defines an override for loading the runtime
  81836. * Return true to stop further extensions from loading the runtime
  81837. */
  81838. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81839. /**
  81840. * Defines an onverride for creating gltf runtime
  81841. * Return true to stop further extensions from creating the runtime
  81842. */
  81843. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81844. /**
  81845. * Defines an override for loading buffers
  81846. * Return true to stop further extensions from loading this buffer
  81847. */
  81848. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  81849. /**
  81850. * Defines an override for loading texture buffers
  81851. * Return true to stop further extensions from loading this texture data
  81852. */
  81853. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81854. /**
  81855. * Defines an override for creating textures
  81856. * Return true to stop further extensions from loading this texture
  81857. */
  81858. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  81859. /**
  81860. * Defines an override for loading shader strings
  81861. * Return true to stop further extensions from loading this shader data
  81862. */
  81863. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81864. /**
  81865. * Defines an override for loading materials
  81866. * Return true to stop further extensions from loading this material
  81867. */
  81868. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81869. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  81870. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  81871. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81872. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81873. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  81874. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81875. private static LoadTextureBufferAsync;
  81876. private static CreateTextureAsync;
  81877. private static ApplyExtensions;
  81878. }
  81879. }
  81880. declare module BABYLON.GLTF1 {
  81881. /** @hidden */
  81882. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  81883. private _bin;
  81884. constructor();
  81885. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  81886. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81887. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  81888. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  81889. }
  81890. }
  81891. declare module BABYLON.GLTF1 {
  81892. /** @hidden */
  81893. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  81894. constructor();
  81895. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  81896. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  81897. private _loadTexture;
  81898. }
  81899. }
  81900. declare module BABYLON.GLTF2.Loader {
  81901. /**
  81902. * Loader interface with an index field.
  81903. */
  81904. export interface IArrayItem {
  81905. /**
  81906. * The index of this item in the array.
  81907. */
  81908. index: number;
  81909. }
  81910. /**
  81911. * Loader interface with additional members.
  81912. */
  81913. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  81914. /** @hidden */
  81915. _data?: Promise<ArrayBufferView>;
  81916. /** @hidden */
  81917. _babylonVertexBuffer?: Promise<VertexBuffer>;
  81918. }
  81919. /**
  81920. * Loader interface with additional members.
  81921. */
  81922. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  81923. }
  81924. /** @hidden */
  81925. export interface _IAnimationSamplerData {
  81926. input: Float32Array;
  81927. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  81928. output: Float32Array;
  81929. }
  81930. /**
  81931. * Loader interface with additional members.
  81932. */
  81933. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  81934. /** @hidden */
  81935. _data?: Promise<_IAnimationSamplerData>;
  81936. }
  81937. /**
  81938. * Loader interface with additional members.
  81939. */
  81940. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  81941. channels: IAnimationChannel[];
  81942. samplers: IAnimationSampler[];
  81943. /** @hidden */
  81944. _babylonAnimationGroup?: AnimationGroup;
  81945. }
  81946. /**
  81947. * Loader interface with additional members.
  81948. */
  81949. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  81950. /** @hidden */
  81951. _data?: Promise<ArrayBufferView>;
  81952. }
  81953. /**
  81954. * Loader interface with additional members.
  81955. */
  81956. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  81957. /** @hidden */
  81958. _data?: Promise<ArrayBufferView>;
  81959. /** @hidden */
  81960. _babylonBuffer?: Promise<Buffer>;
  81961. }
  81962. /**
  81963. * Loader interface with additional members.
  81964. */
  81965. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  81966. }
  81967. /**
  81968. * Loader interface with additional members.
  81969. */
  81970. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  81971. /** @hidden */
  81972. _data?: Promise<ArrayBufferView>;
  81973. }
  81974. /**
  81975. * Loader interface with additional members.
  81976. */
  81977. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  81978. }
  81979. /**
  81980. * Loader interface with additional members.
  81981. */
  81982. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  81983. }
  81984. /**
  81985. * Loader interface with additional members.
  81986. */
  81987. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  81988. baseColorTexture?: ITextureInfo;
  81989. metallicRoughnessTexture?: ITextureInfo;
  81990. }
  81991. /**
  81992. * Loader interface with additional members.
  81993. */
  81994. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  81995. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  81996. normalTexture?: IMaterialNormalTextureInfo;
  81997. occlusionTexture?: IMaterialOcclusionTextureInfo;
  81998. emissiveTexture?: ITextureInfo;
  81999. /** @hidden */
  82000. _data?: {
  82001. [babylonDrawMode: number]: {
  82002. babylonMaterial: Material;
  82003. babylonMeshes: AbstractMesh[];
  82004. promise: Promise<void>;
  82005. };
  82006. };
  82007. }
  82008. /**
  82009. * Loader interface with additional members.
  82010. */
  82011. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82012. primitives: IMeshPrimitive[];
  82013. }
  82014. /**
  82015. * Loader interface with additional members.
  82016. */
  82017. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82018. /** @hidden */
  82019. _instanceData?: {
  82020. babylonSourceMesh: Mesh;
  82021. promise: Promise<any>;
  82022. };
  82023. }
  82024. /**
  82025. * Loader interface with additional members.
  82026. */
  82027. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82028. /**
  82029. * The parent glTF node.
  82030. */
  82031. parent?: INode;
  82032. /** @hidden */
  82033. _babylonTransformNode?: TransformNode;
  82034. /** @hidden */
  82035. _primitiveBabylonMeshes?: AbstractMesh[];
  82036. /** @hidden */
  82037. _babylonBones?: Bone[];
  82038. /** @hidden */
  82039. _numMorphTargets?: number;
  82040. }
  82041. /** @hidden */
  82042. export interface _ISamplerData {
  82043. noMipMaps: boolean;
  82044. samplingMode: number;
  82045. wrapU: number;
  82046. wrapV: number;
  82047. }
  82048. /**
  82049. * Loader interface with additional members.
  82050. */
  82051. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82052. /** @hidden */
  82053. _data?: _ISamplerData;
  82054. }
  82055. /**
  82056. * Loader interface with additional members.
  82057. */
  82058. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82059. }
  82060. /**
  82061. * Loader interface with additional members.
  82062. */
  82063. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82064. /** @hidden */
  82065. _data?: {
  82066. babylonSkeleton: Skeleton;
  82067. promise: Promise<void>;
  82068. };
  82069. }
  82070. /**
  82071. * Loader interface with additional members.
  82072. */
  82073. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82074. }
  82075. /**
  82076. * Loader interface with additional members.
  82077. */
  82078. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82079. }
  82080. /**
  82081. * Loader interface with additional members.
  82082. */
  82083. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82084. accessors?: IAccessor[];
  82085. animations?: IAnimation[];
  82086. buffers?: IBuffer[];
  82087. bufferViews?: IBufferView[];
  82088. cameras?: ICamera[];
  82089. images?: IImage[];
  82090. materials?: IMaterial[];
  82091. meshes?: IMesh[];
  82092. nodes?: INode[];
  82093. samplers?: ISampler[];
  82094. scenes?: IScene[];
  82095. skins?: ISkin[];
  82096. textures?: ITexture[];
  82097. }
  82098. }
  82099. declare module BABYLON.GLTF2 {
  82100. /**
  82101. * Interface for a glTF loader extension.
  82102. */
  82103. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82104. /**
  82105. * Called after the loader state changes to LOADING.
  82106. */
  82107. onLoading?(): void;
  82108. /**
  82109. * Called after the loader state changes to READY.
  82110. */
  82111. onReady?(): void;
  82112. /**
  82113. * Define this method to modify the default behavior when loading scenes.
  82114. * @param context The context when loading the asset
  82115. * @param scene The glTF scene property
  82116. * @returns A promise that resolves when the load is complete or null if not handled
  82117. */
  82118. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82119. /**
  82120. * Define this method to modify the default behavior when loading nodes.
  82121. * @param context The context when loading the asset
  82122. * @param node The glTF node property
  82123. * @param assign A function called synchronously after parsing the glTF properties
  82124. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82125. */
  82126. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82127. /**
  82128. * Define this method to modify the default behavior when loading cameras.
  82129. * @param context The context when loading the asset
  82130. * @param camera The glTF camera property
  82131. * @param assign A function called synchronously after parsing the glTF properties
  82132. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82133. */
  82134. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82135. /**
  82136. * @hidden
  82137. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82138. * @param context The context when loading the asset
  82139. * @param primitive The glTF mesh primitive property
  82140. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82141. */
  82142. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82143. /**
  82144. * @hidden
  82145. * Define this method to modify the default behavior when loading data for mesh primitives.
  82146. * @param context The context when loading the asset
  82147. * @param name The mesh name when loading the asset
  82148. * @param node The glTF node when loading the asset
  82149. * @param mesh The glTF mesh when loading the asset
  82150. * @param primitive The glTF mesh primitive property
  82151. * @param assign A function called synchronously after parsing the glTF properties
  82152. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82153. */
  82154. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82155. /**
  82156. * @hidden
  82157. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82158. * @param context The context when loading the asset
  82159. * @param material The glTF material property
  82160. * @param assign A function called synchronously after parsing the glTF properties
  82161. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82162. */
  82163. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82164. /**
  82165. * Define this method to modify the default behavior when creating materials.
  82166. * @param context The context when loading the asset
  82167. * @param material The glTF material property
  82168. * @param babylonDrawMode The draw mode for the Babylon material
  82169. * @returns The Babylon material or null if not handled
  82170. */
  82171. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82172. /**
  82173. * Define this method to modify the default behavior when loading material properties.
  82174. * @param context The context when loading the asset
  82175. * @param material The glTF material property
  82176. * @param babylonMaterial The Babylon material
  82177. * @returns A promise that resolves when the load is complete or null if not handled
  82178. */
  82179. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82180. /**
  82181. * Define this method to modify the default behavior when loading texture infos.
  82182. * @param context The context when loading the asset
  82183. * @param textureInfo The glTF texture info property
  82184. * @param assign A function called synchronously after parsing the glTF properties
  82185. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82186. */
  82187. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82188. /**
  82189. * @hidden
  82190. * Define this method to modify the default behavior when loading textures.
  82191. * @param context The context when loading the asset
  82192. * @param texture The glTF texture property
  82193. * @param assign A function called synchronously after parsing the glTF properties
  82194. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82195. */
  82196. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82197. /**
  82198. * Define this method to modify the default behavior when loading animations.
  82199. * @param context The context when loading the asset
  82200. * @param animation The glTF animation property
  82201. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82202. */
  82203. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82204. /**
  82205. * @hidden
  82206. * Define this method to modify the default behavior when loading skins.
  82207. * @param context The context when loading the asset
  82208. * @param node The glTF node property
  82209. * @param skin The glTF skin property
  82210. * @returns A promise that resolves when the load is complete or null if not handled
  82211. */
  82212. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82213. /**
  82214. * @hidden
  82215. * Define this method to modify the default behavior when loading uris.
  82216. * @param context The context when loading the asset
  82217. * @param property The glTF property associated with the uri
  82218. * @param uri The uri to load
  82219. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82220. */
  82221. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82222. /**
  82223. * Define this method to modify the default behavior when loading buffer views.
  82224. * @param context The context when loading the asset
  82225. * @param bufferView The glTF buffer view property
  82226. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82227. */
  82228. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82229. /**
  82230. * Define this method to modify the default behavior when loading buffers.
  82231. * @param context The context when loading the asset
  82232. * @param buffer The glTF buffer property
  82233. * @param byteOffset The byte offset to load
  82234. * @param byteLength The byte length to load
  82235. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82236. */
  82237. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82238. }
  82239. }
  82240. declare module BABYLON.GLTF2 {
  82241. /**
  82242. * Helper class for working with arrays when loading the glTF asset
  82243. */
  82244. export class ArrayItem {
  82245. /**
  82246. * Gets an item from the given array.
  82247. * @param context The context when loading the asset
  82248. * @param array The array to get the item from
  82249. * @param index The index to the array
  82250. * @returns The array item
  82251. */
  82252. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82253. /**
  82254. * Assign an `index` field to each item of the given array.
  82255. * @param array The array of items
  82256. */
  82257. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82258. }
  82259. /**
  82260. * The glTF 2.0 loader
  82261. */
  82262. export class GLTFLoader implements IGLTFLoader {
  82263. /** @hidden */
  82264. _completePromises: Promise<any>[];
  82265. /** @hidden */
  82266. _forAssetContainer: boolean;
  82267. /** Storage */
  82268. _babylonLights: Light[];
  82269. /** @hidden */
  82270. _disableInstancedMesh: number;
  82271. private _disposed;
  82272. private _parent;
  82273. private _state;
  82274. private _extensions;
  82275. private _rootUrl;
  82276. private _fileName;
  82277. private _uniqueRootUrl;
  82278. private _gltf;
  82279. private _bin;
  82280. private _babylonScene;
  82281. private _rootBabylonMesh;
  82282. private _defaultBabylonMaterialData;
  82283. private static _RegisteredExtensions;
  82284. /**
  82285. * The default glTF sampler.
  82286. */
  82287. static readonly DefaultSampler: ISampler;
  82288. /**
  82289. * Registers a loader extension.
  82290. * @param name The name of the loader extension.
  82291. * @param factory The factory function that creates the loader extension.
  82292. */
  82293. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82294. /**
  82295. * Unregisters a loader extension.
  82296. * @param name The name of the loader extension.
  82297. * @returns A boolean indicating whether the extension has been unregistered
  82298. */
  82299. static UnregisterExtension(name: string): boolean;
  82300. /**
  82301. * The loader state.
  82302. */
  82303. get state(): Nullable<GLTFLoaderState>;
  82304. /**
  82305. * The object that represents the glTF JSON.
  82306. */
  82307. get gltf(): IGLTF;
  82308. /**
  82309. * The BIN chunk of a binary glTF.
  82310. */
  82311. get bin(): Nullable<IDataBuffer>;
  82312. /**
  82313. * The parent file loader.
  82314. */
  82315. get parent(): GLTFFileLoader;
  82316. /**
  82317. * The Babylon scene when loading the asset.
  82318. */
  82319. get babylonScene(): Scene;
  82320. /**
  82321. * The root Babylon mesh when loading the asset.
  82322. */
  82323. get rootBabylonMesh(): Mesh;
  82324. /** @hidden */
  82325. constructor(parent: GLTFFileLoader);
  82326. /** @hidden */
  82327. dispose(): void;
  82328. /** @hidden */
  82329. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82330. /** @hidden */
  82331. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82332. private _loadAsync;
  82333. private _loadData;
  82334. private _setupData;
  82335. private _loadExtensions;
  82336. private _checkExtensions;
  82337. private _setState;
  82338. private _createRootNode;
  82339. /**
  82340. * Loads a glTF scene.
  82341. * @param context The context when loading the asset
  82342. * @param scene The glTF scene property
  82343. * @returns A promise that resolves when the load is complete
  82344. */
  82345. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82346. private _forEachPrimitive;
  82347. private _getMeshes;
  82348. private _getTransformNodes;
  82349. private _getSkeletons;
  82350. private _getAnimationGroups;
  82351. private _startAnimations;
  82352. /**
  82353. * Loads a glTF node.
  82354. * @param context The context when loading the asset
  82355. * @param node The glTF node property
  82356. * @param assign A function called synchronously after parsing the glTF properties
  82357. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82358. */
  82359. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82360. private _loadMeshAsync;
  82361. /**
  82362. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82363. * @param context The context when loading the asset
  82364. * @param name The mesh name when loading the asset
  82365. * @param node The glTF node when loading the asset
  82366. * @param mesh The glTF mesh when loading the asset
  82367. * @param primitive The glTF mesh primitive property
  82368. * @param assign A function called synchronously after parsing the glTF properties
  82369. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82370. */
  82371. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82372. private _loadVertexDataAsync;
  82373. private _createMorphTargets;
  82374. private _loadMorphTargetsAsync;
  82375. private _loadMorphTargetVertexDataAsync;
  82376. private static _LoadTransform;
  82377. private _loadSkinAsync;
  82378. private _loadBones;
  82379. private _loadBone;
  82380. private _loadSkinInverseBindMatricesDataAsync;
  82381. private _updateBoneMatrices;
  82382. private _getNodeMatrix;
  82383. /**
  82384. * Loads a glTF camera.
  82385. * @param context The context when loading the asset
  82386. * @param camera The glTF camera property
  82387. * @param assign A function called synchronously after parsing the glTF properties
  82388. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82389. */
  82390. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82391. private _loadAnimationsAsync;
  82392. /**
  82393. * Loads a glTF animation.
  82394. * @param context The context when loading the asset
  82395. * @param animation The glTF animation property
  82396. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82397. */
  82398. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82399. /**
  82400. * @hidden Loads a glTF animation channel.
  82401. * @param context The context when loading the asset
  82402. * @param animationContext The context of the animation when loading the asset
  82403. * @param animation The glTF animation property
  82404. * @param channel The glTF animation channel property
  82405. * @param babylonAnimationGroup The babylon animation group property
  82406. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82407. * @returns A void promise when the channel load is complete
  82408. */
  82409. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82410. private _loadAnimationSamplerAsync;
  82411. private _loadBufferAsync;
  82412. /**
  82413. * Loads a glTF buffer view.
  82414. * @param context The context when loading the asset
  82415. * @param bufferView The glTF buffer view property
  82416. * @returns A promise that resolves with the loaded data when the load is complete
  82417. */
  82418. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82419. private _loadAccessorAsync;
  82420. /** @hidden */
  82421. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82422. private _loadIndicesAccessorAsync;
  82423. private _loadVertexBufferViewAsync;
  82424. private _loadVertexAccessorAsync;
  82425. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82426. /** @hidden */
  82427. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82428. private _createDefaultMaterial;
  82429. /**
  82430. * Creates a Babylon material from a glTF material.
  82431. * @param context The context when loading the asset
  82432. * @param material The glTF material property
  82433. * @param babylonDrawMode The draw mode for the Babylon material
  82434. * @returns The Babylon material
  82435. */
  82436. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82437. /**
  82438. * Loads properties from a glTF material into a Babylon material.
  82439. * @param context The context when loading the asset
  82440. * @param material The glTF material property
  82441. * @param babylonMaterial The Babylon material
  82442. * @returns A promise that resolves when the load is complete
  82443. */
  82444. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82445. /**
  82446. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82447. * @param context The context when loading the asset
  82448. * @param material The glTF material property
  82449. * @param babylonMaterial The Babylon material
  82450. * @returns A promise that resolves when the load is complete
  82451. */
  82452. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82453. /**
  82454. * Loads the alpha properties from a glTF material into a Babylon material.
  82455. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82456. * @param context The context when loading the asset
  82457. * @param material The glTF material property
  82458. * @param babylonMaterial The Babylon material
  82459. */
  82460. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82461. /**
  82462. * Loads a glTF texture info.
  82463. * @param context The context when loading the asset
  82464. * @param textureInfo The glTF texture info property
  82465. * @param assign A function called synchronously after parsing the glTF properties
  82466. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82467. */
  82468. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82469. /** @hidden */
  82470. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82471. /** @hidden */
  82472. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82473. private _loadSampler;
  82474. /**
  82475. * Loads a glTF image.
  82476. * @param context The context when loading the asset
  82477. * @param image The glTF image property
  82478. * @returns A promise that resolves with the loaded data when the load is complete
  82479. */
  82480. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82481. /**
  82482. * Loads a glTF uri.
  82483. * @param context The context when loading the asset
  82484. * @param property The glTF property associated with the uri
  82485. * @param uri The base64 or relative uri
  82486. * @returns A promise that resolves with the loaded data when the load is complete
  82487. */
  82488. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82489. /**
  82490. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82491. * @param babylonObject the Babylon object with metadata
  82492. * @param pointer the JSON pointer
  82493. */
  82494. static AddPointerMetadata(babylonObject: {
  82495. metadata: any;
  82496. }, pointer: string): void;
  82497. private static _GetTextureWrapMode;
  82498. private static _GetTextureSamplingMode;
  82499. private static _GetTypedArrayConstructor;
  82500. private static _GetTypedArray;
  82501. private static _GetNumComponents;
  82502. private static _ValidateUri;
  82503. /** @hidden */
  82504. static _GetDrawMode(context: string, mode: number | undefined): number;
  82505. private _compileMaterialsAsync;
  82506. private _compileShadowGeneratorsAsync;
  82507. private _forEachExtensions;
  82508. private _applyExtensions;
  82509. private _extensionsOnLoading;
  82510. private _extensionsOnReady;
  82511. private _extensionsLoadSceneAsync;
  82512. private _extensionsLoadNodeAsync;
  82513. private _extensionsLoadCameraAsync;
  82514. private _extensionsLoadVertexDataAsync;
  82515. private _extensionsLoadMeshPrimitiveAsync;
  82516. private _extensionsLoadMaterialAsync;
  82517. private _extensionsCreateMaterial;
  82518. private _extensionsLoadMaterialPropertiesAsync;
  82519. private _extensionsLoadTextureInfoAsync;
  82520. private _extensionsLoadTextureAsync;
  82521. private _extensionsLoadAnimationAsync;
  82522. private _extensionsLoadSkinAsync;
  82523. private _extensionsLoadUriAsync;
  82524. private _extensionsLoadBufferViewAsync;
  82525. private _extensionsLoadBufferAsync;
  82526. /**
  82527. * Helper method called by a loader extension to load an glTF extension.
  82528. * @param context The context when loading the asset
  82529. * @param property The glTF property to load the extension from
  82530. * @param extensionName The name of the extension to load
  82531. * @param actionAsync The action to run
  82532. * @returns The promise returned by actionAsync or null if the extension does not exist
  82533. */
  82534. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82535. /**
  82536. * Helper method called by a loader extension to load a glTF extra.
  82537. * @param context The context when loading the asset
  82538. * @param property The glTF property to load the extra from
  82539. * @param extensionName The name of the extension to load
  82540. * @param actionAsync The action to run
  82541. * @returns The promise returned by actionAsync or null if the extra does not exist
  82542. */
  82543. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82544. /**
  82545. * Checks for presence of an extension.
  82546. * @param name The name of the extension to check
  82547. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82548. */
  82549. isExtensionUsed(name: string): boolean;
  82550. /**
  82551. * Increments the indentation level and logs a message.
  82552. * @param message The message to log
  82553. */
  82554. logOpen(message: string): void;
  82555. /**
  82556. * Decrements the indentation level.
  82557. */
  82558. logClose(): void;
  82559. /**
  82560. * Logs a message
  82561. * @param message The message to log
  82562. */
  82563. log(message: string): void;
  82564. /**
  82565. * Starts a performance counter.
  82566. * @param counterName The name of the performance counter
  82567. */
  82568. startPerformanceCounter(counterName: string): void;
  82569. /**
  82570. * Ends a performance counter.
  82571. * @param counterName The name of the performance counter
  82572. */
  82573. endPerformanceCounter(counterName: string): void;
  82574. }
  82575. }
  82576. declare module BABYLON.GLTF2.Loader.Extensions {
  82577. /** @hidden */
  82578. interface IEXTLightsImageBased_LightImageBased {
  82579. _babylonTexture?: BaseTexture;
  82580. _loaded?: Promise<void>;
  82581. }
  82582. /**
  82583. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82584. */
  82585. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82586. /**
  82587. * The name of this extension.
  82588. */
  82589. readonly name: string;
  82590. /**
  82591. * Defines whether this extension is enabled.
  82592. */
  82593. enabled: boolean;
  82594. private _loader;
  82595. private _lights?;
  82596. /** @hidden */
  82597. constructor(loader: GLTFLoader);
  82598. /** @hidden */
  82599. dispose(): void;
  82600. /** @hidden */
  82601. onLoading(): void;
  82602. /** @hidden */
  82603. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82604. private _loadLightAsync;
  82605. }
  82606. }
  82607. declare module BABYLON.GLTF2.Loader.Extensions {
  82608. /**
  82609. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82610. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82611. * !!! Experimental Extension Subject to Changes !!!
  82612. */
  82613. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82614. /**
  82615. * The name of this extension.
  82616. */
  82617. readonly name: string;
  82618. /**
  82619. * Defines whether this extension is enabled.
  82620. */
  82621. enabled: boolean;
  82622. private _loader;
  82623. /** @hidden */
  82624. constructor(loader: GLTFLoader);
  82625. /** @hidden */
  82626. dispose(): void;
  82627. /** @hidden */
  82628. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82629. }
  82630. }
  82631. declare module BABYLON.GLTF2.Loader.Extensions {
  82632. /**
  82633. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82634. */
  82635. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82636. /** The name of this extension. */
  82637. readonly name: string;
  82638. /** Defines whether this extension is enabled. */
  82639. enabled: boolean;
  82640. private _loader;
  82641. /** @hidden */
  82642. constructor(loader: GLTFLoader);
  82643. /** @hidden */
  82644. dispose(): void;
  82645. /** @hidden */
  82646. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82647. }
  82648. }
  82649. declare module BABYLON.GLTF2.Loader.Extensions {
  82650. /**
  82651. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82652. */
  82653. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82654. /**
  82655. * The name of this extension.
  82656. */
  82657. readonly name: string;
  82658. /**
  82659. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82660. */
  82661. dracoCompression?: DracoCompression;
  82662. /**
  82663. * Defines whether this extension is enabled.
  82664. */
  82665. enabled: boolean;
  82666. private _loader;
  82667. /** @hidden */
  82668. constructor(loader: GLTFLoader);
  82669. /** @hidden */
  82670. dispose(): void;
  82671. /** @hidden */
  82672. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82673. }
  82674. }
  82675. declare module BABYLON.GLTF2.Loader.Extensions {
  82676. /**
  82677. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82678. */
  82679. export class KHR_lights implements IGLTFLoaderExtension {
  82680. /**
  82681. * The name of this extension.
  82682. */
  82683. readonly name: string;
  82684. /**
  82685. * Defines whether this extension is enabled.
  82686. */
  82687. enabled: boolean;
  82688. private _loader;
  82689. private _lights?;
  82690. /** @hidden */
  82691. constructor(loader: GLTFLoader);
  82692. /** @hidden */
  82693. dispose(): void;
  82694. /** @hidden */
  82695. onLoading(): void;
  82696. /** @hidden */
  82697. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82698. }
  82699. }
  82700. declare module BABYLON.GLTF2.Loader.Extensions {
  82701. /**
  82702. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82703. */
  82704. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82705. /**
  82706. * The name of this extension.
  82707. */
  82708. readonly name: string;
  82709. /**
  82710. * Defines whether this extension is enabled.
  82711. */
  82712. enabled: boolean;
  82713. /**
  82714. * Defines a number that determines the order the extensions are applied.
  82715. */
  82716. order: number;
  82717. private _loader;
  82718. /** @hidden */
  82719. constructor(loader: GLTFLoader);
  82720. /** @hidden */
  82721. dispose(): void;
  82722. /** @hidden */
  82723. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82724. private _loadSpecularGlossinessPropertiesAsync;
  82725. }
  82726. }
  82727. declare module BABYLON.GLTF2.Loader.Extensions {
  82728. /**
  82729. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82730. */
  82731. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82732. /**
  82733. * The name of this extension.
  82734. */
  82735. readonly name: string;
  82736. /**
  82737. * Defines whether this extension is enabled.
  82738. */
  82739. enabled: boolean;
  82740. /**
  82741. * Defines a number that determines the order the extensions are applied.
  82742. */
  82743. order: number;
  82744. private _loader;
  82745. /** @hidden */
  82746. constructor(loader: GLTFLoader);
  82747. /** @hidden */
  82748. dispose(): void;
  82749. /** @hidden */
  82750. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82751. private _loadUnlitPropertiesAsync;
  82752. }
  82753. }
  82754. declare module BABYLON.GLTF2.Loader.Extensions {
  82755. /**
  82756. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82757. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82758. * !!! Experimental Extension Subject to Changes !!!
  82759. */
  82760. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82761. /**
  82762. * The name of this extension.
  82763. */
  82764. readonly name: string;
  82765. /**
  82766. * Defines whether this extension is enabled.
  82767. */
  82768. enabled: boolean;
  82769. /**
  82770. * Defines a number that determines the order the extensions are applied.
  82771. */
  82772. order: number;
  82773. private _loader;
  82774. /** @hidden */
  82775. constructor(loader: GLTFLoader);
  82776. /** @hidden */
  82777. dispose(): void;
  82778. /** @hidden */
  82779. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82780. private _loadClearCoatPropertiesAsync;
  82781. }
  82782. }
  82783. declare module BABYLON.GLTF2.Loader.Extensions {
  82784. /**
  82785. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82786. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82787. * !!! Experimental Extension Subject to Changes !!!
  82788. */
  82789. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82790. /**
  82791. * The name of this extension.
  82792. */
  82793. readonly name: string;
  82794. /**
  82795. * Defines whether this extension is enabled.
  82796. */
  82797. enabled: boolean;
  82798. /**
  82799. * Defines a number that determines the order the extensions are applied.
  82800. */
  82801. order: number;
  82802. private _loader;
  82803. /** @hidden */
  82804. constructor(loader: GLTFLoader);
  82805. /** @hidden */
  82806. dispose(): void;
  82807. /** @hidden */
  82808. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82809. private _loadSheenPropertiesAsync;
  82810. }
  82811. }
  82812. declare module BABYLON.GLTF2.Loader.Extensions {
  82813. /**
  82814. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82815. * !!! Experimental Extension Subject to Changes !!!
  82816. */
  82817. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82818. /**
  82819. * The name of this extension.
  82820. */
  82821. readonly name: string;
  82822. /**
  82823. * Defines whether this extension is enabled.
  82824. */
  82825. enabled: boolean;
  82826. /**
  82827. * Defines a number that determines the order the extensions are applied.
  82828. */
  82829. order: number;
  82830. private _loader;
  82831. /** @hidden */
  82832. constructor(loader: GLTFLoader);
  82833. /** @hidden */
  82834. dispose(): void;
  82835. /** @hidden */
  82836. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82837. private _loadSpecularPropertiesAsync;
  82838. }
  82839. }
  82840. declare module BABYLON.GLTF2.Loader.Extensions {
  82841. /**
  82842. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82843. * !!! Experimental Extension Subject to Changes !!!
  82844. */
  82845. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82846. /**
  82847. * Default ior Value from the spec.
  82848. */
  82849. private static readonly _DEFAULT_IOR;
  82850. /**
  82851. * The name of this extension.
  82852. */
  82853. readonly name: string;
  82854. /**
  82855. * Defines whether this extension is enabled.
  82856. */
  82857. enabled: boolean;
  82858. /**
  82859. * Defines a number that determines the order the extensions are applied.
  82860. */
  82861. order: number;
  82862. private _loader;
  82863. /** @hidden */
  82864. constructor(loader: GLTFLoader);
  82865. /** @hidden */
  82866. dispose(): void;
  82867. /** @hidden */
  82868. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82869. private _loadIorPropertiesAsync;
  82870. }
  82871. }
  82872. declare module BABYLON.GLTF2.Loader.Extensions {
  82873. /**
  82874. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  82875. * !!! Experimental Extension Subject to Changes !!!
  82876. */
  82877. export class KHR_materials_variants implements IGLTFLoaderExtension {
  82878. /**
  82879. * The name of this extension.
  82880. */
  82881. readonly name: string;
  82882. /**
  82883. * Defines whether this extension is enabled.
  82884. */
  82885. enabled: boolean;
  82886. private _loader;
  82887. private _variants?;
  82888. /** @hidden */
  82889. constructor(loader: GLTFLoader);
  82890. /** @hidden */
  82891. dispose(): void;
  82892. /**
  82893. * Gets the list of available variant names for this asset.
  82894. * @param rootMesh The glTF root mesh
  82895. * @returns the list of all the variant names for this model
  82896. */
  82897. static GetAvailableVariants(rootMesh: Mesh): string[];
  82898. /**
  82899. * Gets the list of available variant names for this asset.
  82900. * @param rootMesh The glTF root mesh
  82901. * @returns the list of all the variant names for this model
  82902. */
  82903. getAvailableVariants(rootMesh: Mesh): string[];
  82904. /**
  82905. * Select a variant given a variant name or a list of variant names.
  82906. * @param rootMesh The glTF root mesh
  82907. * @param variantName The variant name(s) to select.
  82908. */
  82909. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82910. /**
  82911. * Select a variant given a variant name or a list of variant names.
  82912. * @param rootMesh The glTF root mesh
  82913. * @param variantName The variant name(s) to select.
  82914. */
  82915. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  82916. /**
  82917. * Reset back to the original before selecting a variant.
  82918. * @param rootMesh The glTF root mesh
  82919. */
  82920. static Reset(rootMesh: Mesh): void;
  82921. /**
  82922. * Reset back to the original before selecting a variant.
  82923. * @param rootMesh The glTF root mesh
  82924. */
  82925. reset(rootMesh: Mesh): void;
  82926. /**
  82927. * Gets the last selected variant name(s) or null if original.
  82928. * @param rootMesh The glTF root mesh
  82929. * @returns The selected variant name(s).
  82930. */
  82931. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82932. /**
  82933. * Gets the last selected variant name(s) or null if original.
  82934. * @param rootMesh The glTF root mesh
  82935. * @returns The selected variant name(s).
  82936. */
  82937. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  82938. private static _GetExtensionMetadata;
  82939. /** @hidden */
  82940. onLoading(): void;
  82941. /** @hidden */
  82942. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82943. }
  82944. }
  82945. declare module BABYLON.GLTF2.Loader.Extensions {
  82946. /**
  82947. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  82948. * !!! Experimental Extension Subject to Changes !!!
  82949. */
  82950. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  82951. /**
  82952. * The name of this extension.
  82953. */
  82954. readonly name: string;
  82955. /**
  82956. * Defines whether this extension is enabled.
  82957. */
  82958. enabled: boolean;
  82959. /**
  82960. * Defines a number that determines the order the extensions are applied.
  82961. */
  82962. order: number;
  82963. private _loader;
  82964. /** @hidden */
  82965. constructor(loader: GLTFLoader);
  82966. /** @hidden */
  82967. dispose(): void;
  82968. /** @hidden */
  82969. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82970. private _loadTransparentPropertiesAsync;
  82971. }
  82972. }
  82973. declare module BABYLON.GLTF2.Loader.Extensions {
  82974. /**
  82975. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  82976. */
  82977. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  82978. /**
  82979. * The name of this extension.
  82980. */
  82981. readonly name: string;
  82982. /**
  82983. * Defines whether this extension is enabled.
  82984. */
  82985. enabled: boolean;
  82986. /** @hidden */
  82987. constructor(loader: GLTFLoader);
  82988. /** @hidden */
  82989. dispose(): void;
  82990. }
  82991. }
  82992. declare module BABYLON.GLTF2.Loader.Extensions {
  82993. /**
  82994. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  82995. * !!! Experimental Extension Subject to Changes !!!
  82996. */
  82997. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  82998. /** The name of this extension. */
  82999. readonly name: string;
  83000. /** Defines whether this extension is enabled. */
  83001. enabled: boolean;
  83002. private _loader;
  83003. /** @hidden */
  83004. constructor(loader: GLTFLoader);
  83005. /** @hidden */
  83006. dispose(): void;
  83007. /** @hidden */
  83008. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83009. }
  83010. }
  83011. declare module BABYLON.GLTF2.Loader.Extensions {
  83012. /**
  83013. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83014. */
  83015. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83016. /**
  83017. * The name of this extension.
  83018. */
  83019. readonly name: string;
  83020. /**
  83021. * Defines whether this extension is enabled.
  83022. */
  83023. enabled: boolean;
  83024. private _loader;
  83025. /** @hidden */
  83026. constructor(loader: GLTFLoader);
  83027. /** @hidden */
  83028. dispose(): void;
  83029. /** @hidden */
  83030. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83031. }
  83032. }
  83033. declare module BABYLON.GLTF2.Loader.Extensions {
  83034. /**
  83035. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83036. * !!! Experimental Extension Subject to Changes !!!
  83037. */
  83038. export class KHR_xmp implements IGLTFLoaderExtension {
  83039. /**
  83040. * The name of this extension.
  83041. */
  83042. readonly name: string;
  83043. /**
  83044. * Defines whether this extension is enabled.
  83045. */
  83046. enabled: boolean;
  83047. /**
  83048. * Defines a number that determines the order the extensions are applied.
  83049. */
  83050. order: number;
  83051. private _loader;
  83052. /** @hidden */
  83053. constructor(loader: GLTFLoader);
  83054. /** @hidden */
  83055. dispose(): void;
  83056. /**
  83057. * Called after the loader state changes to LOADING.
  83058. */
  83059. onLoading(): void;
  83060. }
  83061. }
  83062. declare module BABYLON.GLTF2.Loader.Extensions {
  83063. /**
  83064. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83065. */
  83066. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83067. /**
  83068. * The name of this extension.
  83069. */
  83070. readonly name: string;
  83071. /**
  83072. * Defines whether this extension is enabled.
  83073. */
  83074. enabled: boolean;
  83075. private _loader;
  83076. private _clips;
  83077. private _emitters;
  83078. /** @hidden */
  83079. constructor(loader: GLTFLoader);
  83080. /** @hidden */
  83081. dispose(): void;
  83082. /** @hidden */
  83083. onLoading(): void;
  83084. /** @hidden */
  83085. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83086. /** @hidden */
  83087. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83088. /** @hidden */
  83089. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83090. private _loadClipAsync;
  83091. private _loadEmitterAsync;
  83092. private _getEventAction;
  83093. private _loadAnimationEventAsync;
  83094. }
  83095. }
  83096. declare module BABYLON.GLTF2.Loader.Extensions {
  83097. /**
  83098. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83099. */
  83100. export class MSFT_lod implements IGLTFLoaderExtension {
  83101. /**
  83102. * The name of this extension.
  83103. */
  83104. readonly name: string;
  83105. /**
  83106. * Defines whether this extension is enabled.
  83107. */
  83108. enabled: boolean;
  83109. /**
  83110. * Defines a number that determines the order the extensions are applied.
  83111. */
  83112. order: number;
  83113. /**
  83114. * Maximum number of LODs to load, starting from the lowest LOD.
  83115. */
  83116. maxLODsToLoad: number;
  83117. /**
  83118. * Observable raised when all node LODs of one level are loaded.
  83119. * The event data is the index of the loaded LOD starting from zero.
  83120. * Dispose the loader to cancel the loading of the next level of LODs.
  83121. */
  83122. onNodeLODsLoadedObservable: Observable<number>;
  83123. /**
  83124. * Observable raised when all material LODs of one level are loaded.
  83125. * The event data is the index of the loaded LOD starting from zero.
  83126. * Dispose the loader to cancel the loading of the next level of LODs.
  83127. */
  83128. onMaterialLODsLoadedObservable: Observable<number>;
  83129. private _loader;
  83130. private _bufferLODs;
  83131. private _nodeIndexLOD;
  83132. private _nodeSignalLODs;
  83133. private _nodePromiseLODs;
  83134. private _nodeBufferLODs;
  83135. private _materialIndexLOD;
  83136. private _materialSignalLODs;
  83137. private _materialPromiseLODs;
  83138. private _materialBufferLODs;
  83139. /** @hidden */
  83140. constructor(loader: GLTFLoader);
  83141. /** @hidden */
  83142. dispose(): void;
  83143. /** @hidden */
  83144. onReady(): void;
  83145. /** @hidden */
  83146. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83147. /** @hidden */
  83148. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83149. /** @hidden */
  83150. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83151. /** @hidden */
  83152. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83153. /** @hidden */
  83154. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83155. private _loadBufferLOD;
  83156. /**
  83157. * Gets an array of LOD properties from lowest to highest.
  83158. */
  83159. private _getLODs;
  83160. private _disposeTransformNode;
  83161. private _disposeMaterials;
  83162. }
  83163. }
  83164. declare module BABYLON.GLTF2.Loader.Extensions {
  83165. /** @hidden */
  83166. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83167. readonly name: string;
  83168. enabled: boolean;
  83169. private _loader;
  83170. constructor(loader: GLTFLoader);
  83171. dispose(): void;
  83172. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83173. }
  83174. }
  83175. declare module BABYLON.GLTF2.Loader.Extensions {
  83176. /** @hidden */
  83177. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83178. readonly name: string;
  83179. enabled: boolean;
  83180. private _loader;
  83181. constructor(loader: GLTFLoader);
  83182. dispose(): void;
  83183. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83184. }
  83185. }
  83186. declare module BABYLON.GLTF2.Loader.Extensions {
  83187. /**
  83188. * Store glTF extras (if present) in BJS objects' metadata
  83189. */
  83190. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83191. /**
  83192. * The name of this extension.
  83193. */
  83194. readonly name: string;
  83195. /**
  83196. * Defines whether this extension is enabled.
  83197. */
  83198. enabled: boolean;
  83199. private _loader;
  83200. private _assignExtras;
  83201. /** @hidden */
  83202. constructor(loader: GLTFLoader);
  83203. /** @hidden */
  83204. dispose(): void;
  83205. /** @hidden */
  83206. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83207. /** @hidden */
  83208. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83209. /** @hidden */
  83210. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83211. }
  83212. }
  83213. declare module BABYLON {
  83214. /**
  83215. * Class reading and parsing the MTL file bundled with the obj file.
  83216. */
  83217. export class MTLFileLoader {
  83218. /**
  83219. * Invert Y-Axis of referenced textures on load
  83220. */
  83221. static INVERT_TEXTURE_Y: boolean;
  83222. /**
  83223. * All material loaded from the mtl will be set here
  83224. */
  83225. materials: StandardMaterial[];
  83226. /**
  83227. * This function will read the mtl file and create each material described inside
  83228. * This function could be improve by adding :
  83229. * -some component missing (Ni, Tf...)
  83230. * -including the specific options available
  83231. *
  83232. * @param scene defines the scene the material will be created in
  83233. * @param data defines the mtl data to parse
  83234. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83235. * @param forAssetContainer defines if the material should be registered in the scene
  83236. */
  83237. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83238. /**
  83239. * Gets the texture for the material.
  83240. *
  83241. * If the material is imported from input file,
  83242. * We sanitize the url to ensure it takes the textre from aside the material.
  83243. *
  83244. * @param rootUrl The root url to load from
  83245. * @param value The value stored in the mtl
  83246. * @return The Texture
  83247. */
  83248. private static _getTexture;
  83249. }
  83250. }
  83251. declare module BABYLON {
  83252. /**
  83253. * Options for loading OBJ/MTL files
  83254. */
  83255. type MeshLoadOptions = {
  83256. /**
  83257. * Defines if UVs are optimized by default during load.
  83258. */
  83259. OptimizeWithUV: boolean;
  83260. /**
  83261. * Defines custom scaling of UV coordinates of loaded meshes.
  83262. */
  83263. UVScaling: Vector2;
  83264. /**
  83265. * Invert model on y-axis (does a model scaling inversion)
  83266. */
  83267. InvertY: boolean;
  83268. /**
  83269. * Invert Y-Axis of referenced textures on load
  83270. */
  83271. InvertTextureY: boolean;
  83272. /**
  83273. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83274. */
  83275. ImportVertexColors: boolean;
  83276. /**
  83277. * Compute the normals for the model, even if normals are present in the file.
  83278. */
  83279. ComputeNormals: boolean;
  83280. /**
  83281. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83282. */
  83283. SkipMaterials: boolean;
  83284. /**
  83285. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83286. */
  83287. MaterialLoadingFailsSilently: boolean;
  83288. };
  83289. /**
  83290. * OBJ file type loader.
  83291. * This is a babylon scene loader plugin.
  83292. */
  83293. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83294. /**
  83295. * Defines if UVs are optimized by default during load.
  83296. */
  83297. static OPTIMIZE_WITH_UV: boolean;
  83298. /**
  83299. * Invert model on y-axis (does a model scaling inversion)
  83300. */
  83301. static INVERT_Y: boolean;
  83302. /**
  83303. * Invert Y-Axis of referenced textures on load
  83304. */
  83305. static get INVERT_TEXTURE_Y(): boolean;
  83306. static set INVERT_TEXTURE_Y(value: boolean);
  83307. /**
  83308. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83309. */
  83310. static IMPORT_VERTEX_COLORS: boolean;
  83311. /**
  83312. * Compute the normals for the model, even if normals are present in the file.
  83313. */
  83314. static COMPUTE_NORMALS: boolean;
  83315. /**
  83316. * Defines custom scaling of UV coordinates of loaded meshes.
  83317. */
  83318. static UV_SCALING: Vector2;
  83319. /**
  83320. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83321. */
  83322. static SKIP_MATERIALS: boolean;
  83323. /**
  83324. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83325. *
  83326. * Defaults to true for backwards compatibility.
  83327. */
  83328. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83329. /**
  83330. * Defines the name of the plugin.
  83331. */
  83332. name: string;
  83333. /**
  83334. * Defines the extension the plugin is able to load.
  83335. */
  83336. extensions: string;
  83337. /** @hidden */
  83338. obj: RegExp;
  83339. /** @hidden */
  83340. group: RegExp;
  83341. /** @hidden */
  83342. mtllib: RegExp;
  83343. /** @hidden */
  83344. usemtl: RegExp;
  83345. /** @hidden */
  83346. smooth: RegExp;
  83347. /** @hidden */
  83348. vertexPattern: RegExp;
  83349. /** @hidden */
  83350. normalPattern: RegExp;
  83351. /** @hidden */
  83352. uvPattern: RegExp;
  83353. /** @hidden */
  83354. facePattern1: RegExp;
  83355. /** @hidden */
  83356. facePattern2: RegExp;
  83357. /** @hidden */
  83358. facePattern3: RegExp;
  83359. /** @hidden */
  83360. facePattern4: RegExp;
  83361. /** @hidden */
  83362. facePattern5: RegExp;
  83363. private _forAssetContainer;
  83364. private _meshLoadOptions;
  83365. /**
  83366. * Creates loader for .OBJ files
  83367. *
  83368. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83369. */
  83370. constructor(meshLoadOptions?: MeshLoadOptions);
  83371. private static get currentMeshLoadOptions();
  83372. /**
  83373. * Calls synchronously the MTL file attached to this obj.
  83374. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83375. * Without this function materials are not displayed in the first frame (but displayed after).
  83376. * In consequence it is impossible to get material information in your HTML file
  83377. *
  83378. * @param url The URL of the MTL file
  83379. * @param rootUrl
  83380. * @param onSuccess Callback function to be called when the MTL file is loaded
  83381. * @private
  83382. */
  83383. private _loadMTL;
  83384. /**
  83385. * Instantiates a OBJ file loader plugin.
  83386. * @returns the created plugin
  83387. */
  83388. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83389. /**
  83390. * If the data string can be loaded directly.
  83391. *
  83392. * @param data string containing the file data
  83393. * @returns if the data can be loaded directly
  83394. */
  83395. canDirectLoad(data: string): boolean;
  83396. /**
  83397. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83398. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83399. * @param scene the scene the meshes should be added to
  83400. * @param data the OBJ data to load
  83401. * @param rootUrl root url to load from
  83402. * @param onProgress event that fires when loading progress has occured
  83403. * @param fileName Defines the name of the file to load
  83404. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83405. */
  83406. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83407. meshes: AbstractMesh[];
  83408. particleSystems: IParticleSystem[];
  83409. skeletons: Skeleton[];
  83410. animationGroups: AnimationGroup[];
  83411. }>;
  83412. /**
  83413. * Imports all objects from the loaded OBJ data and adds them to the scene
  83414. * @param scene the scene the objects should be added to
  83415. * @param data the OBJ data to load
  83416. * @param rootUrl root url to load from
  83417. * @param onProgress event that fires when loading progress has occured
  83418. * @param fileName Defines the name of the file to load
  83419. * @returns a promise which completes when objects have been loaded to the scene
  83420. */
  83421. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83422. /**
  83423. * Load into an asset container.
  83424. * @param scene The scene to load into
  83425. * @param data The data to import
  83426. * @param rootUrl The root url for scene and resources
  83427. * @param onProgress The callback when the load progresses
  83428. * @param fileName Defines the name of the file to load
  83429. * @returns The loaded asset container
  83430. */
  83431. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83432. /**
  83433. * Read the OBJ file and create an Array of meshes.
  83434. * Each mesh contains all information given by the OBJ and the MTL file.
  83435. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83436. *
  83437. * @param meshesNames
  83438. * @param scene Scene The scene where are displayed the data
  83439. * @param data String The content of the obj file
  83440. * @param rootUrl String The path to the folder
  83441. * @returns Array<AbstractMesh>
  83442. * @private
  83443. */
  83444. private _parseSolid;
  83445. }
  83446. }
  83447. declare module BABYLON {
  83448. /**
  83449. * STL file type loader.
  83450. * This is a babylon scene loader plugin.
  83451. */
  83452. export class STLFileLoader implements ISceneLoaderPlugin {
  83453. /** @hidden */
  83454. solidPattern: RegExp;
  83455. /** @hidden */
  83456. facetsPattern: RegExp;
  83457. /** @hidden */
  83458. normalPattern: RegExp;
  83459. /** @hidden */
  83460. vertexPattern: RegExp;
  83461. /**
  83462. * Defines the name of the plugin.
  83463. */
  83464. name: string;
  83465. /**
  83466. * Defines the extensions the stl loader is able to load.
  83467. * force data to come in as an ArrayBuffer
  83468. * we'll convert to string if it looks like it's an ASCII .stl
  83469. */
  83470. extensions: ISceneLoaderPluginExtensions;
  83471. /**
  83472. * Import meshes into a scene.
  83473. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83474. * @param scene The scene to import into
  83475. * @param data The data to import
  83476. * @param rootUrl The root url for scene and resources
  83477. * @param meshes The meshes array to import into
  83478. * @param particleSystems The particle systems array to import into
  83479. * @param skeletons The skeletons array to import into
  83480. * @param onError The callback when import fails
  83481. * @returns True if successful or false otherwise
  83482. */
  83483. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83484. /**
  83485. * Load into a scene.
  83486. * @param scene The scene to load into
  83487. * @param data The data to import
  83488. * @param rootUrl The root url for scene and resources
  83489. * @param onError The callback when import fails
  83490. * @returns true if successful or false otherwise
  83491. */
  83492. load(scene: Scene, data: any, rootUrl: string): boolean;
  83493. /**
  83494. * Load into an asset container.
  83495. * @param scene The scene to load into
  83496. * @param data The data to import
  83497. * @param rootUrl The root url for scene and resources
  83498. * @param onError The callback when import fails
  83499. * @returns The loaded asset container
  83500. */
  83501. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83502. private _isBinary;
  83503. private _parseBinary;
  83504. private _parseASCII;
  83505. }
  83506. }
  83507. declare module BABYLON {
  83508. /**
  83509. * Class for generating OBJ data from a Babylon scene.
  83510. */
  83511. export class OBJExport {
  83512. /**
  83513. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83514. * @param mesh defines the list of meshes to serialize
  83515. * @param materials defines if materials should be exported
  83516. * @param matlibname defines the name of the associated mtl file
  83517. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83518. * @returns the OBJ content
  83519. */
  83520. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83521. /**
  83522. * Exports the material(s) of a mesh in .MTL file format (text)
  83523. * @param mesh defines the mesh to extract the material from
  83524. * @returns the mtl content
  83525. */
  83526. static MTL(mesh: Mesh): string;
  83527. }
  83528. }
  83529. declare module BABYLON {
  83530. /** @hidden */
  83531. export var __IGLTFExporterExtension: number;
  83532. /**
  83533. * Interface for extending the exporter
  83534. * @hidden
  83535. */
  83536. export interface IGLTFExporterExtension {
  83537. /**
  83538. * The name of this extension
  83539. */
  83540. readonly name: string;
  83541. /**
  83542. * Defines whether this extension is enabled
  83543. */
  83544. enabled: boolean;
  83545. /**
  83546. * Defines whether this extension is required
  83547. */
  83548. required: boolean;
  83549. }
  83550. }
  83551. declare module BABYLON.GLTF2.Exporter {
  83552. /** @hidden */
  83553. export var __IGLTFExporterExtensionV2: number;
  83554. /**
  83555. * Interface for a glTF exporter extension
  83556. * @hidden
  83557. */
  83558. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83559. /**
  83560. * Define this method to modify the default behavior before exporting a texture
  83561. * @param context The context when loading the asset
  83562. * @param babylonTexture The Babylon.js texture
  83563. * @param mimeType The mime-type of the generated image
  83564. * @returns A promise that resolves with the exported texture
  83565. */
  83566. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83567. /**
  83568. * Define this method to get notified when a texture info is created
  83569. * @param context The context when loading the asset
  83570. * @param textureInfo The glTF texture info
  83571. * @param babylonTexture The Babylon.js texture
  83572. */
  83573. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83574. /**
  83575. * Define this method to modify the default behavior when exporting texture info
  83576. * @param context The context when loading the asset
  83577. * @param meshPrimitive glTF mesh primitive
  83578. * @param babylonSubMesh Babylon submesh
  83579. * @param binaryWriter glTF serializer binary writer instance
  83580. * @returns nullable IMeshPrimitive promise
  83581. */
  83582. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83583. /**
  83584. * Define this method to modify the default behavior when exporting a node
  83585. * @param context The context when exporting the node
  83586. * @param node glTF node
  83587. * @param babylonNode BabylonJS node
  83588. * @returns nullable INode promise
  83589. */
  83590. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83591. [key: number]: number;
  83592. }): Promise<Nullable<INode>>;
  83593. /**
  83594. * Define this method to modify the default behavior when exporting a material
  83595. * @param material glTF material
  83596. * @param babylonMaterial BabylonJS material
  83597. * @returns nullable IMaterial promise
  83598. */
  83599. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83600. /**
  83601. * Define this method to return additional textures to export from a material
  83602. * @param material glTF material
  83603. * @param babylonMaterial BabylonJS material
  83604. * @returns List of textures
  83605. */
  83606. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83607. /** Gets a boolean indicating that this extension was used */
  83608. wasUsed: boolean;
  83609. /** Gets a boolean indicating that this extension is required for the file to work */
  83610. required: boolean;
  83611. /**
  83612. * Called after the exporter state changes to EXPORTING
  83613. */
  83614. onExporting?(): void;
  83615. }
  83616. }
  83617. declare module BABYLON.GLTF2.Exporter {
  83618. /**
  83619. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83620. * @hidden
  83621. */
  83622. export class _GLTFMaterialExporter {
  83623. /**
  83624. * Represents the dielectric specular values for R, G and B
  83625. */
  83626. private static readonly _DielectricSpecular;
  83627. /**
  83628. * Allows the maximum specular power to be defined for material calculations
  83629. */
  83630. private static readonly _MaxSpecularPower;
  83631. /**
  83632. * Mapping to store textures
  83633. */
  83634. private _textureMap;
  83635. /**
  83636. * Numeric tolerance value
  83637. */
  83638. private static readonly _Epsilon;
  83639. /**
  83640. * Reference to the glTF Exporter
  83641. */
  83642. private _exporter;
  83643. constructor(exporter: _Exporter);
  83644. /**
  83645. * Specifies if two colors are approximately equal in value
  83646. * @param color1 first color to compare to
  83647. * @param color2 second color to compare to
  83648. * @param epsilon threshold value
  83649. */
  83650. private static FuzzyEquals;
  83651. /**
  83652. * Gets the materials from a Babylon scene and converts them to glTF materials
  83653. * @param scene babylonjs scene
  83654. * @param mimeType texture mime type
  83655. * @param images array of images
  83656. * @param textures array of textures
  83657. * @param materials array of materials
  83658. * @param imageData mapping of texture names to base64 textures
  83659. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83660. */
  83661. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83662. /**
  83663. * Makes a copy of the glTF material without the texture parameters
  83664. * @param originalMaterial original glTF material
  83665. * @returns glTF material without texture parameters
  83666. */
  83667. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83668. /**
  83669. * Specifies if the material has any texture parameters present
  83670. * @param material glTF Material
  83671. * @returns boolean specifying if texture parameters are present
  83672. */
  83673. _hasTexturesPresent(material: IMaterial): boolean;
  83674. /**
  83675. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83676. * @param babylonStandardMaterial
  83677. * @returns glTF Metallic Roughness Material representation
  83678. */
  83679. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83680. /**
  83681. * Computes the metallic factor
  83682. * @param diffuse diffused value
  83683. * @param specular specular value
  83684. * @param oneMinusSpecularStrength one minus the specular strength
  83685. * @returns metallic value
  83686. */
  83687. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83688. /**
  83689. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83690. * @param glTFMaterial glTF material
  83691. * @param babylonMaterial Babylon material
  83692. */
  83693. private static _SetAlphaMode;
  83694. /**
  83695. * Converts a Babylon Standard Material to a glTF Material
  83696. * @param babylonStandardMaterial BJS Standard Material
  83697. * @param mimeType mime type to use for the textures
  83698. * @param images array of glTF image interfaces
  83699. * @param textures array of glTF texture interfaces
  83700. * @param materials array of glTF material interfaces
  83701. * @param imageData map of image file name to data
  83702. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83703. */
  83704. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83705. private _finishMaterial;
  83706. /**
  83707. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83708. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83709. * @param mimeType mime type to use for the textures
  83710. * @param images array of glTF image interfaces
  83711. * @param textures array of glTF texture interfaces
  83712. * @param materials array of glTF material interfaces
  83713. * @param imageData map of image file name to data
  83714. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83715. */
  83716. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83717. /**
  83718. * Converts an image typed array buffer to a base64 image
  83719. * @param buffer typed array buffer
  83720. * @param width width of the image
  83721. * @param height height of the image
  83722. * @param mimeType mimetype of the image
  83723. * @returns base64 image string
  83724. */
  83725. private _createBase64FromCanvasAsync;
  83726. /**
  83727. * Generates a white texture based on the specified width and height
  83728. * @param width width of the texture in pixels
  83729. * @param height height of the texture in pixels
  83730. * @param scene babylonjs scene
  83731. * @returns white texture
  83732. */
  83733. private _createWhiteTexture;
  83734. /**
  83735. * 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
  83736. * @param texture1 first texture to resize
  83737. * @param texture2 second texture to resize
  83738. * @param scene babylonjs scene
  83739. * @returns resized textures or null
  83740. */
  83741. private _resizeTexturesToSameDimensions;
  83742. /**
  83743. * Converts an array of pixels to a Float32Array
  83744. * Throws an error if the pixel format is not supported
  83745. * @param pixels - array buffer containing pixel values
  83746. * @returns Float32 of pixels
  83747. */
  83748. private _convertPixelArrayToFloat32;
  83749. /**
  83750. * Convert Specular Glossiness Textures to Metallic Roughness
  83751. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83752. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83753. * @param diffuseTexture texture used to store diffuse information
  83754. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83755. * @param factors specular glossiness material factors
  83756. * @param mimeType the mime type to use for the texture
  83757. * @returns pbr metallic roughness interface or null
  83758. */
  83759. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83760. /**
  83761. * Converts specular glossiness material properties to metallic roughness
  83762. * @param specularGlossiness interface with specular glossiness material properties
  83763. * @returns interface with metallic roughness material properties
  83764. */
  83765. private _convertSpecularGlossinessToMetallicRoughness;
  83766. /**
  83767. * Calculates the surface reflectance, independent of lighting conditions
  83768. * @param color Color source to calculate brightness from
  83769. * @returns number representing the perceived brightness, or zero if color is undefined
  83770. */
  83771. private _getPerceivedBrightness;
  83772. /**
  83773. * Returns the maximum color component value
  83774. * @param color
  83775. * @returns maximum color component value, or zero if color is null or undefined
  83776. */
  83777. private _getMaxComponent;
  83778. /**
  83779. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83780. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83781. * @param mimeType mime type to use for the textures
  83782. * @param images array of glTF image interfaces
  83783. * @param textures array of glTF texture interfaces
  83784. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83785. * @param imageData map of image file name to data
  83786. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83787. * @returns glTF PBR Metallic Roughness factors
  83788. */
  83789. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83790. private _getGLTFTextureSampler;
  83791. private _getGLTFTextureWrapMode;
  83792. private _getGLTFTextureWrapModesSampler;
  83793. /**
  83794. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83795. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83796. * @param mimeType mime type to use for the textures
  83797. * @param images array of glTF image interfaces
  83798. * @param textures array of glTF texture interfaces
  83799. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83800. * @param imageData map of image file name to data
  83801. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83802. * @returns glTF PBR Metallic Roughness factors
  83803. */
  83804. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83805. /**
  83806. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83807. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83808. * @param mimeType mime type to use for the textures
  83809. * @param images array of glTF image interfaces
  83810. * @param textures array of glTF texture interfaces
  83811. * @param materials array of glTF material interfaces
  83812. * @param imageData map of image file name to data
  83813. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83814. */
  83815. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83816. private setMetallicRoughnessPbrMaterial;
  83817. private getPixelsFromTexture;
  83818. /**
  83819. * Extracts a texture from a Babylon texture into file data and glTF data
  83820. * @param babylonTexture Babylon texture to extract
  83821. * @param mimeType Mime Type of the babylonTexture
  83822. * @return glTF texture info, or null if the texture format is not supported
  83823. */
  83824. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83825. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83826. /**
  83827. * Builds a texture from base64 string
  83828. * @param base64Texture base64 texture string
  83829. * @param baseTextureName Name to use for the texture
  83830. * @param mimeType image mime type for the texture
  83831. * @param images array of images
  83832. * @param textures array of textures
  83833. * @param imageData map of image data
  83834. * @returns glTF texture info, or null if the texture format is not supported
  83835. */
  83836. private _getTextureInfoFromBase64;
  83837. }
  83838. }
  83839. declare module BABYLON {
  83840. /**
  83841. * Class for holding and downloading glTF file data
  83842. */
  83843. export class GLTFData {
  83844. /**
  83845. * Object which contains the file name as the key and its data as the value
  83846. */
  83847. glTFFiles: {
  83848. [fileName: string]: string | Blob;
  83849. };
  83850. /**
  83851. * Initializes the glTF file object
  83852. */
  83853. constructor();
  83854. /**
  83855. * Downloads the glTF data as files based on their names and data
  83856. */
  83857. downloadFiles(): void;
  83858. }
  83859. }
  83860. declare module BABYLON {
  83861. /**
  83862. * Holds a collection of exporter options and parameters
  83863. */
  83864. export interface IExportOptions {
  83865. /**
  83866. * Function which indicates whether a babylon node should be exported or not
  83867. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  83868. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  83869. */
  83870. shouldExportNode?(node: Node): boolean;
  83871. /**
  83872. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  83873. * @param metadata source metadata to read from
  83874. * @returns the data to store to glTF node extras
  83875. */
  83876. metadataSelector?(metadata: any): any;
  83877. /**
  83878. * The sample rate to bake animation curves
  83879. */
  83880. animationSampleRate?: number;
  83881. /**
  83882. * Begin serialization without waiting for the scene to be ready
  83883. */
  83884. exportWithoutWaitingForScene?: boolean;
  83885. /**
  83886. * Indicates if coordinate system swapping root nodes should be included in export
  83887. */
  83888. includeCoordinateSystemConversionNodes?: boolean;
  83889. }
  83890. /**
  83891. * Class for generating glTF data from a Babylon scene.
  83892. */
  83893. export class GLTF2Export {
  83894. /**
  83895. * Exports the geometry of the scene to .gltf file format asynchronously
  83896. * @param scene Babylon scene with scene hierarchy information
  83897. * @param filePrefix File prefix to use when generating the glTF file
  83898. * @param options Exporter options
  83899. * @returns Returns an object with a .gltf file and associates texture names
  83900. * as keys and their data and paths as values
  83901. */
  83902. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83903. private static _PreExportAsync;
  83904. private static _PostExportAsync;
  83905. /**
  83906. * Exports the geometry of the scene to .glb file format asychronously
  83907. * @param scene Babylon scene with scene hierarchy information
  83908. * @param filePrefix File prefix to use when generating glb file
  83909. * @param options Exporter options
  83910. * @returns Returns an object with a .glb filename as key and data as value
  83911. */
  83912. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  83913. }
  83914. }
  83915. declare module BABYLON.GLTF2.Exporter {
  83916. /**
  83917. * @hidden
  83918. */
  83919. export class _GLTFUtilities {
  83920. /**
  83921. * Creates a buffer view based on the supplied arguments
  83922. * @param bufferIndex index value of the specified buffer
  83923. * @param byteOffset byte offset value
  83924. * @param byteLength byte length of the bufferView
  83925. * @param byteStride byte distance between conequential elements
  83926. * @param name name of the buffer view
  83927. * @returns bufferView for glTF
  83928. */
  83929. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  83930. /**
  83931. * Creates an accessor based on the supplied arguments
  83932. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  83933. * @param name The name of the accessor
  83934. * @param type The type of the accessor
  83935. * @param componentType The datatype of components in the attribute
  83936. * @param count The number of attributes referenced by this accessor
  83937. * @param byteOffset The offset relative to the start of the bufferView in bytes
  83938. * @param min Minimum value of each component in this attribute
  83939. * @param max Maximum value of each component in this attribute
  83940. * @returns accessor for glTF
  83941. */
  83942. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  83943. /**
  83944. * Calculates the minimum and maximum values of an array of position floats
  83945. * @param positions Positions array of a mesh
  83946. * @param vertexStart Starting vertex offset to calculate min and max values
  83947. * @param vertexCount Number of vertices to check for min and max values
  83948. * @returns min number array and max number array
  83949. */
  83950. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  83951. min: number[];
  83952. max: number[];
  83953. };
  83954. /**
  83955. * Converts a new right-handed Vector3
  83956. * @param vector vector3 array
  83957. * @returns right-handed Vector3
  83958. */
  83959. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  83960. /**
  83961. * Converts a Vector3 to right-handed
  83962. * @param vector Vector3 to convert to right-handed
  83963. */
  83964. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  83965. /**
  83966. * Converts a three element number array to right-handed
  83967. * @param vector number array to convert to right-handed
  83968. */
  83969. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  83970. /**
  83971. * Converts a new right-handed Vector3
  83972. * @param vector vector3 array
  83973. * @returns right-handed Vector3
  83974. */
  83975. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  83976. /**
  83977. * Converts a Vector3 to right-handed
  83978. * @param vector Vector3 to convert to right-handed
  83979. */
  83980. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  83981. /**
  83982. * Converts a three element number array to right-handed
  83983. * @param vector number array to convert to right-handed
  83984. */
  83985. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  83986. /**
  83987. * Converts a Vector4 to right-handed
  83988. * @param vector Vector4 to convert to right-handed
  83989. */
  83990. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  83991. /**
  83992. * Converts a Vector4 to right-handed
  83993. * @param vector Vector4 to convert to right-handed
  83994. */
  83995. static _GetRightHandedArray4FromRef(vector: number[]): void;
  83996. /**
  83997. * Converts a Quaternion to right-handed
  83998. * @param quaternion Source quaternion to convert to right-handed
  83999. */
  84000. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84001. /**
  84002. * Converts a Quaternion to right-handed
  84003. * @param quaternion Source quaternion to convert to right-handed
  84004. */
  84005. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84006. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84007. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84008. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84009. }
  84010. }
  84011. declare module BABYLON.GLTF2.Exporter {
  84012. /**
  84013. * Converts Babylon Scene into glTF 2.0.
  84014. * @hidden
  84015. */
  84016. export class _Exporter {
  84017. /**
  84018. * Stores the glTF to export
  84019. */
  84020. _glTF: IGLTF;
  84021. /**
  84022. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84023. */
  84024. _bufferViews: IBufferView[];
  84025. /**
  84026. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84027. */
  84028. _accessors: IAccessor[];
  84029. /**
  84030. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84031. */
  84032. _nodes: INode[];
  84033. /**
  84034. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84035. */
  84036. private _scenes;
  84037. /**
  84038. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84039. */
  84040. private _meshes;
  84041. /**
  84042. * Stores all the generated material information, which represents the appearance of each primitive
  84043. */
  84044. _materials: IMaterial[];
  84045. _materialMap: {
  84046. [materialID: number]: number;
  84047. };
  84048. /**
  84049. * Stores all the generated texture information, which is referenced by glTF materials
  84050. */
  84051. _textures: ITexture[];
  84052. /**
  84053. * Stores all the generated image information, which is referenced by glTF textures
  84054. */
  84055. _images: IImage[];
  84056. /**
  84057. * Stores all the texture samplers
  84058. */
  84059. _samplers: ISampler[];
  84060. /**
  84061. * Stores all the generated glTF skins
  84062. */
  84063. _skins: ISkin[];
  84064. /**
  84065. * Stores all the generated animation samplers, which is referenced by glTF animations
  84066. */
  84067. /**
  84068. * Stores the animations for glTF models
  84069. */
  84070. private _animations;
  84071. /**
  84072. * Stores the total amount of bytes stored in the glTF buffer
  84073. */
  84074. private _totalByteLength;
  84075. /**
  84076. * Stores a reference to the Babylon scene containing the source geometry and material information
  84077. */
  84078. _babylonScene: Scene;
  84079. /**
  84080. * Stores a map of the image data, where the key is the file name and the value
  84081. * is the image data
  84082. */
  84083. _imageData: {
  84084. [fileName: string]: {
  84085. data: Uint8Array;
  84086. mimeType: ImageMimeType;
  84087. };
  84088. };
  84089. protected _orderedImageData: Array<{
  84090. data: Uint8Array;
  84091. mimeType: ImageMimeType;
  84092. }>;
  84093. /**
  84094. * Stores a map of the unique id of a node to its index in the node array
  84095. */
  84096. _nodeMap: {
  84097. [key: number]: number;
  84098. };
  84099. /**
  84100. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84101. */
  84102. _convertToRightHandedSystem: boolean;
  84103. /**
  84104. * Specifies if a Babylon node should be converted to right-handed on export
  84105. */
  84106. _convertToRightHandedSystemMap: {
  84107. [nodeId: number]: boolean;
  84108. };
  84109. _includeCoordinateSystemConversionNodes: boolean;
  84110. /**
  84111. * Baked animation sample rate
  84112. */
  84113. private _animationSampleRate;
  84114. private _options;
  84115. private _localEngine;
  84116. _glTFMaterialExporter: _GLTFMaterialExporter;
  84117. private _extensions;
  84118. private static _ExtensionNames;
  84119. private static _ExtensionFactories;
  84120. private _applyExtension;
  84121. private _applyExtensions;
  84122. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84123. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84124. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84125. [key: number]: number;
  84126. }): Promise<Nullable<INode>>;
  84127. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84128. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84129. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84130. private _forEachExtensions;
  84131. private _extensionsOnExporting;
  84132. /**
  84133. * Load glTF serializer extensions
  84134. */
  84135. private _loadExtensions;
  84136. /**
  84137. * Creates a glTF Exporter instance, which can accept optional exporter options
  84138. * @param babylonScene Babylon scene object
  84139. * @param options Options to modify the behavior of the exporter
  84140. */
  84141. constructor(babylonScene: Scene, options?: IExportOptions);
  84142. dispose(): void;
  84143. /**
  84144. * Registers a glTF exporter extension
  84145. * @param name Name of the extension to export
  84146. * @param factory The factory function that creates the exporter extension
  84147. */
  84148. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84149. /**
  84150. * Un-registers an exporter extension
  84151. * @param name The name fo the exporter extension
  84152. * @returns A boolean indicating whether the extension has been un-registered
  84153. */
  84154. static UnregisterExtension(name: string): boolean;
  84155. /**
  84156. * Lazy load a local engine
  84157. */
  84158. _getLocalEngine(): Engine;
  84159. private reorderIndicesBasedOnPrimitiveMode;
  84160. /**
  84161. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84162. * clock-wise during export to glTF
  84163. * @param submesh BabylonJS submesh
  84164. * @param primitiveMode Primitive mode of the mesh
  84165. * @param sideOrientation the winding order of the submesh
  84166. * @param vertexBufferKind The type of vertex attribute
  84167. * @param meshAttributeArray The vertex attribute data
  84168. * @param byteOffset The offset to the binary data
  84169. * @param binaryWriter The binary data for the glTF file
  84170. * @param convertToRightHandedSystem Converts the values to right-handed
  84171. */
  84172. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84173. /**
  84174. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84175. * clock-wise during export to glTF
  84176. * @param submesh BabylonJS submesh
  84177. * @param primitiveMode Primitive mode of the mesh
  84178. * @param sideOrientation the winding order of the submesh
  84179. * @param vertexBufferKind The type of vertex attribute
  84180. * @param meshAttributeArray The vertex attribute data
  84181. * @param byteOffset The offset to the binary data
  84182. * @param binaryWriter The binary data for the glTF file
  84183. * @param convertToRightHandedSystem Converts the values to right-handed
  84184. */
  84185. private reorderTriangleFillMode;
  84186. /**
  84187. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84188. * clock-wise during export to glTF
  84189. * @param submesh BabylonJS submesh
  84190. * @param primitiveMode Primitive mode of the mesh
  84191. * @param sideOrientation the winding order of the submesh
  84192. * @param vertexBufferKind The type of vertex attribute
  84193. * @param meshAttributeArray The vertex attribute data
  84194. * @param byteOffset The offset to the binary data
  84195. * @param binaryWriter The binary data for the glTF file
  84196. * @param convertToRightHandedSystem Converts the values to right-handed
  84197. */
  84198. private reorderTriangleStripDrawMode;
  84199. /**
  84200. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84201. * clock-wise during export to glTF
  84202. * @param submesh BabylonJS submesh
  84203. * @param primitiveMode Primitive mode of the mesh
  84204. * @param sideOrientation the winding order of the submesh
  84205. * @param vertexBufferKind The type of vertex attribute
  84206. * @param meshAttributeArray The vertex attribute data
  84207. * @param byteOffset The offset to the binary data
  84208. * @param binaryWriter The binary data for the glTF file
  84209. * @param convertToRightHandedSystem Converts the values to right-handed
  84210. */
  84211. private reorderTriangleFanMode;
  84212. /**
  84213. * Writes the vertex attribute data to binary
  84214. * @param vertices The vertices to write to the binary writer
  84215. * @param byteOffset The offset into the binary writer to overwrite binary data
  84216. * @param vertexAttributeKind The vertex attribute type
  84217. * @param meshAttributeArray The vertex attribute data
  84218. * @param binaryWriter The writer containing the binary data
  84219. * @param convertToRightHandedSystem Converts the values to right-handed
  84220. */
  84221. private writeVertexAttributeData;
  84222. /**
  84223. * Writes mesh attribute data to a data buffer
  84224. * Returns the bytelength of the data
  84225. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84226. * @param meshAttributeArray Array containing the attribute data
  84227. * @param byteStride Specifies the space between data
  84228. * @param binaryWriter The buffer to write the binary data to
  84229. * @param convertToRightHandedSystem Converts the values to right-handed
  84230. */
  84231. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84232. /**
  84233. * Writes mesh attribute data to a data buffer
  84234. * Returns the bytelength of the data
  84235. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84236. * @param meshAttributeArray Array containing the attribute data
  84237. * @param byteStride Specifies the space between data
  84238. * @param binaryWriter The buffer to write the binary data to
  84239. * @param convertToRightHandedSystem Converts the values to right-handed
  84240. */
  84241. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84242. /**
  84243. * Generates glTF json data
  84244. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84245. * @param glTFPrefix Text to use when prefixing a glTF file
  84246. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84247. * @returns json data as string
  84248. */
  84249. private generateJSON;
  84250. /**
  84251. * Generates data for .gltf and .bin files based on the glTF prefix string
  84252. * @param glTFPrefix Text to use when prefixing a glTF file
  84253. * @param dispose Dispose the exporter
  84254. * @returns GLTFData with glTF file data
  84255. */
  84256. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84257. /**
  84258. * Creates a binary buffer for glTF
  84259. * @returns array buffer for binary data
  84260. */
  84261. private _generateBinaryAsync;
  84262. /**
  84263. * Pads the number to a multiple of 4
  84264. * @param num number to pad
  84265. * @returns padded number
  84266. */
  84267. private _getPadding;
  84268. /**
  84269. * @hidden
  84270. */
  84271. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84272. /**
  84273. * Sets the TRS for each node
  84274. * @param node glTF Node for storing the transformation data
  84275. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84276. * @param convertToRightHandedSystem Converts the values to right-handed
  84277. */
  84278. private setNodeTransformation;
  84279. private getVertexBufferFromMesh;
  84280. /**
  84281. * Creates a bufferview based on the vertices type for the Babylon mesh
  84282. * @param kind Indicates the type of vertices data
  84283. * @param componentType Indicates the numerical type used to store the data
  84284. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84285. * @param binaryWriter The buffer to write the bufferview data to
  84286. * @param convertToRightHandedSystem Converts the values to right-handed
  84287. */
  84288. private createBufferViewKind;
  84289. /**
  84290. * Creates a bufferview based on the vertices type for the Babylon mesh
  84291. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84292. * @param babylonMorphTarget the morph target to be exported
  84293. * @param binaryWriter The buffer to write the bufferview data to
  84294. * @param convertToRightHandedSystem Converts the values to right-handed
  84295. */
  84296. private setMorphTargetAttributes;
  84297. /**
  84298. * The primitive mode of the Babylon mesh
  84299. * @param babylonMesh The BabylonJS mesh
  84300. */
  84301. private getMeshPrimitiveMode;
  84302. /**
  84303. * Sets the primitive mode of the glTF mesh primitive
  84304. * @param meshPrimitive glTF mesh primitive
  84305. * @param primitiveMode The primitive mode
  84306. */
  84307. private setPrimitiveMode;
  84308. /**
  84309. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84310. * @param meshPrimitive glTF mesh primitive
  84311. * @param attributeKind vertex attribute
  84312. * @returns boolean specifying if uv coordinates are present
  84313. */
  84314. private setAttributeKind;
  84315. /**
  84316. * Sets data for the primitive attributes of each submesh
  84317. * @param mesh glTF Mesh object to store the primitive attribute information
  84318. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84319. * @param binaryWriter Buffer to write the attribute data to
  84320. * @param convertToRightHandedSystem Converts the values to right-handed
  84321. */
  84322. private setPrimitiveAttributesAsync;
  84323. /**
  84324. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84325. * @param node The node to check
  84326. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84327. */
  84328. private isBabylonCoordinateSystemConvertingNode;
  84329. /**
  84330. * Creates a glTF scene based on the array of meshes
  84331. * Returns the the total byte offset
  84332. * @param babylonScene Babylon scene to get the mesh data from
  84333. * @param binaryWriter Buffer to write binary data to
  84334. */
  84335. private createSceneAsync;
  84336. /**
  84337. * Creates a mapping of Node unique id to node index and handles animations
  84338. * @param babylonScene Babylon Scene
  84339. * @param nodes Babylon transform nodes
  84340. * @param binaryWriter Buffer to write binary data to
  84341. * @returns Node mapping of unique id to index
  84342. */
  84343. private createNodeMapAndAnimationsAsync;
  84344. /**
  84345. * Creates a glTF node from a Babylon mesh
  84346. * @param babylonMesh Source Babylon mesh
  84347. * @param binaryWriter Buffer for storing geometry data
  84348. * @param convertToRightHandedSystem Converts the values to right-handed
  84349. * @param nodeMap Node mapping of unique id to glTF node index
  84350. * @returns glTF node
  84351. */
  84352. private createNodeAsync;
  84353. /**
  84354. * Creates a glTF skin from a Babylon skeleton
  84355. * @param babylonScene Babylon Scene
  84356. * @param nodes Babylon transform nodes
  84357. * @param binaryWriter Buffer to write binary data to
  84358. * @returns Node mapping of unique id to index
  84359. */
  84360. private createSkinsAsync;
  84361. }
  84362. /**
  84363. * @hidden
  84364. *
  84365. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84366. */
  84367. export class _BinaryWriter {
  84368. /**
  84369. * Array buffer which stores all binary data
  84370. */
  84371. private _arrayBuffer;
  84372. /**
  84373. * View of the array buffer
  84374. */
  84375. private _dataView;
  84376. /**
  84377. * byte offset of data in array buffer
  84378. */
  84379. private _byteOffset;
  84380. /**
  84381. * Initialize binary writer with an initial byte length
  84382. * @param byteLength Initial byte length of the array buffer
  84383. */
  84384. constructor(byteLength: number);
  84385. /**
  84386. * Resize the array buffer to the specified byte length
  84387. * @param byteLength
  84388. */
  84389. private resizeBuffer;
  84390. /**
  84391. * Get an array buffer with the length of the byte offset
  84392. * @returns ArrayBuffer resized to the byte offset
  84393. */
  84394. getArrayBuffer(): ArrayBuffer;
  84395. /**
  84396. * Get the byte offset of the array buffer
  84397. * @returns byte offset
  84398. */
  84399. getByteOffset(): number;
  84400. /**
  84401. * Stores an UInt8 in the array buffer
  84402. * @param entry
  84403. * @param byteOffset If defined, specifies where to set the value as an offset.
  84404. */
  84405. setUInt8(entry: number, byteOffset?: number): void;
  84406. /**
  84407. * Stores an UInt16 in the array buffer
  84408. * @param entry
  84409. * @param byteOffset If defined, specifies where to set the value as an offset.
  84410. */
  84411. setUInt16(entry: number, byteOffset?: number): void;
  84412. /**
  84413. * Gets an UInt32 in the array buffer
  84414. * @param entry
  84415. * @param byteOffset If defined, specifies where to set the value as an offset.
  84416. */
  84417. getUInt32(byteOffset: number): number;
  84418. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84419. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84420. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84421. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84422. /**
  84423. * Stores a Float32 in the array buffer
  84424. * @param entry
  84425. */
  84426. setFloat32(entry: number, byteOffset?: number): void;
  84427. /**
  84428. * Stores an UInt32 in the array buffer
  84429. * @param entry
  84430. * @param byteOffset If defined, specifies where to set the value as an offset.
  84431. */
  84432. setUInt32(entry: number, byteOffset?: number): void;
  84433. }
  84434. }
  84435. declare module BABYLON.GLTF2.Exporter {
  84436. /**
  84437. * @hidden
  84438. * Interface to store animation data.
  84439. */
  84440. export interface _IAnimationData {
  84441. /**
  84442. * Keyframe data.
  84443. */
  84444. inputs: number[];
  84445. /**
  84446. * Value data.
  84447. */
  84448. outputs: number[][];
  84449. /**
  84450. * Animation interpolation data.
  84451. */
  84452. samplerInterpolation: AnimationSamplerInterpolation;
  84453. /**
  84454. * Minimum keyframe value.
  84455. */
  84456. inputsMin: number;
  84457. /**
  84458. * Maximum keyframe value.
  84459. */
  84460. inputsMax: number;
  84461. }
  84462. /**
  84463. * @hidden
  84464. */
  84465. export interface _IAnimationInfo {
  84466. /**
  84467. * The target channel for the animation
  84468. */
  84469. animationChannelTargetPath: AnimationChannelTargetPath;
  84470. /**
  84471. * The glTF accessor type for the data.
  84472. */
  84473. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84474. /**
  84475. * Specifies if quaternions should be used.
  84476. */
  84477. useQuaternion: boolean;
  84478. }
  84479. /**
  84480. * @hidden
  84481. * Utility class for generating glTF animation data from BabylonJS.
  84482. */
  84483. export class _GLTFAnimation {
  84484. /**
  84485. * @ignore
  84486. *
  84487. * Creates glTF channel animation from BabylonJS animation.
  84488. * @param babylonTransformNode - BabylonJS mesh.
  84489. * @param animation - animation.
  84490. * @param animationChannelTargetPath - The target animation channel.
  84491. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84492. * @param useQuaternion - Specifies if quaternions are used.
  84493. * @returns nullable IAnimationData
  84494. */
  84495. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84496. private static _DeduceAnimationInfo;
  84497. /**
  84498. * @ignore
  84499. * Create node animations from the transform node animations
  84500. * @param babylonNode
  84501. * @param runtimeGLTFAnimation
  84502. * @param idleGLTFAnimations
  84503. * @param nodeMap
  84504. * @param nodes
  84505. * @param binaryWriter
  84506. * @param bufferViews
  84507. * @param accessors
  84508. * @param convertToRightHandedSystem
  84509. * @param animationSampleRate
  84510. */
  84511. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84512. [key: number]: number;
  84513. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84514. /**
  84515. * @ignore
  84516. * Create individual morph animations from the mesh's morph target animation tracks
  84517. * @param babylonNode
  84518. * @param runtimeGLTFAnimation
  84519. * @param idleGLTFAnimations
  84520. * @param nodeMap
  84521. * @param nodes
  84522. * @param binaryWriter
  84523. * @param bufferViews
  84524. * @param accessors
  84525. * @param convertToRightHandedSystem
  84526. * @param animationSampleRate
  84527. */
  84528. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84529. [key: number]: number;
  84530. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84531. /**
  84532. * @ignore
  84533. * Create node and morph animations from the animation groups
  84534. * @param babylonScene
  84535. * @param glTFAnimations
  84536. * @param nodeMap
  84537. * @param nodes
  84538. * @param binaryWriter
  84539. * @param bufferViews
  84540. * @param accessors
  84541. * @param convertToRightHandedSystemMap
  84542. * @param animationSampleRate
  84543. */
  84544. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84545. [key: number]: number;
  84546. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84547. [nodeId: number]: boolean;
  84548. }, animationSampleRate: number): void;
  84549. private static AddAnimation;
  84550. /**
  84551. * Create a baked animation
  84552. * @param babylonTransformNode BabylonJS mesh
  84553. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84554. * @param animationChannelTargetPath animation target channel
  84555. * @param minFrame minimum animation frame
  84556. * @param maxFrame maximum animation frame
  84557. * @param fps frames per second of the animation
  84558. * @param inputs input key frames of the animation
  84559. * @param outputs output key frame data of the animation
  84560. * @param convertToRightHandedSystem converts the values to right-handed
  84561. * @param useQuaternion specifies if quaternions should be used
  84562. */
  84563. private static _CreateBakedAnimation;
  84564. private static _ConvertFactorToVector3OrQuaternion;
  84565. private static _SetInterpolatedValue;
  84566. /**
  84567. * Creates linear animation from the animation key frames
  84568. * @param babylonTransformNode BabylonJS mesh
  84569. * @param animation BabylonJS animation
  84570. * @param animationChannelTargetPath The target animation channel
  84571. * @param frameDelta The difference between the last and first frame of the animation
  84572. * @param inputs Array to store the key frame times
  84573. * @param outputs Array to store the key frame data
  84574. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84575. * @param useQuaternion Specifies if quaternions are used in the animation
  84576. */
  84577. private static _CreateLinearOrStepAnimation;
  84578. /**
  84579. * Creates cubic spline animation from the animation key frames
  84580. * @param babylonTransformNode BabylonJS mesh
  84581. * @param animation BabylonJS animation
  84582. * @param animationChannelTargetPath The target animation channel
  84583. * @param frameDelta The difference between the last and first frame of the animation
  84584. * @param inputs Array to store the key frame times
  84585. * @param outputs Array to store the key frame data
  84586. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84587. * @param useQuaternion Specifies if quaternions are used in the animation
  84588. */
  84589. private static _CreateCubicSplineAnimation;
  84590. private static _GetBasePositionRotationOrScale;
  84591. /**
  84592. * Adds a key frame value
  84593. * @param keyFrame
  84594. * @param animation
  84595. * @param outputs
  84596. * @param animationChannelTargetPath
  84597. * @param basePositionRotationOrScale
  84598. * @param convertToRightHandedSystem
  84599. * @param useQuaternion
  84600. */
  84601. private static _AddKeyframeValue;
  84602. /**
  84603. * Determine the interpolation based on the key frames
  84604. * @param keyFrames
  84605. * @param animationChannelTargetPath
  84606. * @param useQuaternion
  84607. */
  84608. private static _DeduceInterpolation;
  84609. /**
  84610. * Adds an input tangent or output tangent to the output data
  84611. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84612. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84613. * @param outputs The animation data by keyframe
  84614. * @param animationChannelTargetPath The target animation channel
  84615. * @param interpolation The interpolation type
  84616. * @param keyFrame The key frame with the animation data
  84617. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84618. * @param useQuaternion Specifies if quaternions are used
  84619. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84620. */
  84621. private static AddSplineTangent;
  84622. /**
  84623. * Get the minimum and maximum key frames' frame values
  84624. * @param keyFrames animation key frames
  84625. * @returns the minimum and maximum key frame value
  84626. */
  84627. private static calculateMinMaxKeyFrames;
  84628. }
  84629. }
  84630. declare module BABYLON.GLTF2.Exporter {
  84631. /** @hidden */
  84632. export var textureTransformPixelShader: {
  84633. name: string;
  84634. shader: string;
  84635. };
  84636. }
  84637. declare module BABYLON.GLTF2.Exporter.Extensions {
  84638. /**
  84639. * @hidden
  84640. */
  84641. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84642. private _recordedTextures;
  84643. /** Name of this extension */
  84644. readonly name: string;
  84645. /** Defines whether this extension is enabled */
  84646. enabled: boolean;
  84647. /** Defines whether this extension is required */
  84648. required: boolean;
  84649. /** Reference to the glTF exporter */
  84650. private _wasUsed;
  84651. constructor(exporter: _Exporter);
  84652. dispose(): void;
  84653. /** @hidden */
  84654. get wasUsed(): boolean;
  84655. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84656. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84657. /**
  84658. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84659. * @param babylonTexture
  84660. * @param offset
  84661. * @param rotation
  84662. * @param scale
  84663. * @param scene
  84664. */
  84665. private _textureTransformTextureAsync;
  84666. }
  84667. }
  84668. declare module BABYLON.GLTF2.Exporter.Extensions {
  84669. /**
  84670. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84671. */
  84672. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84673. /** The name of this extension. */
  84674. readonly name: string;
  84675. /** Defines whether this extension is enabled. */
  84676. enabled: boolean;
  84677. /** Defines whether this extension is required */
  84678. required: boolean;
  84679. /** Reference to the glTF exporter */
  84680. private _exporter;
  84681. private _lights;
  84682. /** @hidden */
  84683. constructor(exporter: _Exporter);
  84684. /** @hidden */
  84685. dispose(): void;
  84686. /** @hidden */
  84687. get wasUsed(): boolean;
  84688. /** @hidden */
  84689. onExporting(): void;
  84690. /**
  84691. * Define this method to modify the default behavior when exporting a node
  84692. * @param context The context when exporting the node
  84693. * @param node glTF node
  84694. * @param babylonNode BabylonJS node
  84695. * @param nodeMap Node mapping of unique id to glTF node index
  84696. * @returns nullable INode promise
  84697. */
  84698. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84699. [key: number]: number;
  84700. }): Promise<Nullable<INode>>;
  84701. }
  84702. }
  84703. declare module BABYLON.GLTF2.Exporter.Extensions {
  84704. /**
  84705. * @hidden
  84706. */
  84707. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84708. /** Name of this extension */
  84709. readonly name: string;
  84710. /** Defines whether this extension is enabled */
  84711. enabled: boolean;
  84712. /** Defines whether this extension is required */
  84713. required: boolean;
  84714. /** Reference to the glTF exporter */
  84715. private _textureInfos;
  84716. private _exportedTextures;
  84717. private _wasUsed;
  84718. constructor(exporter: _Exporter);
  84719. dispose(): void;
  84720. /** @hidden */
  84721. get wasUsed(): boolean;
  84722. private _getTextureIndex;
  84723. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84724. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84725. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84726. }
  84727. }
  84728. declare module BABYLON.GLTF2.Exporter.Extensions {
  84729. /**
  84730. * @hidden
  84731. */
  84732. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84733. /** Name of this extension */
  84734. readonly name: string;
  84735. /** Defines whether this extension is enabled */
  84736. enabled: boolean;
  84737. /** Defines whether this extension is required */
  84738. required: boolean;
  84739. private _wasUsed;
  84740. constructor(exporter: _Exporter);
  84741. /** @hidden */
  84742. get wasUsed(): boolean;
  84743. dispose(): void;
  84744. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84745. }
  84746. }
  84747. declare module BABYLON {
  84748. /**
  84749. * Class for generating STL data from a Babylon scene.
  84750. */
  84751. export class STLExport {
  84752. /**
  84753. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84754. * @param meshes list defines the mesh to serialize
  84755. * @param download triggers the automatic download of the file.
  84756. * @param fileName changes the downloads fileName.
  84757. * @param binary changes the STL to a binary type.
  84758. * @param isLittleEndian toggle for binary type exporter.
  84759. * @returns the STL as UTF8 string
  84760. */
  84761. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84762. }
  84763. }
  84764. declare module "babylonjs-gltf2interface" {
  84765. export = BABYLON.GLTF2;
  84766. }
  84767. /**
  84768. * Module for glTF 2.0 Interface
  84769. */
  84770. declare module BABYLON.GLTF2 {
  84771. /**
  84772. * The datatype of the components in the attribute
  84773. */
  84774. const enum AccessorComponentType {
  84775. /**
  84776. * Byte
  84777. */
  84778. BYTE = 5120,
  84779. /**
  84780. * Unsigned Byte
  84781. */
  84782. UNSIGNED_BYTE = 5121,
  84783. /**
  84784. * Short
  84785. */
  84786. SHORT = 5122,
  84787. /**
  84788. * Unsigned Short
  84789. */
  84790. UNSIGNED_SHORT = 5123,
  84791. /**
  84792. * Unsigned Int
  84793. */
  84794. UNSIGNED_INT = 5125,
  84795. /**
  84796. * Float
  84797. */
  84798. FLOAT = 5126,
  84799. }
  84800. /**
  84801. * Specifies if the attirbute is a scalar, vector, or matrix
  84802. */
  84803. const enum AccessorType {
  84804. /**
  84805. * Scalar
  84806. */
  84807. SCALAR = "SCALAR",
  84808. /**
  84809. * Vector2
  84810. */
  84811. VEC2 = "VEC2",
  84812. /**
  84813. * Vector3
  84814. */
  84815. VEC3 = "VEC3",
  84816. /**
  84817. * Vector4
  84818. */
  84819. VEC4 = "VEC4",
  84820. /**
  84821. * Matrix2x2
  84822. */
  84823. MAT2 = "MAT2",
  84824. /**
  84825. * Matrix3x3
  84826. */
  84827. MAT3 = "MAT3",
  84828. /**
  84829. * Matrix4x4
  84830. */
  84831. MAT4 = "MAT4",
  84832. }
  84833. /**
  84834. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84835. */
  84836. const enum AnimationChannelTargetPath {
  84837. /**
  84838. * Translation
  84839. */
  84840. TRANSLATION = "translation",
  84841. /**
  84842. * Rotation
  84843. */
  84844. ROTATION = "rotation",
  84845. /**
  84846. * Scale
  84847. */
  84848. SCALE = "scale",
  84849. /**
  84850. * Weights
  84851. */
  84852. WEIGHTS = "weights",
  84853. }
  84854. /**
  84855. * Interpolation algorithm
  84856. */
  84857. const enum AnimationSamplerInterpolation {
  84858. /**
  84859. * The animated values are linearly interpolated between keyframes
  84860. */
  84861. LINEAR = "LINEAR",
  84862. /**
  84863. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  84864. */
  84865. STEP = "STEP",
  84866. /**
  84867. * The animation's interpolation is computed using a cubic spline with specified tangents
  84868. */
  84869. CUBICSPLINE = "CUBICSPLINE",
  84870. }
  84871. /**
  84872. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  84873. */
  84874. const enum CameraType {
  84875. /**
  84876. * A perspective camera containing properties to create a perspective projection matrix
  84877. */
  84878. PERSPECTIVE = "perspective",
  84879. /**
  84880. * An orthographic camera containing properties to create an orthographic projection matrix
  84881. */
  84882. ORTHOGRAPHIC = "orthographic",
  84883. }
  84884. /**
  84885. * The mime-type of the image
  84886. */
  84887. const enum ImageMimeType {
  84888. /**
  84889. * JPEG Mime-type
  84890. */
  84891. JPEG = "image/jpeg",
  84892. /**
  84893. * PNG Mime-type
  84894. */
  84895. PNG = "image/png",
  84896. }
  84897. /**
  84898. * The alpha rendering mode of the material
  84899. */
  84900. const enum MaterialAlphaMode {
  84901. /**
  84902. * The alpha value is ignored and the rendered output is fully opaque
  84903. */
  84904. OPAQUE = "OPAQUE",
  84905. /**
  84906. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  84907. */
  84908. MASK = "MASK",
  84909. /**
  84910. * 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)
  84911. */
  84912. BLEND = "BLEND",
  84913. }
  84914. /**
  84915. * The type of the primitives to render
  84916. */
  84917. const enum MeshPrimitiveMode {
  84918. /**
  84919. * Points
  84920. */
  84921. POINTS = 0,
  84922. /**
  84923. * Lines
  84924. */
  84925. LINES = 1,
  84926. /**
  84927. * Line Loop
  84928. */
  84929. LINE_LOOP = 2,
  84930. /**
  84931. * Line Strip
  84932. */
  84933. LINE_STRIP = 3,
  84934. /**
  84935. * Triangles
  84936. */
  84937. TRIANGLES = 4,
  84938. /**
  84939. * Triangle Strip
  84940. */
  84941. TRIANGLE_STRIP = 5,
  84942. /**
  84943. * Triangle Fan
  84944. */
  84945. TRIANGLE_FAN = 6,
  84946. }
  84947. /**
  84948. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  84949. */
  84950. const enum TextureMagFilter {
  84951. /**
  84952. * Nearest
  84953. */
  84954. NEAREST = 9728,
  84955. /**
  84956. * Linear
  84957. */
  84958. LINEAR = 9729,
  84959. }
  84960. /**
  84961. * Minification filter. All valid values correspond to WebGL enums
  84962. */
  84963. const enum TextureMinFilter {
  84964. /**
  84965. * Nearest
  84966. */
  84967. NEAREST = 9728,
  84968. /**
  84969. * Linear
  84970. */
  84971. LINEAR = 9729,
  84972. /**
  84973. * Nearest Mip-Map Nearest
  84974. */
  84975. NEAREST_MIPMAP_NEAREST = 9984,
  84976. /**
  84977. * Linear Mipmap Nearest
  84978. */
  84979. LINEAR_MIPMAP_NEAREST = 9985,
  84980. /**
  84981. * Nearest Mipmap Linear
  84982. */
  84983. NEAREST_MIPMAP_LINEAR = 9986,
  84984. /**
  84985. * Linear Mipmap Linear
  84986. */
  84987. LINEAR_MIPMAP_LINEAR = 9987,
  84988. }
  84989. /**
  84990. * S (U) wrapping mode. All valid values correspond to WebGL enums
  84991. */
  84992. const enum TextureWrapMode {
  84993. /**
  84994. * Clamp to Edge
  84995. */
  84996. CLAMP_TO_EDGE = 33071,
  84997. /**
  84998. * Mirrored Repeat
  84999. */
  85000. MIRRORED_REPEAT = 33648,
  85001. /**
  85002. * Repeat
  85003. */
  85004. REPEAT = 10497,
  85005. }
  85006. /**
  85007. * glTF Property
  85008. */
  85009. interface IProperty {
  85010. /**
  85011. * Dictionary object with extension-specific objects
  85012. */
  85013. extensions?: {
  85014. [key: string]: any;
  85015. };
  85016. /**
  85017. * Application-Specific data
  85018. */
  85019. extras?: any;
  85020. }
  85021. /**
  85022. * glTF Child of Root Property
  85023. */
  85024. interface IChildRootProperty extends IProperty {
  85025. /**
  85026. * The user-defined name of this object
  85027. */
  85028. name?: string;
  85029. }
  85030. /**
  85031. * Indices of those attributes that deviate from their initialization value
  85032. */
  85033. interface IAccessorSparseIndices extends IProperty {
  85034. /**
  85035. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85036. */
  85037. bufferView: number;
  85038. /**
  85039. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85040. */
  85041. byteOffset?: number;
  85042. /**
  85043. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85044. */
  85045. componentType: AccessorComponentType;
  85046. }
  85047. /**
  85048. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85049. */
  85050. interface IAccessorSparseValues extends IProperty {
  85051. /**
  85052. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85053. */
  85054. bufferView: number;
  85055. /**
  85056. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85057. */
  85058. byteOffset?: number;
  85059. }
  85060. /**
  85061. * Sparse storage of attributes that deviate from their initialization value
  85062. */
  85063. interface IAccessorSparse extends IProperty {
  85064. /**
  85065. * The number of attributes encoded in this sparse accessor
  85066. */
  85067. count: number;
  85068. /**
  85069. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85070. */
  85071. indices: IAccessorSparseIndices;
  85072. /**
  85073. * 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
  85074. */
  85075. values: IAccessorSparseValues;
  85076. }
  85077. /**
  85078. * 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
  85079. */
  85080. interface IAccessor extends IChildRootProperty {
  85081. /**
  85082. * The index of the bufferview
  85083. */
  85084. bufferView?: number;
  85085. /**
  85086. * The offset relative to the start of the bufferView in bytes
  85087. */
  85088. byteOffset?: number;
  85089. /**
  85090. * The datatype of components in the attribute
  85091. */
  85092. componentType: AccessorComponentType;
  85093. /**
  85094. * Specifies whether integer data values should be normalized
  85095. */
  85096. normalized?: boolean;
  85097. /**
  85098. * The number of attributes referenced by this accessor
  85099. */
  85100. count: number;
  85101. /**
  85102. * Specifies if the attribute is a scalar, vector, or matrix
  85103. */
  85104. type: AccessorType;
  85105. /**
  85106. * Maximum value of each component in this attribute
  85107. */
  85108. max?: number[];
  85109. /**
  85110. * Minimum value of each component in this attribute
  85111. */
  85112. min?: number[];
  85113. /**
  85114. * Sparse storage of attributes that deviate from their initialization value
  85115. */
  85116. sparse?: IAccessorSparse;
  85117. }
  85118. /**
  85119. * Targets an animation's sampler at a node's property
  85120. */
  85121. interface IAnimationChannel extends IProperty {
  85122. /**
  85123. * The index of a sampler in this animation used to compute the value for the target
  85124. */
  85125. sampler: number;
  85126. /**
  85127. * The index of the node and TRS property to target
  85128. */
  85129. target: IAnimationChannelTarget;
  85130. }
  85131. /**
  85132. * The index of the node and TRS property that an animation channel targets
  85133. */
  85134. interface IAnimationChannelTarget extends IProperty {
  85135. /**
  85136. * The index of the node to target
  85137. */
  85138. node: number;
  85139. /**
  85140. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85141. */
  85142. path: AnimationChannelTargetPath;
  85143. }
  85144. /**
  85145. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85146. */
  85147. interface IAnimationSampler extends IProperty {
  85148. /**
  85149. * The index of an accessor containing keyframe input values, e.g., time
  85150. */
  85151. input: number;
  85152. /**
  85153. * Interpolation algorithm
  85154. */
  85155. interpolation?: AnimationSamplerInterpolation;
  85156. /**
  85157. * The index of an accessor, containing keyframe output values
  85158. */
  85159. output: number;
  85160. }
  85161. /**
  85162. * A keyframe animation
  85163. */
  85164. interface IAnimation extends IChildRootProperty {
  85165. /**
  85166. * An array of channels, each of which targets an animation's sampler at a node's property
  85167. */
  85168. channels: IAnimationChannel[];
  85169. /**
  85170. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85171. */
  85172. samplers: IAnimationSampler[];
  85173. }
  85174. /**
  85175. * Metadata about the glTF asset
  85176. */
  85177. interface IAsset extends IChildRootProperty {
  85178. /**
  85179. * A copyright message suitable for display to credit the content creator
  85180. */
  85181. copyright?: string;
  85182. /**
  85183. * Tool that generated this glTF model. Useful for debugging
  85184. */
  85185. generator?: string;
  85186. /**
  85187. * The glTF version that this asset targets
  85188. */
  85189. version: string;
  85190. /**
  85191. * The minimum glTF version that this asset targets
  85192. */
  85193. minVersion?: string;
  85194. }
  85195. /**
  85196. * A buffer points to binary geometry, animation, or skins
  85197. */
  85198. interface IBuffer extends IChildRootProperty {
  85199. /**
  85200. * 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
  85201. */
  85202. uri?: string;
  85203. /**
  85204. * The length of the buffer in bytes
  85205. */
  85206. byteLength: number;
  85207. }
  85208. /**
  85209. * A view into a buffer generally representing a subset of the buffer
  85210. */
  85211. interface IBufferView extends IChildRootProperty {
  85212. /**
  85213. * The index of the buffer
  85214. */
  85215. buffer: number;
  85216. /**
  85217. * The offset into the buffer in bytes
  85218. */
  85219. byteOffset?: number;
  85220. /**
  85221. * The lenth of the bufferView in bytes
  85222. */
  85223. byteLength: number;
  85224. /**
  85225. * The stride, in bytes
  85226. */
  85227. byteStride?: number;
  85228. }
  85229. /**
  85230. * An orthographic camera containing properties to create an orthographic projection matrix
  85231. */
  85232. interface ICameraOrthographic extends IProperty {
  85233. /**
  85234. * The floating-point horizontal magnification of the view. Must not be zero
  85235. */
  85236. xmag: number;
  85237. /**
  85238. * The floating-point vertical magnification of the view. Must not be zero
  85239. */
  85240. ymag: number;
  85241. /**
  85242. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85243. */
  85244. zfar: number;
  85245. /**
  85246. * The floating-point distance to the near clipping plane
  85247. */
  85248. znear: number;
  85249. }
  85250. /**
  85251. * A perspective camera containing properties to create a perspective projection matrix
  85252. */
  85253. interface ICameraPerspective extends IProperty {
  85254. /**
  85255. * The floating-point aspect ratio of the field of view
  85256. */
  85257. aspectRatio?: number;
  85258. /**
  85259. * The floating-point vertical field of view in radians
  85260. */
  85261. yfov: number;
  85262. /**
  85263. * The floating-point distance to the far clipping plane
  85264. */
  85265. zfar?: number;
  85266. /**
  85267. * The floating-point distance to the near clipping plane
  85268. */
  85269. znear: number;
  85270. }
  85271. /**
  85272. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85273. */
  85274. interface ICamera extends IChildRootProperty {
  85275. /**
  85276. * An orthographic camera containing properties to create an orthographic projection matrix
  85277. */
  85278. orthographic?: ICameraOrthographic;
  85279. /**
  85280. * A perspective camera containing properties to create a perspective projection matrix
  85281. */
  85282. perspective?: ICameraPerspective;
  85283. /**
  85284. * Specifies if the camera uses a perspective or orthographic projection
  85285. */
  85286. type: CameraType;
  85287. }
  85288. /**
  85289. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85290. */
  85291. interface IImage extends IChildRootProperty {
  85292. /**
  85293. * 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
  85294. */
  85295. uri?: string;
  85296. /**
  85297. * The image's MIME type
  85298. */
  85299. mimeType?: ImageMimeType;
  85300. /**
  85301. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85302. */
  85303. bufferView?: number;
  85304. }
  85305. /**
  85306. * Material Normal Texture Info
  85307. */
  85308. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85309. /**
  85310. * The scalar multiplier applied to each normal vector of the normal texture
  85311. */
  85312. scale?: number;
  85313. }
  85314. /**
  85315. * Material Occlusion Texture Info
  85316. */
  85317. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85318. /**
  85319. * A scalar multiplier controlling the amount of occlusion applied
  85320. */
  85321. strength?: number;
  85322. }
  85323. /**
  85324. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85325. */
  85326. interface IMaterialPbrMetallicRoughness {
  85327. /**
  85328. * The material's base color factor
  85329. */
  85330. baseColorFactor?: number[];
  85331. /**
  85332. * The base color texture
  85333. */
  85334. baseColorTexture?: ITextureInfo;
  85335. /**
  85336. * The metalness of the material
  85337. */
  85338. metallicFactor?: number;
  85339. /**
  85340. * The roughness of the material
  85341. */
  85342. roughnessFactor?: number;
  85343. /**
  85344. * The metallic-roughness texture
  85345. */
  85346. metallicRoughnessTexture?: ITextureInfo;
  85347. }
  85348. /**
  85349. * The material appearance of a primitive
  85350. */
  85351. interface IMaterial extends IChildRootProperty {
  85352. /**
  85353. * 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
  85354. */
  85355. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85356. /**
  85357. * The normal map texture
  85358. */
  85359. normalTexture?: IMaterialNormalTextureInfo;
  85360. /**
  85361. * The occlusion map texture
  85362. */
  85363. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85364. /**
  85365. * The emissive map texture
  85366. */
  85367. emissiveTexture?: ITextureInfo;
  85368. /**
  85369. * 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
  85370. */
  85371. emissiveFactor?: number[];
  85372. /**
  85373. * The alpha rendering mode of the material
  85374. */
  85375. alphaMode?: MaterialAlphaMode;
  85376. /**
  85377. * The alpha cutoff value of the material
  85378. */
  85379. alphaCutoff?: number;
  85380. /**
  85381. * Specifies whether the material is double sided
  85382. */
  85383. doubleSided?: boolean;
  85384. }
  85385. /**
  85386. * Geometry to be rendered with the given material
  85387. */
  85388. interface IMeshPrimitive extends IProperty {
  85389. /**
  85390. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85391. */
  85392. attributes: {
  85393. [name: string]: number;
  85394. };
  85395. /**
  85396. * The index of the accessor that contains the indices
  85397. */
  85398. indices?: number;
  85399. /**
  85400. * The index of the material to apply to this primitive when rendering
  85401. */
  85402. material?: number;
  85403. /**
  85404. * The type of primitives to render. All valid values correspond to WebGL enums
  85405. */
  85406. mode?: MeshPrimitiveMode;
  85407. /**
  85408. * 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
  85409. */
  85410. targets?: {
  85411. [name: string]: number;
  85412. }[];
  85413. }
  85414. /**
  85415. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85416. */
  85417. interface IMesh extends IChildRootProperty {
  85418. /**
  85419. * An array of primitives, each defining geometry to be rendered with a material
  85420. */
  85421. primitives: IMeshPrimitive[];
  85422. /**
  85423. * Array of weights to be applied to the Morph Targets
  85424. */
  85425. weights?: number[];
  85426. }
  85427. /**
  85428. * A node in the node hierarchy
  85429. */
  85430. interface INode extends IChildRootProperty {
  85431. /**
  85432. * The index of the camera referenced by this node
  85433. */
  85434. camera?: number;
  85435. /**
  85436. * The indices of this node's children
  85437. */
  85438. children?: number[];
  85439. /**
  85440. * The index of the skin referenced by this node
  85441. */
  85442. skin?: number;
  85443. /**
  85444. * A floating-point 4x4 transformation matrix stored in column-major order
  85445. */
  85446. matrix?: number[];
  85447. /**
  85448. * The index of the mesh in this node
  85449. */
  85450. mesh?: number;
  85451. /**
  85452. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85453. */
  85454. rotation?: number[];
  85455. /**
  85456. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85457. */
  85458. scale?: number[];
  85459. /**
  85460. * The node's translation along the x, y, and z axes
  85461. */
  85462. translation?: number[];
  85463. /**
  85464. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85465. */
  85466. weights?: number[];
  85467. }
  85468. /**
  85469. * Texture sampler properties for filtering and wrapping modes
  85470. */
  85471. interface ISampler extends IChildRootProperty {
  85472. /**
  85473. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85474. */
  85475. magFilter?: TextureMagFilter;
  85476. /**
  85477. * Minification filter. All valid values correspond to WebGL enums
  85478. */
  85479. minFilter?: TextureMinFilter;
  85480. /**
  85481. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85482. */
  85483. wrapS?: TextureWrapMode;
  85484. /**
  85485. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85486. */
  85487. wrapT?: TextureWrapMode;
  85488. }
  85489. /**
  85490. * The root nodes of a scene
  85491. */
  85492. interface IScene extends IChildRootProperty {
  85493. /**
  85494. * The indices of each root node
  85495. */
  85496. nodes: number[];
  85497. }
  85498. /**
  85499. * Joints and matrices defining a skin
  85500. */
  85501. interface ISkin extends IChildRootProperty {
  85502. /**
  85503. * 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
  85504. */
  85505. inverseBindMatrices?: number;
  85506. /**
  85507. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85508. */
  85509. skeleton?: number;
  85510. /**
  85511. * 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)
  85512. */
  85513. joints: number[];
  85514. }
  85515. /**
  85516. * A texture and its sampler
  85517. */
  85518. interface ITexture extends IChildRootProperty {
  85519. /**
  85520. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85521. */
  85522. sampler?: number;
  85523. /**
  85524. * The index of the image used by this texture
  85525. */
  85526. source: number;
  85527. }
  85528. /**
  85529. * Reference to a texture
  85530. */
  85531. interface ITextureInfo extends IProperty {
  85532. /**
  85533. * The index of the texture
  85534. */
  85535. index: number;
  85536. /**
  85537. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85538. */
  85539. texCoord?: number;
  85540. }
  85541. /**
  85542. * The root object for a glTF asset
  85543. */
  85544. interface IGLTF extends IProperty {
  85545. /**
  85546. * An array of accessors. An accessor is a typed view into a bufferView
  85547. */
  85548. accessors?: IAccessor[];
  85549. /**
  85550. * An array of keyframe animations
  85551. */
  85552. animations?: IAnimation[];
  85553. /**
  85554. * Metadata about the glTF asset
  85555. */
  85556. asset: IAsset;
  85557. /**
  85558. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85559. */
  85560. buffers?: IBuffer[];
  85561. /**
  85562. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85563. */
  85564. bufferViews?: IBufferView[];
  85565. /**
  85566. * An array of cameras
  85567. */
  85568. cameras?: ICamera[];
  85569. /**
  85570. * Names of glTF extensions used somewhere in this asset
  85571. */
  85572. extensionsUsed?: string[];
  85573. /**
  85574. * Names of glTF extensions required to properly load this asset
  85575. */
  85576. extensionsRequired?: string[];
  85577. /**
  85578. * An array of images. An image defines data used to create a texture
  85579. */
  85580. images?: IImage[];
  85581. /**
  85582. * An array of materials. A material defines the appearance of a primitive
  85583. */
  85584. materials?: IMaterial[];
  85585. /**
  85586. * An array of meshes. A mesh is a set of primitives to be rendered
  85587. */
  85588. meshes?: IMesh[];
  85589. /**
  85590. * An array of nodes
  85591. */
  85592. nodes?: INode[];
  85593. /**
  85594. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85595. */
  85596. samplers?: ISampler[];
  85597. /**
  85598. * The index of the default scene
  85599. */
  85600. scene?: number;
  85601. /**
  85602. * An array of scenes
  85603. */
  85604. scenes?: IScene[];
  85605. /**
  85606. * An array of skins. A skin is defined by joints and matrices
  85607. */
  85608. skins?: ISkin[];
  85609. /**
  85610. * An array of textures
  85611. */
  85612. textures?: ITexture[];
  85613. }
  85614. /**
  85615. * The glTF validation results
  85616. * @ignore
  85617. */
  85618. interface IGLTFValidationResults {
  85619. info: {
  85620. generator: string;
  85621. hasAnimations: boolean;
  85622. hasDefaultScene: boolean;
  85623. hasMaterials: boolean;
  85624. hasMorphTargets: boolean;
  85625. hasSkins: boolean;
  85626. hasTextures: boolean;
  85627. maxAttributesUsed: number;
  85628. primitivesCount: number
  85629. };
  85630. issues: {
  85631. messages: Array<string>;
  85632. numErrors: number;
  85633. numHints: number;
  85634. numInfos: number;
  85635. numWarnings: number;
  85636. truncated: boolean
  85637. };
  85638. mimeType: string;
  85639. uri: string;
  85640. validatedAt: string;
  85641. validatorVersion: string;
  85642. }
  85643. /**
  85644. * The glTF validation options
  85645. */
  85646. interface IGLTFValidationOptions {
  85647. /** Uri to use */
  85648. uri?: string;
  85649. /** Function used to load external resources */
  85650. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85651. /** Boolean indicating that we need to validate accessor data */
  85652. validateAccessorData?: boolean;
  85653. /** max number of issues allowed */
  85654. maxIssues?: number;
  85655. /** Ignored issues */
  85656. ignoredIssues?: Array<string>;
  85657. /** Value to override severy settings */
  85658. severityOverrides?: Object;
  85659. }
  85660. /**
  85661. * The glTF validator object
  85662. * @ignore
  85663. */
  85664. interface IGLTFValidator {
  85665. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85666. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85667. }
  85668. /**
  85669. * Interfaces from the EXT_lights_image_based extension
  85670. */
  85671. /** @hidden */
  85672. interface IEXTLightsImageBased_LightReferenceImageBased {
  85673. light: number;
  85674. }
  85675. /** @hidden */
  85676. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85677. intensity: number;
  85678. rotation: number[];
  85679. specularImageSize: number;
  85680. specularImages: number[][];
  85681. irradianceCoefficients: number[][];
  85682. }
  85683. /** @hidden */
  85684. interface IEXTLightsImageBased {
  85685. lights: IEXTLightsImageBased_LightImageBased[];
  85686. }
  85687. /**
  85688. * Interfaces from the EXT_mesh_gpu_instancing extension
  85689. * !!! Experimental Extension Subject to Changes !!!
  85690. */
  85691. /** @hidden */
  85692. interface IEXTMeshGpuInstancing {
  85693. mesh?: number;
  85694. attributes: { [name: string]: number };
  85695. }
  85696. /**
  85697. * Interfaces from the KHR_draco_mesh_compression extension
  85698. */
  85699. /** @hidden */
  85700. interface IKHRDracoMeshCompression {
  85701. bufferView: number;
  85702. attributes: { [name: string]: number };
  85703. }
  85704. /**
  85705. * Interfaces from the KHR_lights_punctual extension
  85706. */
  85707. /** @hidden */
  85708. const enum IKHRLightsPunctual_LightType {
  85709. DIRECTIONAL = "directional",
  85710. POINT = "point",
  85711. SPOT = "spot"
  85712. }
  85713. /** @hidden */
  85714. interface IKHRLightsPunctual_LightReference {
  85715. light: number;
  85716. }
  85717. /** @hidden */
  85718. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85719. type: IKHRLightsPunctual_LightType;
  85720. color?: number[];
  85721. intensity?: number;
  85722. range?: number;
  85723. spot?: {
  85724. innerConeAngle?: number;
  85725. outerConeAngle?: number;
  85726. };
  85727. }
  85728. /** @hidden */
  85729. interface IKHRLightsPunctual {
  85730. lights: IKHRLightsPunctual_Light[];
  85731. }
  85732. /**
  85733. * Interfaces from the KHR_materials_clearcoat extension
  85734. * !!! Experimental Extension Subject to Changes !!!
  85735. */
  85736. /** @hidden */
  85737. interface IKHRMaterialsClearcoat {
  85738. clearcoatFactor: number;
  85739. clearcoatTexture: ITextureInfo;
  85740. clearcoatRoughnessFactor: number;
  85741. clearcoatRoughnessTexture: ITextureInfo;
  85742. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85743. }
  85744. /**
  85745. * Interfaces from the KHR_materials_ior extension
  85746. * !!! Experimental Extension Subject to Changes !!!
  85747. */
  85748. /** @hidden */
  85749. interface IKHRMaterialsIor {
  85750. ior: number;
  85751. }
  85752. /**
  85753. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85754. */
  85755. /** @hidden */
  85756. interface IKHRMaterialsPbrSpecularGlossiness {
  85757. diffuseFactor: number[];
  85758. diffuseTexture: ITextureInfo;
  85759. specularFactor: number[];
  85760. glossinessFactor: number;
  85761. specularGlossinessTexture: ITextureInfo;
  85762. }
  85763. /**
  85764. * Interfaces from the KHR_materials_sheen extension
  85765. * !!! Experimental Extension Subject to Changes !!!
  85766. */
  85767. /** @hidden */
  85768. interface IKHRMaterialsSheen {
  85769. sheenColorFactor?: number[];
  85770. sheenTexture?: ITextureInfo;
  85771. sheenRoughnessFactor?: number;
  85772. }
  85773. /**
  85774. * Interfaces from the KHR_materials_specular extension
  85775. * !!! Experimental Extension Subject to Changes !!!
  85776. */
  85777. /** @hidden */
  85778. interface IKHRMaterialsSpecular {
  85779. specularFactor: number;
  85780. specularColorFactor: number[];
  85781. specularTexture: ITextureInfo;
  85782. }
  85783. /**
  85784. * Interfaces from the KHR_materials_transmission extension
  85785. * !!! Experimental Extension Subject to Changes !!!
  85786. */
  85787. /** @hidden */
  85788. interface IKHRMaterialsTransmission {
  85789. transmissionFactor?: number;
  85790. transmissionTexture?: ITextureInfo;
  85791. }
  85792. /**
  85793. * Interfaces from the KHR_materials_variants extension
  85794. * !!! Experimental Extension Subject to Changes !!!
  85795. */
  85796. /** @hidden */
  85797. interface IKHRMaterialVariants_Mapping extends IProperty {
  85798. mappings: Array<{
  85799. variants: number[];
  85800. material: number;
  85801. }>;
  85802. }
  85803. /** @hidden */
  85804. interface IKHRMaterialVariants_Variant extends IProperty {
  85805. name: string;
  85806. }
  85807. /** @hidden */
  85808. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85809. variants: Array<IKHRMaterialVariants_Variant>;
  85810. }
  85811. /**
  85812. * Interfaces from the KHR_texture_basisu extension
  85813. * !!! Experimental Extension Subject to Changes !!!
  85814. */
  85815. /** @hidden */
  85816. interface IKHRTextureBasisU {
  85817. source: number;
  85818. }
  85819. /**
  85820. * Interfaces from the EXT_texture_webp extension
  85821. */
  85822. /** @hidden */
  85823. interface IEXTTextureWebP {
  85824. source: number;
  85825. }
  85826. /**
  85827. * Interfaces from the KHR_texture_transform extension
  85828. */
  85829. /** @hidden */
  85830. interface IKHRTextureTransform {
  85831. offset?: number[];
  85832. rotation?: number;
  85833. scale?: number[];
  85834. texCoord?: number;
  85835. }
  85836. /**
  85837. * Interfaces from the KHR_xmp extension
  85838. * !!! Experimental Extension Subject to Changes !!!
  85839. */
  85840. /** @hidden */
  85841. interface IKHRXmp_Data {
  85842. [key: string]: unknown;
  85843. }
  85844. /** @hidden */
  85845. interface IKHRXmp_Gltf {
  85846. packets: IKHRXmp_Data[];
  85847. }
  85848. /** @hidden */
  85849. interface IKHRXmp_Node {
  85850. packet: number;
  85851. }
  85852. /**
  85853. * Interfaces from the MSFT_audio_emitter extension
  85854. */
  85855. /** @hidden */
  85856. interface IMSFTAudioEmitter_ClipReference {
  85857. clip: number;
  85858. weight?: number;
  85859. }
  85860. /** @hidden */
  85861. interface IMSFTAudioEmitter_EmittersReference {
  85862. emitters: number[];
  85863. }
  85864. /** @hidden */
  85865. const enum IMSFTAudioEmitter_DistanceModel {
  85866. linear = "linear",
  85867. inverse = "inverse",
  85868. exponential = "exponential",
  85869. }
  85870. /** @hidden */
  85871. interface IMSFTAudioEmitter_Emitter {
  85872. name?: string;
  85873. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  85874. refDistance?: number;
  85875. maxDistance?: number;
  85876. rolloffFactor?: number;
  85877. innerAngle?: number;
  85878. outerAngle?: number;
  85879. loop?: boolean;
  85880. volume?: number;
  85881. clips: IMSFTAudioEmitter_ClipReference[];
  85882. }
  85883. /** @hidden */
  85884. const enum IMSFTAudioEmitter_AudioMimeType {
  85885. WAV = "audio/wav",
  85886. }
  85887. /** @hidden */
  85888. interface IMSFTAudioEmitter_Clip extends IProperty {
  85889. uri?: string;
  85890. bufferView?: number;
  85891. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  85892. }
  85893. /** @hidden */
  85894. const enum IMSFTAudioEmitter_AnimationEventAction {
  85895. play = "play",
  85896. pause = "pause",
  85897. stop = "stop",
  85898. }
  85899. /** @hidden */
  85900. interface IMSFTAudioEmitter_AnimationEvent {
  85901. action: IMSFTAudioEmitter_AnimationEventAction;
  85902. emitter: number;
  85903. time: number;
  85904. startOffset?: number;
  85905. }
  85906. /**
  85907. * Interfaces from the MSFT_lod extension
  85908. */
  85909. /** @hidden */
  85910. interface IMSFTLOD {
  85911. ids: number[];
  85912. }
  85913. }
  85914. declare module BABYLON {
  85915. /** @hidden */
  85916. export var cellPixelShader: {
  85917. name: string;
  85918. shader: string;
  85919. };
  85920. }
  85921. declare module BABYLON {
  85922. /** @hidden */
  85923. export var cellVertexShader: {
  85924. name: string;
  85925. shader: string;
  85926. };
  85927. }
  85928. declare module BABYLON {
  85929. export class CellMaterial extends BABYLON.PushMaterial {
  85930. private _diffuseTexture;
  85931. diffuseTexture: BABYLON.BaseTexture;
  85932. diffuseColor: BABYLON.Color3;
  85933. _computeHighLevel: boolean;
  85934. computeHighLevel: boolean;
  85935. private _disableLighting;
  85936. disableLighting: boolean;
  85937. private _maxSimultaneousLights;
  85938. maxSimultaneousLights: number;
  85939. constructor(name: string, scene: BABYLON.Scene);
  85940. needAlphaBlending(): boolean;
  85941. needAlphaTesting(): boolean;
  85942. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  85943. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  85944. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  85945. getAnimatables(): BABYLON.IAnimatable[];
  85946. getActiveTextures(): BABYLON.BaseTexture[];
  85947. hasTexture(texture: BABYLON.BaseTexture): boolean;
  85948. dispose(forceDisposeEffect?: boolean): void;
  85949. getClassName(): string;
  85950. clone(name: string): CellMaterial;
  85951. serialize(): any;
  85952. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  85953. }
  85954. }
  85955. declare module BABYLON {
  85956. export class CustomShaderStructure {
  85957. FragmentStore: string;
  85958. VertexStore: string;
  85959. constructor();
  85960. }
  85961. export class ShaderSpecialParts {
  85962. constructor();
  85963. Fragment_Begin: string;
  85964. Fragment_Definitions: string;
  85965. Fragment_MainBegin: string;
  85966. Fragment_Custom_Diffuse: string;
  85967. Fragment_Before_Lights: string;
  85968. Fragment_Before_Fog: string;
  85969. Fragment_Custom_Alpha: string;
  85970. Fragment_Before_FragColor: string;
  85971. Vertex_Begin: string;
  85972. Vertex_Definitions: string;
  85973. Vertex_MainBegin: string;
  85974. Vertex_Before_PositionUpdated: string;
  85975. Vertex_Before_NormalUpdated: string;
  85976. Vertex_After_WorldPosComputed: string;
  85977. Vertex_MainEnd: string;
  85978. }
  85979. export class CustomMaterial extends BABYLON.StandardMaterial {
  85980. static ShaderIndexer: number;
  85981. CustomParts: ShaderSpecialParts;
  85982. _isCreatedShader: boolean;
  85983. _createdShaderName: string;
  85984. _customUniform: string[];
  85985. _newUniforms: string[];
  85986. _newUniformInstances: {
  85987. [name: string]: any;
  85988. };
  85989. _newSamplerInstances: {
  85990. [name: string]: BABYLON.Texture;
  85991. };
  85992. _customAttributes: string[];
  85993. FragmentShader: string;
  85994. VertexShader: string;
  85995. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  85996. ReviewUniform(name: string, arr: string[]): string[];
  85997. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  85998. constructor(name: string, scene: BABYLON.Scene);
  85999. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86000. AddAttribute(name: string): CustomMaterial;
  86001. Fragment_Begin(shaderPart: string): CustomMaterial;
  86002. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86003. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86004. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86005. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86006. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86007. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86008. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86009. Vertex_Begin(shaderPart: string): CustomMaterial;
  86010. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86011. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86012. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86013. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86014. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86015. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86016. }
  86017. }
  86018. declare module BABYLON {
  86019. export class ShaderAlebdoParts {
  86020. constructor();
  86021. Fragment_Begin: string;
  86022. Fragment_Definitions: string;
  86023. Fragment_MainBegin: string;
  86024. Fragment_Custom_Albedo: string;
  86025. Fragment_Before_Lights: string;
  86026. Fragment_Custom_MetallicRoughness: string;
  86027. Fragment_Custom_MicroSurface: string;
  86028. Fragment_Before_Fog: string;
  86029. Fragment_Custom_Alpha: string;
  86030. Fragment_Before_FragColor: string;
  86031. Vertex_Begin: string;
  86032. Vertex_Definitions: string;
  86033. Vertex_MainBegin: string;
  86034. Vertex_Before_PositionUpdated: string;
  86035. Vertex_Before_NormalUpdated: string;
  86036. Vertex_After_WorldPosComputed: string;
  86037. Vertex_MainEnd: string;
  86038. }
  86039. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86040. static ShaderIndexer: number;
  86041. CustomParts: ShaderAlebdoParts;
  86042. _isCreatedShader: boolean;
  86043. _createdShaderName: string;
  86044. _customUniform: string[];
  86045. _newUniforms: string[];
  86046. _newUniformInstances: {
  86047. [name: string]: any;
  86048. };
  86049. _newSamplerInstances: {
  86050. [name: string]: BABYLON.Texture;
  86051. };
  86052. _customAttributes: string[];
  86053. FragmentShader: string;
  86054. VertexShader: string;
  86055. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86056. ReviewUniform(name: string, arr: string[]): string[];
  86057. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86058. constructor(name: string, scene: BABYLON.Scene);
  86059. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86060. AddAttribute(name: string): PBRCustomMaterial;
  86061. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86062. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86063. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86064. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86065. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86066. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86067. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86068. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86069. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86070. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86071. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86072. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86073. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86074. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86075. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86076. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86077. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /** @hidden */
  86082. export var firePixelShader: {
  86083. name: string;
  86084. shader: string;
  86085. };
  86086. }
  86087. declare module BABYLON {
  86088. /** @hidden */
  86089. export var fireVertexShader: {
  86090. name: string;
  86091. shader: string;
  86092. };
  86093. }
  86094. declare module BABYLON {
  86095. export class FireMaterial extends BABYLON.PushMaterial {
  86096. private _diffuseTexture;
  86097. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86098. private _distortionTexture;
  86099. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86100. private _opacityTexture;
  86101. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86102. diffuseColor: BABYLON.Color3;
  86103. speed: number;
  86104. private _scaledDiffuse;
  86105. private _lastTime;
  86106. constructor(name: string, scene: BABYLON.Scene);
  86107. needAlphaBlending(): boolean;
  86108. needAlphaTesting(): boolean;
  86109. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86110. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86111. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86112. getAnimatables(): BABYLON.IAnimatable[];
  86113. getActiveTextures(): BABYLON.BaseTexture[];
  86114. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86115. getClassName(): string;
  86116. dispose(forceDisposeEffect?: boolean): void;
  86117. clone(name: string): FireMaterial;
  86118. serialize(): any;
  86119. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86120. }
  86121. }
  86122. declare module BABYLON {
  86123. /** @hidden */
  86124. export var furPixelShader: {
  86125. name: string;
  86126. shader: string;
  86127. };
  86128. }
  86129. declare module BABYLON {
  86130. /** @hidden */
  86131. export var furVertexShader: {
  86132. name: string;
  86133. shader: string;
  86134. };
  86135. }
  86136. declare module BABYLON {
  86137. export class FurMaterial extends BABYLON.PushMaterial {
  86138. private _diffuseTexture;
  86139. diffuseTexture: BABYLON.BaseTexture;
  86140. private _heightTexture;
  86141. heightTexture: BABYLON.BaseTexture;
  86142. diffuseColor: BABYLON.Color3;
  86143. furLength: number;
  86144. furAngle: number;
  86145. furColor: BABYLON.Color3;
  86146. furOffset: number;
  86147. furSpacing: number;
  86148. furGravity: BABYLON.Vector3;
  86149. furSpeed: number;
  86150. furDensity: number;
  86151. furOcclusion: number;
  86152. furTexture: BABYLON.DynamicTexture;
  86153. private _disableLighting;
  86154. disableLighting: boolean;
  86155. private _maxSimultaneousLights;
  86156. maxSimultaneousLights: number;
  86157. highLevelFur: boolean;
  86158. _meshes: BABYLON.AbstractMesh[];
  86159. private _furTime;
  86160. constructor(name: string, scene: BABYLON.Scene);
  86161. get furTime(): number;
  86162. set furTime(furTime: number);
  86163. needAlphaBlending(): boolean;
  86164. needAlphaTesting(): boolean;
  86165. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86166. updateFur(): void;
  86167. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86168. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86169. getAnimatables(): BABYLON.IAnimatable[];
  86170. getActiveTextures(): BABYLON.BaseTexture[];
  86171. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86172. dispose(forceDisposeEffect?: boolean): void;
  86173. clone(name: string): FurMaterial;
  86174. serialize(): any;
  86175. getClassName(): string;
  86176. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86177. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86178. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86179. }
  86180. }
  86181. declare module BABYLON {
  86182. /** @hidden */
  86183. export var gradientPixelShader: {
  86184. name: string;
  86185. shader: string;
  86186. };
  86187. }
  86188. declare module BABYLON {
  86189. /** @hidden */
  86190. export var gradientVertexShader: {
  86191. name: string;
  86192. shader: string;
  86193. };
  86194. }
  86195. declare module BABYLON {
  86196. export class GradientMaterial extends BABYLON.PushMaterial {
  86197. private _maxSimultaneousLights;
  86198. maxSimultaneousLights: number;
  86199. topColor: BABYLON.Color3;
  86200. topColorAlpha: number;
  86201. bottomColor: BABYLON.Color3;
  86202. bottomColorAlpha: number;
  86203. offset: number;
  86204. scale: number;
  86205. smoothness: number;
  86206. private _disableLighting;
  86207. disableLighting: boolean;
  86208. constructor(name: string, scene: BABYLON.Scene);
  86209. needAlphaBlending(): boolean;
  86210. needAlphaTesting(): boolean;
  86211. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86212. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86213. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86214. getAnimatables(): BABYLON.IAnimatable[];
  86215. dispose(forceDisposeEffect?: boolean): void;
  86216. clone(name: string): GradientMaterial;
  86217. serialize(): any;
  86218. getClassName(): string;
  86219. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86220. }
  86221. }
  86222. declare module BABYLON {
  86223. /** @hidden */
  86224. export var gridPixelShader: {
  86225. name: string;
  86226. shader: string;
  86227. };
  86228. }
  86229. declare module BABYLON {
  86230. /** @hidden */
  86231. export var gridVertexShader: {
  86232. name: string;
  86233. shader: string;
  86234. };
  86235. }
  86236. declare module BABYLON {
  86237. /**
  86238. * The grid materials allows you to wrap any shape with a grid.
  86239. * Colors are customizable.
  86240. */
  86241. export class GridMaterial extends BABYLON.PushMaterial {
  86242. /**
  86243. * Main color of the grid (e.g. between lines)
  86244. */
  86245. mainColor: BABYLON.Color3;
  86246. /**
  86247. * Color of the grid lines.
  86248. */
  86249. lineColor: BABYLON.Color3;
  86250. /**
  86251. * The scale of the grid compared to unit.
  86252. */
  86253. gridRatio: number;
  86254. /**
  86255. * Allows setting an offset for the grid lines.
  86256. */
  86257. gridOffset: BABYLON.Vector3;
  86258. /**
  86259. * The frequency of thicker lines.
  86260. */
  86261. majorUnitFrequency: number;
  86262. /**
  86263. * The visibility of minor units in the grid.
  86264. */
  86265. minorUnitVisibility: number;
  86266. /**
  86267. * The grid opacity outside of the lines.
  86268. */
  86269. opacity: number;
  86270. /**
  86271. * Determine RBG output is premultiplied by alpha value.
  86272. */
  86273. preMultiplyAlpha: boolean;
  86274. private _opacityTexture;
  86275. opacityTexture: BABYLON.BaseTexture;
  86276. private _gridControl;
  86277. /**
  86278. * constructor
  86279. * @param name The name given to the material in order to identify it afterwards.
  86280. * @param scene The scene the material is used in.
  86281. */
  86282. constructor(name: string, scene: BABYLON.Scene);
  86283. /**
  86284. * Returns wehter or not the grid requires alpha blending.
  86285. */
  86286. needAlphaBlending(): boolean;
  86287. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86288. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86289. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86290. /**
  86291. * Dispose the material and its associated resources.
  86292. * @param forceDisposeEffect will also dispose the used effect when true
  86293. */
  86294. dispose(forceDisposeEffect?: boolean): void;
  86295. clone(name: string): GridMaterial;
  86296. serialize(): any;
  86297. getClassName(): string;
  86298. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86299. }
  86300. }
  86301. declare module BABYLON {
  86302. /** @hidden */
  86303. export var lavaPixelShader: {
  86304. name: string;
  86305. shader: string;
  86306. };
  86307. }
  86308. declare module BABYLON {
  86309. /** @hidden */
  86310. export var lavaVertexShader: {
  86311. name: string;
  86312. shader: string;
  86313. };
  86314. }
  86315. declare module BABYLON {
  86316. export class LavaMaterial extends BABYLON.PushMaterial {
  86317. private _diffuseTexture;
  86318. diffuseTexture: BABYLON.BaseTexture;
  86319. noiseTexture: BABYLON.BaseTexture;
  86320. fogColor: BABYLON.Color3;
  86321. speed: number;
  86322. movingSpeed: number;
  86323. lowFrequencySpeed: number;
  86324. fogDensity: number;
  86325. private _lastTime;
  86326. diffuseColor: BABYLON.Color3;
  86327. private _disableLighting;
  86328. disableLighting: boolean;
  86329. private _unlit;
  86330. unlit: boolean;
  86331. private _maxSimultaneousLights;
  86332. maxSimultaneousLights: number;
  86333. private _scaledDiffuse;
  86334. constructor(name: string, scene: BABYLON.Scene);
  86335. needAlphaBlending(): boolean;
  86336. needAlphaTesting(): boolean;
  86337. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86338. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86339. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86340. getAnimatables(): BABYLON.IAnimatable[];
  86341. getActiveTextures(): BABYLON.BaseTexture[];
  86342. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86343. dispose(forceDisposeEffect?: boolean): void;
  86344. clone(name: string): LavaMaterial;
  86345. serialize(): any;
  86346. getClassName(): string;
  86347. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86348. }
  86349. }
  86350. declare module BABYLON {
  86351. /** @hidden */
  86352. export var mixPixelShader: {
  86353. name: string;
  86354. shader: string;
  86355. };
  86356. }
  86357. declare module BABYLON {
  86358. /** @hidden */
  86359. export var mixVertexShader: {
  86360. name: string;
  86361. shader: string;
  86362. };
  86363. }
  86364. declare module BABYLON {
  86365. export class MixMaterial extends BABYLON.PushMaterial {
  86366. /**
  86367. * Mix textures
  86368. */
  86369. private _mixTexture1;
  86370. mixTexture1: BABYLON.BaseTexture;
  86371. private _mixTexture2;
  86372. mixTexture2: BABYLON.BaseTexture;
  86373. /**
  86374. * Diffuse textures
  86375. */
  86376. private _diffuseTexture1;
  86377. diffuseTexture1: BABYLON.Texture;
  86378. private _diffuseTexture2;
  86379. diffuseTexture2: BABYLON.Texture;
  86380. private _diffuseTexture3;
  86381. diffuseTexture3: BABYLON.Texture;
  86382. private _diffuseTexture4;
  86383. diffuseTexture4: BABYLON.Texture;
  86384. private _diffuseTexture5;
  86385. diffuseTexture5: BABYLON.Texture;
  86386. private _diffuseTexture6;
  86387. diffuseTexture6: BABYLON.Texture;
  86388. private _diffuseTexture7;
  86389. diffuseTexture7: BABYLON.Texture;
  86390. private _diffuseTexture8;
  86391. diffuseTexture8: BABYLON.Texture;
  86392. /**
  86393. * Uniforms
  86394. */
  86395. diffuseColor: BABYLON.Color3;
  86396. specularColor: BABYLON.Color3;
  86397. specularPower: number;
  86398. private _disableLighting;
  86399. disableLighting: boolean;
  86400. private _maxSimultaneousLights;
  86401. maxSimultaneousLights: number;
  86402. constructor(name: string, scene: BABYLON.Scene);
  86403. needAlphaBlending(): boolean;
  86404. needAlphaTesting(): boolean;
  86405. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86406. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86407. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86408. getAnimatables(): BABYLON.IAnimatable[];
  86409. getActiveTextures(): BABYLON.BaseTexture[];
  86410. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86411. dispose(forceDisposeEffect?: boolean): void;
  86412. clone(name: string): MixMaterial;
  86413. serialize(): any;
  86414. getClassName(): string;
  86415. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86416. }
  86417. }
  86418. declare module BABYLON {
  86419. /** @hidden */
  86420. export var normalPixelShader: {
  86421. name: string;
  86422. shader: string;
  86423. };
  86424. }
  86425. declare module BABYLON {
  86426. /** @hidden */
  86427. export var normalVertexShader: {
  86428. name: string;
  86429. shader: string;
  86430. };
  86431. }
  86432. declare module BABYLON {
  86433. export class NormalMaterial extends BABYLON.PushMaterial {
  86434. private _diffuseTexture;
  86435. diffuseTexture: BABYLON.BaseTexture;
  86436. diffuseColor: BABYLON.Color3;
  86437. private _disableLighting;
  86438. disableLighting: boolean;
  86439. private _maxSimultaneousLights;
  86440. maxSimultaneousLights: number;
  86441. constructor(name: string, scene: BABYLON.Scene);
  86442. needAlphaBlending(): boolean;
  86443. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86444. needAlphaTesting(): boolean;
  86445. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86446. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86447. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86448. getAnimatables(): BABYLON.IAnimatable[];
  86449. getActiveTextures(): BABYLON.BaseTexture[];
  86450. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86451. dispose(forceDisposeEffect?: boolean): void;
  86452. clone(name: string): NormalMaterial;
  86453. serialize(): any;
  86454. getClassName(): string;
  86455. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86456. }
  86457. }
  86458. declare module BABYLON {
  86459. /** @hidden */
  86460. export var shadowOnlyPixelShader: {
  86461. name: string;
  86462. shader: string;
  86463. };
  86464. }
  86465. declare module BABYLON {
  86466. /** @hidden */
  86467. export var shadowOnlyVertexShader: {
  86468. name: string;
  86469. shader: string;
  86470. };
  86471. }
  86472. declare module BABYLON {
  86473. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86474. private _activeLight;
  86475. private _needAlphaBlending;
  86476. constructor(name: string, scene: BABYLON.Scene);
  86477. shadowColor: BABYLON.Color3;
  86478. needAlphaBlending(): boolean;
  86479. needAlphaTesting(): boolean;
  86480. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86481. get activeLight(): BABYLON.IShadowLight;
  86482. set activeLight(light: BABYLON.IShadowLight);
  86483. private _getFirstShadowLightForMesh;
  86484. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86485. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86486. clone(name: string): ShadowOnlyMaterial;
  86487. serialize(): any;
  86488. getClassName(): string;
  86489. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86490. }
  86491. }
  86492. declare module BABYLON {
  86493. /** @hidden */
  86494. export var simplePixelShader: {
  86495. name: string;
  86496. shader: string;
  86497. };
  86498. }
  86499. declare module BABYLON {
  86500. /** @hidden */
  86501. export var simpleVertexShader: {
  86502. name: string;
  86503. shader: string;
  86504. };
  86505. }
  86506. declare module BABYLON {
  86507. export class SimpleMaterial extends BABYLON.PushMaterial {
  86508. private _diffuseTexture;
  86509. diffuseTexture: BABYLON.BaseTexture;
  86510. diffuseColor: BABYLON.Color3;
  86511. private _disableLighting;
  86512. disableLighting: boolean;
  86513. private _maxSimultaneousLights;
  86514. maxSimultaneousLights: number;
  86515. constructor(name: string, scene: BABYLON.Scene);
  86516. needAlphaBlending(): boolean;
  86517. needAlphaTesting(): boolean;
  86518. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86519. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86520. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86521. getAnimatables(): BABYLON.IAnimatable[];
  86522. getActiveTextures(): BABYLON.BaseTexture[];
  86523. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86524. dispose(forceDisposeEffect?: boolean): void;
  86525. clone(name: string): SimpleMaterial;
  86526. serialize(): any;
  86527. getClassName(): string;
  86528. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86529. }
  86530. }
  86531. declare module BABYLON {
  86532. /** @hidden */
  86533. export var skyPixelShader: {
  86534. name: string;
  86535. shader: string;
  86536. };
  86537. }
  86538. declare module BABYLON {
  86539. /** @hidden */
  86540. export var skyVertexShader: {
  86541. name: string;
  86542. shader: string;
  86543. };
  86544. }
  86545. declare module BABYLON {
  86546. /**
  86547. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86548. * @see https://doc.babylonjs.com/extensions/sky
  86549. */
  86550. export class SkyMaterial extends BABYLON.PushMaterial {
  86551. /**
  86552. * Defines the overall luminance of sky in interval ]0, 1[.
  86553. */
  86554. luminance: number;
  86555. /**
  86556. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86557. */
  86558. turbidity: number;
  86559. /**
  86560. * Defines the sky appearance (light intensity).
  86561. */
  86562. rayleigh: number;
  86563. /**
  86564. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86565. */
  86566. mieCoefficient: number;
  86567. /**
  86568. * Defines the amount of haze particles following the Mie scattering theory.
  86569. */
  86570. mieDirectionalG: number;
  86571. /**
  86572. * Defines the distance of the sun according to the active scene camera.
  86573. */
  86574. distance: number;
  86575. /**
  86576. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86577. * "inclined".
  86578. */
  86579. inclination: number;
  86580. /**
  86581. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86582. * an object direction and a reference direction.
  86583. */
  86584. azimuth: number;
  86585. /**
  86586. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86587. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86588. */
  86589. sunPosition: BABYLON.Vector3;
  86590. /**
  86591. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86592. * .sunPosition property.
  86593. */
  86594. useSunPosition: boolean;
  86595. /**
  86596. * Defines an offset vector used to get a horizon offset.
  86597. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86598. */
  86599. cameraOffset: BABYLON.Vector3;
  86600. private _cameraPosition;
  86601. /**
  86602. * Instantiates a new sky material.
  86603. * This material allows to create dynamic and texture free
  86604. * effects for skyboxes by taking care of the atmosphere state.
  86605. * @see https://doc.babylonjs.com/extensions/sky
  86606. * @param name Define the name of the material in the scene
  86607. * @param scene Define the scene the material belong to
  86608. */
  86609. constructor(name: string, scene: BABYLON.Scene);
  86610. /**
  86611. * Specifies if the material will require alpha blending
  86612. * @returns a boolean specifying if alpha blending is needed
  86613. */
  86614. needAlphaBlending(): boolean;
  86615. /**
  86616. * Specifies if this material should be rendered in alpha test mode
  86617. * @returns false as the sky material doesn't need alpha testing.
  86618. */
  86619. needAlphaTesting(): boolean;
  86620. /**
  86621. * Get the texture used for alpha test purpose.
  86622. * @returns null as the sky material has no texture.
  86623. */
  86624. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86625. /**
  86626. * Get if the submesh is ready to be used and all its information available.
  86627. * Child classes can use it to update shaders
  86628. * @param mesh defines the mesh to check
  86629. * @param subMesh defines which submesh to check
  86630. * @param useInstances specifies that instances should be used
  86631. * @returns a boolean indicating that the submesh is ready or not
  86632. */
  86633. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86634. /**
  86635. * Binds the submesh to this material by preparing the effect and shader to draw
  86636. * @param world defines the world transformation matrix
  86637. * @param mesh defines the mesh containing the submesh
  86638. * @param subMesh defines the submesh to bind the material to
  86639. */
  86640. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86641. /**
  86642. * Get the list of animatables in the material.
  86643. * @returns the list of animatables object used in the material
  86644. */
  86645. getAnimatables(): BABYLON.IAnimatable[];
  86646. /**
  86647. * Disposes the material
  86648. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86649. */
  86650. dispose(forceDisposeEffect?: boolean): void;
  86651. /**
  86652. * Makes a duplicate of the material, and gives it a new name
  86653. * @param name defines the new name for the duplicated material
  86654. * @returns the cloned material
  86655. */
  86656. clone(name: string): SkyMaterial;
  86657. /**
  86658. * Serializes this material in a JSON representation
  86659. * @returns the serialized material object
  86660. */
  86661. serialize(): any;
  86662. /**
  86663. * Gets the current class name of the material e.g. "SkyMaterial"
  86664. * Mainly use in serialization.
  86665. * @returns the class name
  86666. */
  86667. getClassName(): string;
  86668. /**
  86669. * Creates a sky material from parsed material data
  86670. * @param source defines the JSON representation of the material
  86671. * @param scene defines the hosting scene
  86672. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86673. * @returns a new sky material
  86674. */
  86675. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86676. }
  86677. }
  86678. declare module BABYLON {
  86679. /** @hidden */
  86680. export var terrainPixelShader: {
  86681. name: string;
  86682. shader: string;
  86683. };
  86684. }
  86685. declare module BABYLON {
  86686. /** @hidden */
  86687. export var terrainVertexShader: {
  86688. name: string;
  86689. shader: string;
  86690. };
  86691. }
  86692. declare module BABYLON {
  86693. export class TerrainMaterial extends BABYLON.PushMaterial {
  86694. private _mixTexture;
  86695. mixTexture: BABYLON.BaseTexture;
  86696. private _diffuseTexture1;
  86697. diffuseTexture1: BABYLON.Texture;
  86698. private _diffuseTexture2;
  86699. diffuseTexture2: BABYLON.Texture;
  86700. private _diffuseTexture3;
  86701. diffuseTexture3: BABYLON.Texture;
  86702. private _bumpTexture1;
  86703. bumpTexture1: BABYLON.Texture;
  86704. private _bumpTexture2;
  86705. bumpTexture2: BABYLON.Texture;
  86706. private _bumpTexture3;
  86707. bumpTexture3: BABYLON.Texture;
  86708. diffuseColor: BABYLON.Color3;
  86709. specularColor: BABYLON.Color3;
  86710. specularPower: number;
  86711. private _disableLighting;
  86712. disableLighting: boolean;
  86713. private _maxSimultaneousLights;
  86714. maxSimultaneousLights: number;
  86715. constructor(name: string, scene: BABYLON.Scene);
  86716. needAlphaBlending(): boolean;
  86717. needAlphaTesting(): boolean;
  86718. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86721. getAnimatables(): BABYLON.IAnimatable[];
  86722. getActiveTextures(): BABYLON.BaseTexture[];
  86723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86724. dispose(forceDisposeEffect?: boolean): void;
  86725. clone(name: string): TerrainMaterial;
  86726. serialize(): any;
  86727. getClassName(): string;
  86728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86729. }
  86730. }
  86731. declare module BABYLON {
  86732. /** @hidden */
  86733. export var triplanarPixelShader: {
  86734. name: string;
  86735. shader: string;
  86736. };
  86737. }
  86738. declare module BABYLON {
  86739. /** @hidden */
  86740. export var triplanarVertexShader: {
  86741. name: string;
  86742. shader: string;
  86743. };
  86744. }
  86745. declare module BABYLON {
  86746. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86747. mixTexture: BABYLON.BaseTexture;
  86748. private _diffuseTextureX;
  86749. diffuseTextureX: BABYLON.BaseTexture;
  86750. private _diffuseTextureY;
  86751. diffuseTextureY: BABYLON.BaseTexture;
  86752. private _diffuseTextureZ;
  86753. diffuseTextureZ: BABYLON.BaseTexture;
  86754. private _normalTextureX;
  86755. normalTextureX: BABYLON.BaseTexture;
  86756. private _normalTextureY;
  86757. normalTextureY: BABYLON.BaseTexture;
  86758. private _normalTextureZ;
  86759. normalTextureZ: BABYLON.BaseTexture;
  86760. tileSize: number;
  86761. diffuseColor: BABYLON.Color3;
  86762. specularColor: BABYLON.Color3;
  86763. specularPower: number;
  86764. private _disableLighting;
  86765. disableLighting: boolean;
  86766. private _maxSimultaneousLights;
  86767. maxSimultaneousLights: number;
  86768. constructor(name: string, scene: BABYLON.Scene);
  86769. needAlphaBlending(): boolean;
  86770. needAlphaTesting(): boolean;
  86771. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86772. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86773. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86774. getAnimatables(): BABYLON.IAnimatable[];
  86775. getActiveTextures(): BABYLON.BaseTexture[];
  86776. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86777. dispose(forceDisposeEffect?: boolean): void;
  86778. clone(name: string): TriPlanarMaterial;
  86779. serialize(): any;
  86780. getClassName(): string;
  86781. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86782. }
  86783. }
  86784. declare module BABYLON {
  86785. /** @hidden */
  86786. export var waterPixelShader: {
  86787. name: string;
  86788. shader: string;
  86789. };
  86790. }
  86791. declare module BABYLON {
  86792. /** @hidden */
  86793. export var waterVertexShader: {
  86794. name: string;
  86795. shader: string;
  86796. };
  86797. }
  86798. declare module BABYLON {
  86799. export class WaterMaterial extends BABYLON.PushMaterial {
  86800. renderTargetSize: BABYLON.Vector2;
  86801. private _bumpTexture;
  86802. bumpTexture: BABYLON.BaseTexture;
  86803. diffuseColor: BABYLON.Color3;
  86804. specularColor: BABYLON.Color3;
  86805. specularPower: number;
  86806. private _disableLighting;
  86807. disableLighting: boolean;
  86808. private _maxSimultaneousLights;
  86809. maxSimultaneousLights: number;
  86810. /**
  86811. * @param {number}: Represents the wind force
  86812. */
  86813. windForce: number;
  86814. /**
  86815. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  86816. */
  86817. windDirection: BABYLON.Vector2;
  86818. /**
  86819. * @param {number}: Wave height, represents the height of the waves
  86820. */
  86821. waveHeight: number;
  86822. /**
  86823. * @param {number}: Bump height, represents the bump height related to the bump map
  86824. */
  86825. bumpHeight: number;
  86826. /**
  86827. * @param {boolean}: Add a smaller moving bump to less steady waves.
  86828. */
  86829. private _bumpSuperimpose;
  86830. bumpSuperimpose: boolean;
  86831. /**
  86832. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86833. */
  86834. private _fresnelSeparate;
  86835. fresnelSeparate: boolean;
  86836. /**
  86837. * @param {boolean}: bump Waves modify the reflection.
  86838. */
  86839. private _bumpAffectsReflection;
  86840. bumpAffectsReflection: boolean;
  86841. /**
  86842. * @param {number}: The water color blended with the refraction (near)
  86843. */
  86844. waterColor: BABYLON.Color3;
  86845. /**
  86846. * @param {number}: The blend factor related to the water color
  86847. */
  86848. colorBlendFactor: number;
  86849. /**
  86850. * @param {number}: The water color blended with the reflection (far)
  86851. */
  86852. waterColor2: BABYLON.Color3;
  86853. /**
  86854. * @param {number}: The blend factor related to the water color (reflection, far)
  86855. */
  86856. colorBlendFactor2: number;
  86857. /**
  86858. * @param {number}: Represents the maximum length of a wave
  86859. */
  86860. waveLength: number;
  86861. /**
  86862. * @param {number}: Defines the waves speed
  86863. */
  86864. waveSpeed: number;
  86865. /**
  86866. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  86867. * will avoid calculating useless pixels in the pixel shader of the water material.
  86868. */
  86869. disableClipPlane: boolean;
  86870. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  86871. private _mesh;
  86872. private _refractionRTT;
  86873. private _reflectionRTT;
  86874. private _reflectionTransform;
  86875. private _lastTime;
  86876. private _lastDeltaTime;
  86877. private _useLogarithmicDepth;
  86878. private _waitingRenderList;
  86879. private _imageProcessingConfiguration;
  86880. private _imageProcessingObserver;
  86881. /**
  86882. * Gets a boolean indicating that current material needs to register RTT
  86883. */
  86884. get hasRenderTargetTextures(): boolean;
  86885. /**
  86886. * Constructor
  86887. */
  86888. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  86889. get useLogarithmicDepth(): boolean;
  86890. set useLogarithmicDepth(value: boolean);
  86891. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86892. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  86893. addToRenderList(node: any): void;
  86894. enableRenderTargets(enable: boolean): void;
  86895. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  86896. get renderTargetsEnabled(): boolean;
  86897. needAlphaBlending(): boolean;
  86898. needAlphaTesting(): boolean;
  86899. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86900. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86901. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86902. private _createRenderTargets;
  86903. getAnimatables(): BABYLON.IAnimatable[];
  86904. getActiveTextures(): BABYLON.BaseTexture[];
  86905. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86906. dispose(forceDisposeEffect?: boolean): void;
  86907. clone(name: string): WaterMaterial;
  86908. serialize(): any;
  86909. getClassName(): string;
  86910. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  86911. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  86912. }
  86913. }
  86914. declare module BABYLON {
  86915. /** @hidden */
  86916. export var asciiartPixelShader: {
  86917. name: string;
  86918. shader: string;
  86919. };
  86920. }
  86921. declare module BABYLON {
  86922. /**
  86923. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  86924. *
  86925. * It basically takes care rendering the font front the given font size to a texture.
  86926. * This is used later on in the postprocess.
  86927. */
  86928. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  86929. private _font;
  86930. private _text;
  86931. private _charSize;
  86932. /**
  86933. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  86934. */
  86935. get charSize(): number;
  86936. /**
  86937. * Create a new instance of the Ascii Art FontTexture class
  86938. * @param name the name of the texture
  86939. * @param font the font to use, use the W3C CSS notation
  86940. * @param text the caracter set to use in the rendering.
  86941. * @param scene the scene that owns the texture
  86942. */
  86943. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  86944. /**
  86945. * Gets the max char width of a font.
  86946. * @param font the font to use, use the W3C CSS notation
  86947. * @return the max char width
  86948. */
  86949. private getFontWidth;
  86950. /**
  86951. * Gets the max char height of a font.
  86952. * @param font the font to use, use the W3C CSS notation
  86953. * @return the max char height
  86954. */
  86955. private getFontHeight;
  86956. /**
  86957. * Clones the current AsciiArtTexture.
  86958. * @return the clone of the texture.
  86959. */
  86960. clone(): AsciiArtFontTexture;
  86961. /**
  86962. * Parses a json object representing the texture and returns an instance of it.
  86963. * @param source the source JSON representation
  86964. * @param scene the scene to create the texture for
  86965. * @return the parsed texture
  86966. */
  86967. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  86968. }
  86969. /**
  86970. * Option available in the Ascii Art Post Process.
  86971. */
  86972. export interface IAsciiArtPostProcessOptions {
  86973. /**
  86974. * The font to use following the w3c font definition.
  86975. */
  86976. font?: string;
  86977. /**
  86978. * The character set to use in the postprocess.
  86979. */
  86980. characterSet?: string;
  86981. /**
  86982. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  86983. * This number is defined between 0 and 1;
  86984. */
  86985. mixToTile?: number;
  86986. /**
  86987. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  86988. * This number is defined between 0 and 1;
  86989. */
  86990. mixToNormal?: number;
  86991. }
  86992. /**
  86993. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  86994. *
  86995. * Simmply add it to your scene and let the nerd that lives in you have fun.
  86996. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  86997. */
  86998. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  86999. /**
  87000. * The font texture used to render the char in the post process.
  87001. */
  87002. private _asciiArtFontTexture;
  87003. /**
  87004. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87005. * This number is defined between 0 and 1;
  87006. */
  87007. mixToTile: number;
  87008. /**
  87009. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87010. * This number is defined between 0 and 1;
  87011. */
  87012. mixToNormal: number;
  87013. /**
  87014. * Instantiates a new Ascii Art Post Process.
  87015. * @param name the name to give to the postprocess
  87016. * @camera the camera to apply the post process to.
  87017. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87018. */
  87019. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87020. }
  87021. }
  87022. declare module BABYLON {
  87023. /** @hidden */
  87024. export var digitalrainPixelShader: {
  87025. name: string;
  87026. shader: string;
  87027. };
  87028. }
  87029. declare module BABYLON {
  87030. /**
  87031. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87032. *
  87033. * It basically takes care rendering the font front the given font size to a texture.
  87034. * This is used later on in the postprocess.
  87035. */
  87036. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87037. private _font;
  87038. private _text;
  87039. private _charSize;
  87040. /**
  87041. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87042. */
  87043. get charSize(): number;
  87044. /**
  87045. * Create a new instance of the Digital Rain FontTexture class
  87046. * @param name the name of the texture
  87047. * @param font the font to use, use the W3C CSS notation
  87048. * @param text the caracter set to use in the rendering.
  87049. * @param scene the scene that owns the texture
  87050. */
  87051. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87052. /**
  87053. * Gets the max char width of a font.
  87054. * @param font the font to use, use the W3C CSS notation
  87055. * @return the max char width
  87056. */
  87057. private getFontWidth;
  87058. /**
  87059. * Gets the max char height of a font.
  87060. * @param font the font to use, use the W3C CSS notation
  87061. * @return the max char height
  87062. */
  87063. private getFontHeight;
  87064. /**
  87065. * Clones the current DigitalRainFontTexture.
  87066. * @return the clone of the texture.
  87067. */
  87068. clone(): DigitalRainFontTexture;
  87069. /**
  87070. * Parses a json object representing the texture and returns an instance of it.
  87071. * @param source the source JSON representation
  87072. * @param scene the scene to create the texture for
  87073. * @return the parsed texture
  87074. */
  87075. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87076. }
  87077. /**
  87078. * Option available in the Digital Rain Post Process.
  87079. */
  87080. export interface IDigitalRainPostProcessOptions {
  87081. /**
  87082. * The font to use following the w3c font definition.
  87083. */
  87084. font?: string;
  87085. /**
  87086. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87087. * This number is defined between 0 and 1;
  87088. */
  87089. mixToTile?: number;
  87090. /**
  87091. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87092. * This number is defined between 0 and 1;
  87093. */
  87094. mixToNormal?: number;
  87095. }
  87096. /**
  87097. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87098. *
  87099. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87100. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87101. */
  87102. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87103. /**
  87104. * The font texture used to render the char in the post process.
  87105. */
  87106. private _digitalRainFontTexture;
  87107. /**
  87108. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87109. * This number is defined between 0 and 1;
  87110. */
  87111. mixToTile: number;
  87112. /**
  87113. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87114. * This number is defined between 0 and 1;
  87115. */
  87116. mixToNormal: number;
  87117. /**
  87118. * Instantiates a new Digital Rain Post Process.
  87119. * @param name the name to give to the postprocess
  87120. * @camera the camera to apply the post process to.
  87121. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87122. */
  87123. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87124. }
  87125. }
  87126. declare module BABYLON {
  87127. /** @hidden */
  87128. export var brickProceduralTexturePixelShader: {
  87129. name: string;
  87130. shader: string;
  87131. };
  87132. }
  87133. declare module BABYLON {
  87134. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87135. private _numberOfBricksHeight;
  87136. private _numberOfBricksWidth;
  87137. private _jointColor;
  87138. private _brickColor;
  87139. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87140. updateShaderUniforms(): void;
  87141. get numberOfBricksHeight(): number;
  87142. set numberOfBricksHeight(value: number);
  87143. get numberOfBricksWidth(): number;
  87144. set numberOfBricksWidth(value: number);
  87145. get jointColor(): BABYLON.Color3;
  87146. set jointColor(value: BABYLON.Color3);
  87147. get brickColor(): BABYLON.Color3;
  87148. set brickColor(value: BABYLON.Color3);
  87149. /**
  87150. * Serializes this brick procedural texture
  87151. * @returns a serialized brick procedural texture object
  87152. */
  87153. serialize(): any;
  87154. /**
  87155. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87156. * @param parsedTexture defines parsed texture data
  87157. * @param scene defines the current scene
  87158. * @param rootUrl defines the root URL containing brick procedural texture information
  87159. * @returns a parsed Brick Procedural BABYLON.Texture
  87160. */
  87161. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87162. }
  87163. }
  87164. declare module BABYLON {
  87165. /** @hidden */
  87166. export var cloudProceduralTexturePixelShader: {
  87167. name: string;
  87168. shader: string;
  87169. };
  87170. }
  87171. declare module BABYLON {
  87172. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87173. private _skyColor;
  87174. private _cloudColor;
  87175. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87176. updateShaderUniforms(): void;
  87177. get skyColor(): BABYLON.Color4;
  87178. set skyColor(value: BABYLON.Color4);
  87179. get cloudColor(): BABYLON.Color4;
  87180. set cloudColor(value: BABYLON.Color4);
  87181. /**
  87182. * Serializes this cloud procedural texture
  87183. * @returns a serialized cloud procedural texture object
  87184. */
  87185. serialize(): any;
  87186. /**
  87187. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87188. * @param parsedTexture defines parsed texture data
  87189. * @param scene defines the current scene
  87190. * @param rootUrl defines the root URL containing cloud procedural texture information
  87191. * @returns a parsed Cloud Procedural BABYLON.Texture
  87192. */
  87193. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87194. }
  87195. }
  87196. declare module BABYLON {
  87197. /** @hidden */
  87198. export var fireProceduralTexturePixelShader: {
  87199. name: string;
  87200. shader: string;
  87201. };
  87202. }
  87203. declare module BABYLON {
  87204. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87205. private _time;
  87206. private _speed;
  87207. private _autoGenerateTime;
  87208. private _fireColors;
  87209. private _alphaThreshold;
  87210. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87211. updateShaderUniforms(): void;
  87212. render(useCameraPostProcess?: boolean): void;
  87213. static get PurpleFireColors(): BABYLON.Color3[];
  87214. static get GreenFireColors(): BABYLON.Color3[];
  87215. static get RedFireColors(): BABYLON.Color3[];
  87216. static get BlueFireColors(): BABYLON.Color3[];
  87217. get autoGenerateTime(): boolean;
  87218. set autoGenerateTime(value: boolean);
  87219. get fireColors(): BABYLON.Color3[];
  87220. set fireColors(value: BABYLON.Color3[]);
  87221. get time(): number;
  87222. set time(value: number);
  87223. get speed(): BABYLON.Vector2;
  87224. set speed(value: BABYLON.Vector2);
  87225. get alphaThreshold(): number;
  87226. set alphaThreshold(value: number);
  87227. /**
  87228. * Serializes this fire procedural texture
  87229. * @returns a serialized fire procedural texture object
  87230. */
  87231. serialize(): any;
  87232. /**
  87233. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87234. * @param parsedTexture defines parsed texture data
  87235. * @param scene defines the current scene
  87236. * @param rootUrl defines the root URL containing fire procedural texture information
  87237. * @returns a parsed Fire Procedural BABYLON.Texture
  87238. */
  87239. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87240. }
  87241. }
  87242. declare module BABYLON {
  87243. /** @hidden */
  87244. export var grassProceduralTexturePixelShader: {
  87245. name: string;
  87246. shader: string;
  87247. };
  87248. }
  87249. declare module BABYLON {
  87250. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87251. private _grassColors;
  87252. private _groundColor;
  87253. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87254. updateShaderUniforms(): void;
  87255. get grassColors(): BABYLON.Color3[];
  87256. set grassColors(value: BABYLON.Color3[]);
  87257. get groundColor(): BABYLON.Color3;
  87258. set groundColor(value: BABYLON.Color3);
  87259. /**
  87260. * Serializes this grass procedural texture
  87261. * @returns a serialized grass procedural texture object
  87262. */
  87263. serialize(): any;
  87264. /**
  87265. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87266. * @param parsedTexture defines parsed texture data
  87267. * @param scene defines the current scene
  87268. * @param rootUrl defines the root URL containing grass procedural texture information
  87269. * @returns a parsed Grass Procedural BABYLON.Texture
  87270. */
  87271. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87272. }
  87273. }
  87274. declare module BABYLON {
  87275. /** @hidden */
  87276. export var marbleProceduralTexturePixelShader: {
  87277. name: string;
  87278. shader: string;
  87279. };
  87280. }
  87281. declare module BABYLON {
  87282. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87283. private _numberOfTilesHeight;
  87284. private _numberOfTilesWidth;
  87285. private _amplitude;
  87286. private _jointColor;
  87287. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87288. updateShaderUniforms(): void;
  87289. get numberOfTilesHeight(): number;
  87290. set numberOfTilesHeight(value: number);
  87291. get amplitude(): number;
  87292. set amplitude(value: number);
  87293. get numberOfTilesWidth(): number;
  87294. set numberOfTilesWidth(value: number);
  87295. get jointColor(): BABYLON.Color3;
  87296. set jointColor(value: BABYLON.Color3);
  87297. /**
  87298. * Serializes this marble procedural texture
  87299. * @returns a serialized marble procedural texture object
  87300. */
  87301. serialize(): any;
  87302. /**
  87303. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87304. * @param parsedTexture defines parsed texture data
  87305. * @param scene defines the current scene
  87306. * @param rootUrl defines the root URL containing marble procedural texture information
  87307. * @returns a parsed Marble Procedural BABYLON.Texture
  87308. */
  87309. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87310. }
  87311. }
  87312. declare module BABYLON {
  87313. /** @hidden */
  87314. export var normalMapProceduralTexturePixelShader: {
  87315. name: string;
  87316. shader: string;
  87317. };
  87318. }
  87319. declare module BABYLON {
  87320. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87321. private _baseTexture;
  87322. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87323. updateShaderUniforms(): void;
  87324. render(useCameraPostProcess?: boolean): void;
  87325. resize(size: any, generateMipMaps: any): void;
  87326. get baseTexture(): BABYLON.Texture;
  87327. set baseTexture(texture: BABYLON.Texture);
  87328. /**
  87329. * Serializes this normal map procedural texture
  87330. * @returns a serialized normal map procedural texture object
  87331. */
  87332. serialize(): any;
  87333. /**
  87334. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87335. * @param parsedTexture defines parsed texture data
  87336. * @param scene defines the current scene
  87337. * @param rootUrl defines the root URL containing normal map procedural texture information
  87338. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87339. */
  87340. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87341. }
  87342. }
  87343. declare module BABYLON {
  87344. /** @hidden */
  87345. export var perlinNoiseProceduralTexturePixelShader: {
  87346. name: string;
  87347. shader: string;
  87348. };
  87349. }
  87350. declare module BABYLON {
  87351. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87352. time: number;
  87353. timeScale: number;
  87354. translationSpeed: number;
  87355. private _currentTranslation;
  87356. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87357. updateShaderUniforms(): void;
  87358. render(useCameraPostProcess?: boolean): void;
  87359. resize(size: any, generateMipMaps: any): void;
  87360. /**
  87361. * Serializes this perlin noise procedural texture
  87362. * @returns a serialized perlin noise procedural texture object
  87363. */
  87364. serialize(): any;
  87365. /**
  87366. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87367. * @param parsedTexture defines parsed texture data
  87368. * @param scene defines the current scene
  87369. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87370. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87371. */
  87372. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87373. }
  87374. }
  87375. declare module BABYLON {
  87376. /** @hidden */
  87377. export var roadProceduralTexturePixelShader: {
  87378. name: string;
  87379. shader: string;
  87380. };
  87381. }
  87382. declare module BABYLON {
  87383. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87384. private _roadColor;
  87385. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87386. updateShaderUniforms(): void;
  87387. get roadColor(): BABYLON.Color3;
  87388. set roadColor(value: BABYLON.Color3);
  87389. /**
  87390. * Serializes this road procedural texture
  87391. * @returns a serialized road procedural texture object
  87392. */
  87393. serialize(): any;
  87394. /**
  87395. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87396. * @param parsedTexture defines parsed texture data
  87397. * @param scene defines the current scene
  87398. * @param rootUrl defines the root URL containing road procedural texture information
  87399. * @returns a parsed Road Procedural BABYLON.Texture
  87400. */
  87401. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87402. }
  87403. }
  87404. declare module BABYLON {
  87405. /** @hidden */
  87406. export var starfieldProceduralTexturePixelShader: {
  87407. name: string;
  87408. shader: string;
  87409. };
  87410. }
  87411. declare module BABYLON {
  87412. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87413. private _time;
  87414. private _alpha;
  87415. private _beta;
  87416. private _zoom;
  87417. private _formuparam;
  87418. private _stepsize;
  87419. private _tile;
  87420. private _brightness;
  87421. private _darkmatter;
  87422. private _distfading;
  87423. private _saturation;
  87424. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87425. updateShaderUniforms(): void;
  87426. get time(): number;
  87427. set time(value: number);
  87428. get alpha(): number;
  87429. set alpha(value: number);
  87430. get beta(): number;
  87431. set beta(value: number);
  87432. get formuparam(): number;
  87433. set formuparam(value: number);
  87434. get stepsize(): number;
  87435. set stepsize(value: number);
  87436. get zoom(): number;
  87437. set zoom(value: number);
  87438. get tile(): number;
  87439. set tile(value: number);
  87440. get brightness(): number;
  87441. set brightness(value: number);
  87442. get darkmatter(): number;
  87443. set darkmatter(value: number);
  87444. get distfading(): number;
  87445. set distfading(value: number);
  87446. get saturation(): number;
  87447. set saturation(value: number);
  87448. /**
  87449. * Serializes this starfield procedural texture
  87450. * @returns a serialized starfield procedural texture object
  87451. */
  87452. serialize(): any;
  87453. /**
  87454. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87455. * @param parsedTexture defines parsed texture data
  87456. * @param scene defines the current scene
  87457. * @param rootUrl defines the root URL containing startfield procedural texture information
  87458. * @returns a parsed Starfield Procedural BABYLON.Texture
  87459. */
  87460. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87461. }
  87462. }
  87463. declare module BABYLON {
  87464. /** @hidden */
  87465. export var woodProceduralTexturePixelShader: {
  87466. name: string;
  87467. shader: string;
  87468. };
  87469. }
  87470. declare module BABYLON {
  87471. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87472. private _ampScale;
  87473. private _woodColor;
  87474. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87475. updateShaderUniforms(): void;
  87476. get ampScale(): number;
  87477. set ampScale(value: number);
  87478. get woodColor(): BABYLON.Color3;
  87479. set woodColor(value: BABYLON.Color3);
  87480. /**
  87481. * Serializes this wood procedural texture
  87482. * @returns a serialized wood procedural texture object
  87483. */
  87484. serialize(): any;
  87485. /**
  87486. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87487. * @param parsedTexture defines parsed texture data
  87488. * @param scene defines the current scene
  87489. * @param rootUrl defines the root URL containing wood procedural texture information
  87490. * @returns a parsed Wood Procedural BABYLON.Texture
  87491. */
  87492. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87493. }
  87494. }